diff --git a/node.cpp b/node.cpp index 8060b9b..d57cd3e 100755 --- a/node.cpp +++ b/node.cpp @@ -422,6 +422,21 @@ namespace vb01{ return origin; } + Node* Node::findDescendant(string name, bool allDescendants){ + vector descendants = children; + + if(allDescendants){ + descendants.clear(); + getDescendants(descendants); + } + + for(Node *desc : descendants) + if(desc->getName() == name) + return desc; + + return nullptr; + } + void Node::updateShaders(){ Root *root = Root::getSingleton(); diff --git a/node.h b/node.h index 58c1b90..bce352c 100755 --- a/node.h +++ b/node.h @@ -45,6 +45,7 @@ namespace vb01{ Quaternion globalToLocalOrientation(Quaternion); Vector3 localToGlobalScale(Vector3); Vector3 globalToLocalScale(Vector3); + Node* findDescendant(std::string, bool=false); inline void dettachMesh(int id){meshes.erase(meshes.begin() + id);} inline Skeleton* getSkeleton(int i){return skeletons[i];} inline int getNumSkeletons(){return skeletons.size();}