/*! The SLRefGroup::shapeInit checks the validity of the referenced node. To avoid endless loops a refShape node is not allowed to refShape its ancestors. An ancestor of a refShape node is group node followed along the previous pointers with lower depth than the depth of the refShape node. */ void SLRefGroup::shapeInit(SLSceneView* sv) { // cummulate wm with referenced wm SLShape* ref = (SLShape*)_refGroup; _wm *= ref->m(); _wmI.setMatrix(_wm.inverse()); _wmN.setMatrix(_wmI.mat3()); _wmN.transpose(); // check circular references SLNode* parent = this->parent(); while (parent) { if (parent==_refGroup) SL_EXIT_MSG("Reference node produces a never ending loop."); parent = parent->parent(); } // set transparency flag _aabb.hasAlpha(((SLShape*)_refGroup)->aabb()->hasAlpha()); // delete all child references if (_first) deleteAll(); // loop through the referenced group and add a SLRefShape or SLRefGroup SLNode* current = ((SLGroup*)_refGroup)->first(); while (current) { if (typeid(*current)==typeid(SLGroup)) addNode(new SLRefGroup((SLGroup*)current, name()+"_"+current->name())); else addNode(new SLRefShape((SLShape*)current, name()+"_"+current->name())); ((SLShape*)_last)->wm(_wm); ((SLShape*)_last)->depth(depth()+1); ((SLShape*)_last)->shapeInit(sv); current = current->next(); } }
/*! SLGroup::getNode finds a node by a name */ SLNode* SLGroup::getNode(SLstring name) { SLNode* current = _first; while (current) { if(current->name() == name) return current; if (typeid(*current)==typeid(SLGroup)) { SLNode* found = ((SLGroup*)current)->getNode(name); if (found) return found; } current = current->next(); } return 0; }