Hello,

I'm trying to create a remove DOFTransform visitor.  I tried this:
void RemoveDofVisitor::apply(osg::Transform& node)
{
   if(dynamic_cast<const osgSim::DOFTransform*>(&node)){
      osgSim::DOFTransform* pDofNode =
dynamic_cast<osgSim::DOFTransform*>(&node);
      if ( pDofNode->getNumParents() > 0 ){
         osg::Group* parent = pDofNode->getParent(0);
         for( unsigned int i=0; i<pDofNode->getNumChildren(); i++ ){        
            //TODO make this work for multiple parents.
            //Set grandparent of dofs children its parents.
            parent->addChild(pDofNode->getChild(i));
         }
         //Remove children from DOF
         pDofNode->removeChild(0, pDofNode->getNumChildren());
         //Remove dof from tree
         parent->removeChild(pDofNode);
         apply((osg::Node&)*parent);
      }
   }else{
      apply((osg::Node&)node);
   }
}

But, it crashes.  Should this first be done by collecting DOFs with a
visitor, and then removing them from the scene graph?  Or would it be safer
to replace the DOFTransform with an osg::Group?

Thanks.

Zach 
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to