Hi Jacob,

Also use  a conditional after a dynamic_cast<> otherwise you may well be
operating on a NULL pointer as this is what C++ will pass back to you when
the object isn't of the type you want.

To find the node you want it easiest to just write a custom NodeVisitor that
searches through the scene graph and at each Goede it encounters do what you
need to do.

Do a search through the examples to find places where NodeVisitor is
subclassed.  Look for ones that have an apply(osg::Geode& ) as this will be
very close to what you need.

Robert

On Fri, Apr 11, 2008 at 6:10 PM, Jacob Huckaby <[EMAIL PROTECTED]> wrote:

> Hi,
>
> Quick question (at least I hope it is.) I am trying to find the Drawable
> inside a Node that I read from a file, to which I can apply a custom
> TriangleIntersector. I have tried casting the Node as a Geode, and using
> getDrawable(), but it crashes on the getDrawable(). Here is the code I am
> trying:
>
>     osg::Geode* geode = dynamic_cast<osg::Geode*> (node);
>     osg::Drawable* drawable = geode->getDrawable(0);
>     drawable->accept(ti);
>
> I have been able to make this work with Shapes that I have put into
> ShapeDrawables:
>
>     osg::Box* box = new
> osg::Box(osg::Vec3(1.0f,1.0f,1.0f),1.0f,1.0f,1.0f);
>     osg::ShapeDrawable* drawable = new osg::ShapeDrawable(box);
>     drawable->accept(ti);
>
> My question: how can I get access to the Drawable in my Node (so that I
> can apply my TriangleIntersector)? It is only a single node. If you have any
> advice, I would greatly appreciate it. Thank you,
>
> Jake
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to