diff --git a/light.cpp b/light.cpp index 38db627..5e409f6 100755 --- a/light.cpp +++ b/light.cpp @@ -56,7 +56,7 @@ namespace vb01{ Node *rootNode = root->getRootNode(); vector descendants; vector lights; - rootNode->getDescendants(rootNode, descendants); + rootNode->getDescendants(descendants); descendants.push_back(rootNode); std::vector materials; Camera *cam=root->getCamera(); diff --git a/mesh.cpp b/mesh.cpp index c1db1dc..a47a723 100755 --- a/mesh.cpp +++ b/mesh.cpp @@ -45,7 +45,7 @@ namespace vb01{ } void Mesh::construct(){ - initFramebuffer(); + //initFramebuffer(); initMesh(); } @@ -70,11 +70,11 @@ namespace vb01{ if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) cout<<"Not complete\n"; + + glBindFramebuffer(GL_FRAMEBUFFER, 0); } void Mesh::initMesh(){ - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); @@ -211,7 +211,7 @@ namespace vb01{ environmentShader->use(); Node *rootNode = root->getRootNode(); vector descendants; - rootNode->getDescendants(rootNode, descendants); + rootNode->getDescendants(descendants); for(Node *n : descendants){ for(Mesh *m : n->getMeshes()) if(m != this){ diff --git a/model.cpp b/model.cpp index dce619f..22b65bf 100755 --- a/model.cpp +++ b/model.cpp @@ -34,7 +34,7 @@ namespace vb01{ delete children[0]->getMesh(0)->getMaterial(); vector descendants; - getDescendants(this,descendants); + getDescendants(descendants); for(Node *node : descendants) for(Mesh *mesh : node->getMeshes()) mesh->setMaterial(nullptr); @@ -52,7 +52,7 @@ namespace vb01{ void Model::setMaterial(Material *mat){ vector descendants; - getDescendants(this, descendants); + getDescendants(descendants); for(Node *node : descendants) for(Mesh *mesh : node->getMeshes()) mesh->setMaterial(mat); @@ -60,7 +60,7 @@ namespace vb01{ void Model::setCastShadow(bool castShadow){ vector descendants; - getDescendants(this, descendants); + getDescendants(descendants); for(Node *node : descendants) for(Mesh *mesh : node->getMeshes()) mesh->setCastShadow(castShadow); @@ -69,19 +69,19 @@ namespace vb01{ void Model::setReflect(bool reflect){ vector descendants; - getDescendants(this, descendants); + getDescendants(descendants); for(Node *node : descendants) for(Mesh *mesh : node->getMeshes()) mesh->setReflect(reflect); this->reflect = reflect; } - void Model::setWireframe(bool wirefame){ + void Model::setWireframe(bool wireframe){ vector descendants; - getDescendants(this, descendants); + getDescendants(descendants); for(Node *node : descendants) for(Mesh *mesh : node->getMeshes()) - mesh->setWireframe(wirefame); + mesh->setWireframe(wireframe); this->wireframe = wireframe; } } diff --git a/node.cpp b/node.cpp index 8779a97..5b00029 100755 --- a/node.cpp +++ b/node.cpp @@ -157,12 +157,11 @@ namespace vb01{ setOrientation(newRot * oldRot); } - void Node::getDescendants(Node *node, vector &descendants){ - for(Node *child : node->getChildren()){ - if(child->getNumChildren() > 0) - getDescendants(child, descendants); - else - descendants.push_back(child); + void Node::getDescendants(vector &descendants){ + for(Node *child : getChildren()){ + descendants.push_back(child); + if(!child->getChildren().empty()) + child->getDescendants(descendants); } } @@ -292,7 +291,7 @@ namespace vb01{ Node *rootNode = root->getRootNode(); vector descendants; - rootNode->getDescendants(rootNode, descendants); + rootNode->getDescendants(descendants); descendants.push_back(rootNode); for(Node *n : descendants){ diff --git a/node.h b/node.h index a9d36f1..c444343 100755 --- a/node.h +++ b/node.h @@ -35,7 +35,7 @@ namespace vb01{ virtual void lookAt(Vector3, Node*); void updateAxis(); void setOrientation(Quaternion); - void getDescendants(Node*, std::vector&); + void getDescendants(std::vector&); std::vector getAncestors(Node *anc = Root::getSingleton()->getRootNode()); Vector3 localToGlobalPosition(Vector3); Vector3 globalToLocalPosition(Vector3);