nuclear@8: #include "opengl.h" nuclear@8: #include "co_mesh.h" nuclear@8: #include "co_xform.h" nuclear@8: #include "gobj.h" nuclear@8: nuclear@8: static CoMesh reg_co_mesh; nuclear@8: static Component *cons_co_mesh() { return new CoMesh; } nuclear@8: nuclear@8: CoMesh::CoMesh() nuclear@8: { nuclear@8: name = "mesh"; nuclear@8: mesh = 0; nuclear@8: nuclear@8: register_component(name, cons_co_mesh); nuclear@8: } nuclear@8: nuclear@8: CoMesh::~CoMesh() nuclear@8: { nuclear@8: delete mesh; nuclear@8: } nuclear@8: nuclear@8: void CoMesh::draw() const nuclear@8: { nuclear@8: if(!mesh) return; nuclear@8: nuclear@8: CoXForm *co_xform = COCAST(CoXForm, gobj->get_component("xform")); nuclear@8: if(co_xform) { nuclear@8: glPushMatrix(); nuclear@8: glMultTransposeMatrixf(co_xform->xform[0]); nuclear@8: } nuclear@8: nuclear@8: mesh->draw(); nuclear@8: nuclear@8: if(co_xform) { nuclear@8: glPopMatrix(); nuclear@8: } nuclear@8: } nuclear@8: nuclear@8: nuclear@8: CoMesh *gobj_co_mesh(const GObject *obj, bool nofail) nuclear@8: { nuclear@8: CoMesh *co = COCAST(CoMesh, obj->get_component("mesh")); nuclear@8: if(co) return co; nuclear@8: nuclear@8: return nofail ? ®_co_mesh : 0; nuclear@8: }