Ha! What a coincidence. I just encountered this exact same thing today.

When you call "new Node", you get a Node. Nodes don't have children, only
Groups have children. So you don't want to use the copy constructor if you
want to copy a whole subtree.

I discovered that OSG offers an alternative to the copy constructor to get
around just this very issue. Use the clone() method. So, instead, your code
should look like this:

  osg::ref_ptr<osg::Node> copyA = A->clone( osg::CopyOp::DEEP_COPY_ALL );

"copyA" will be a ref_ptr to a Node, but the actual type of the object
pointed to will be a clone of A, so if A is a Group (with children), then
copyA will also be a Group.

Later,
   -Paul


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Judie
> Sent: Wednesday, April 16, 2008 2:21 PM
> To: [email protected]
> Subject: [osg-users] Using a visitor after a DEEP_COPY_ALL 
> doesn't returnanything
> 
> HI,
> 
> I want to make a copy of an existing node and all it's 
> children, and then find all the geometry and make it transparent.
> 
> I do something like
> 
> osg::ref_ptr<osg::Node> copyA = new osg::Node(*A, 
> osg::CopyOp::DEEP_COPY_ALL);
> 
> where A is the original Node tree.
> 
> If I try to use the findNodeVisitor:
> 
> findNodeVisitor nv(FINDNODETYPE_NODETYPE|FINDNODETYPE_FINDALL,
> "Geode");
> copyA->accept(nv);
> std::vector<osg::Node*> nodeList = nv.getNodeList(); int 
> length = nodeList.size();
> 
> then length is 0.
> 
> If I do the same with the original node:
> 
> findNodeVisitor nv(FINDNODETYPE_NODETYPE|FINDNODETYPE_FINDALL,
> "Geode");
> A->accept(nv);
> std::vector<osg::Node*> nodeList = nv.getNodeList(); int 
> length = nodeList.size();
> 
> then length is 32.
> 
> Also if I try to cast the copyA to a osg::Group* I get a null pointer:
> 
> osg::Group* temp = dynamic_cast<osg::Group*>(copyA);
> 
> temp is a null pointer.
> 
> So did I miss a step somewhere?
> 
> Judie
> 
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce
> negraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to