diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 6b1d664..0a69534 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -23,15 +23,15 @@ void Mesh::customDraw() { glCullFace(GL_BACK); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } - - + + //ofDrawBox(0, 0, 0, 1); + for(Part& part: parts) { if(part.hasTriangles) part.draw(); } } - void Mesh::drawNormals(float length) { bool lightOn = ofGetLightingEnabled(); if(lightOn) diff --git a/src/Object.cpp b/src/Object.cpp index 40b6f14..711345a 100644 --- a/src/Object.cpp +++ b/src/Object.cpp @@ -53,10 +53,11 @@ void Object::draw(Scene* scn) { ofNode::transformGL(); customDraw(); + ofNode::restoreTransformGL(); + for(Object* child: children) { child->draw(scn); } - ofNode::restoreTransformGL(); postDraw(); } @@ -64,9 +65,9 @@ void Object::draw(Scene* scn) { void Object::customDraw() { } -void Object::addChild(Object* child) { +void Object::addChild(Object* child, bool keepGlobalTransform) { child->parent = this; - child->setParent(*this, true); + child->setParent(*this, keepGlobalTransform); children.push_back(child); } diff --git a/src/Object.h b/src/Object.h index 93b6091..264e339 100644 --- a/src/Object.h +++ b/src/Object.h @@ -38,7 +38,7 @@ class Object: public ofNode { virtual void customDraw(); virtual void postDraw(){}; - void addChild(Object* child); + void addChild(Object* child, bool keepGlobalTransform=false); std::vector getChildren(); Object* getParent(); bool hasParent(); diff --git a/src/Parser.h b/src/Parser.h index 39522f3..58d7892 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -772,8 +772,8 @@ class Parser { DNAStructureReader parentReader = reader.readStructure("parent"); Object* parent = static_cast(parentReader.parse()); if(parent != NULL) { - parent->addChild(object); object->setTransformMatrix(mat * ofMatrix4x4::getInverseOf(parent->getGlobalTransformMatrix())); + parent->addChild(object, false); } } diff --git a/src/Scene.cpp b/src/Scene.cpp index 3643eb5..3849681 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -80,7 +80,6 @@ void Scene::customDraw() { //lights if(doLightning) { - if(lights.size()>0) { ofSetSmoothLighting(true); ofEnableLighting();