Hi Judie,

You may check that all the nodes contained into your graph have the clone
method implemented. Do you have some custom nodes into the graph ?

On Thu, Apr 17, 2008 at 6:00 PM, Judie <[EMAIL PROTECTED]> wrote:

> Hi Serge,
>
> Thanks for that piece of information. I am still not getting a "deep
> copy" of the nodes, however.
>
> I did an experiment and I went to the top level node:
>
> osg::Node* subgraph = m_sceneView->getSceneData();
>
> and I used this one for the deep copy
>
> osg::ref_ptr<osg::Node> copyA  = static_cast<osg::Node *>(subgraph-
> >clone(osg::CopyOp::DEEP_COPY_ALL ));
>
> And now I get a few nodes in the new copy. My list now contains 3
> items which makes sense because the tree is like:
>
> subgraph
>      \
>     GroupA
>         \
>         A
>      /   |  \
>    B   C   D
>
> where A has 32 items.
>
>
> So there is stoppage at node A and no more copy or else there is a
> problem with the visitor.
>
> findNodeVisitor nv(FINDNODETYPE_NODETYPE|
> FINDNODETYPE_FINDALL,"Geode");
>
> copyA->accept(nv);
>
> std::vector<osg::Node*> nodeList = nv.getNodeList();
>
> int length = nodeList.size();
>
> now length is 3 (but at this level it should be 35).
>
> Judie
>
>
> On Apr 17, 8:04 am, "Serge Lages" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Just cast the clone() return to an osg::Node * and it should work :
> >
> > osg::ref_ptr<osg::Node> copyA = static_cast<osg::Node *>(A->clone(
> > osg::CopyOp::DEEP_COPY_ALL ));
> >
> >
> >
> >
> >
> > On Thu, Apr 17, 2008 at 4:54 PM, Judie <[EMAIL PROTECTED]>
> wrote:
> > > Hi Paul,
> >
> > > Does that work on your compiler? I tried that as well, but I got the
> > > following error:
> >
> > > error C2440: 'initializing' : cannot convert from 'class osg::Object
> > > *' to 'class osg::ref_ptr<class osg::Node>'
> > >        No constructor could take the source type, or constructor
> > > overload resolution was ambiguous
> >
> > > So then I tried using the parent of the node which is a group and
> > > create a group from that using the deep copy:
> >
> > > osg::Ref_Ptr<osg::Group> CopyAParent = new osg::Group(*AParent,
> > > osg::CopyOp::DEEP_COPY_ALL);
> >
> > > but it still doesn't have any nodes in the list:
> >
> > > osg::Node *test = m_CopyAParent ->getChild(0);
> > > findNodeVisitor nv1(FINDNODETYPE_NODETYPE|FINDNODETYPE_FINDALL,
> > > "Geode");
> > > test->accept(nv1);
> > > std::vector<osg::Node*> nodeList = nv1.getNodeList();
> > > int length = nodeList.size();
> >
> > > here length is 0.
> >
> > > Thanks,
> >
> > > Judie
> >
> > > On Apr 16, 6:47 pm, "Paul Martz" <[EMAIL PROTECTED]> wrote:
> > > > 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]://
> > > lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph...-Hide
> > > quoted text -
> >
> > > > - Show quoted text -
> > > _______________________________________________
> > > osg-users mailing list
> > > [EMAIL PROTECTED]
> > >http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> ..
> >
> > --
> > Serge Lageshttp://www.tharsis-software.com
> >
> > _______________________________________________
> > osg-users mailing list
> > [EMAIL PROTECTED]://
> lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph...- Hide
> quoted text -
> >
> > - Show quoted text -
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Serge Lages
http://www.tharsis-software.com
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to