Skip to content

Commit

Permalink
fixed mesh offset of parent / child
Browse files Browse the repository at this point in the history
  • Loading branch information
underdoeg committed Jul 7, 2014
1 parent ec55dcc commit 222eadb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,21 @@ void Object::draw(Scene* scn) {

ofNode::transformGL();
customDraw();
ofNode::restoreTransformGL();

for(Object* child: children) {
child->draw(scn);
}
ofNode::restoreTransformGL();

postDraw();
}

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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object*> getChildren();
Object* getParent();
bool hasParent();
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ class Parser {
DNAStructureReader parentReader = reader.readStructure("parent");
Object* parent = static_cast<Object*>(parentReader.parse());
if(parent != NULL) {
parent->addChild(object);
object->setTransformMatrix(mat * ofMatrix4x4::getInverseOf(parent->getGlobalTransformMatrix()));
parent->addChild(object, false);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void Scene::customDraw() {

//lights
if(doLightning) {

if(lights.size()>0) {
ofSetSmoothLighting(true);
ofEnableLighting();
Expand Down

0 comments on commit 222eadb

Please # to comment.