mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
improved descendants retrieval method
This commit is contained in:
@@ -56,7 +56,7 @@ namespace vb01{
|
||||
Node *rootNode = root->getRootNode();
|
||||
vector<Node*> descendants;
|
||||
vector<Light*> lights;
|
||||
rootNode->getDescendants(rootNode, descendants);
|
||||
rootNode->getDescendants(descendants);
|
||||
descendants.push_back(rootNode);
|
||||
std::vector<Material*> materials;
|
||||
Camera *cam=root->getCamera();
|
||||
|
||||
@@ -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<Node*> descendants;
|
||||
rootNode->getDescendants(rootNode, descendants);
|
||||
rootNode->getDescendants(descendants);
|
||||
for(Node *n : descendants){
|
||||
for(Mesh *m : n->getMeshes())
|
||||
if(m != this){
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace vb01{
|
||||
delete children[0]->getMesh(0)->getMaterial();
|
||||
|
||||
vector<Node*> 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<Node*> 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<Node*> 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<Node*> 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<Node*> descendants;
|
||||
getDescendants(this, descendants);
|
||||
getDescendants(descendants);
|
||||
for(Node *node : descendants)
|
||||
for(Mesh *mesh : node->getMeshes())
|
||||
mesh->setWireframe(wirefame);
|
||||
mesh->setWireframe(wireframe);
|
||||
this->wireframe = wireframe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,12 +157,11 @@ namespace vb01{
|
||||
setOrientation(newRot * oldRot);
|
||||
}
|
||||
|
||||
void Node::getDescendants(Node *node, vector<Node*> &descendants){
|
||||
for(Node *child : node->getChildren()){
|
||||
if(child->getNumChildren() > 0)
|
||||
getDescendants(child, descendants);
|
||||
else
|
||||
descendants.push_back(child);
|
||||
void Node::getDescendants(vector<Node*> &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<Node*> descendants;
|
||||
rootNode->getDescendants(rootNode, descendants);
|
||||
rootNode->getDescendants(descendants);
|
||||
descendants.push_back(rootNode);
|
||||
|
||||
for(Node *n : descendants){
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace vb01{
|
||||
virtual void lookAt(Vector3, Node*);
|
||||
void updateAxis();
|
||||
void setOrientation(Quaternion);
|
||||
void getDescendants(Node*, std::vector<Node*>&);
|
||||
void getDescendants(std::vector<Node*>&);
|
||||
std::vector<Node*> getAncestors(Node *anc = Root::getSingleton()->getRootNode());
|
||||
Vector3 localToGlobalPosition(Vector3);
|
||||
Vector3 globalToLocalPosition(Vector3);
|
||||
|
||||
Reference in New Issue
Block a user