osg::Node *pLoadedModel = osgDB::readNodeFile("Model.OBJ");
osg::Group *pGroup = dynamic_cast<osg::Group*>(pLoadedModel);
// check if null
sg::Geode *pGeode = dynamic_cast<osg::Geode*>(pGroup->getChild(1));
if (pGeode != NULL)
{
 std::cout << pGeode->getName() << std::endl;
}

I think this contains enough tips...

I am sure that OBJ reader returns an   osg::node  which is osg::group,
so you can even static cast...






2006/8/25, Jeff Kershner <[EMAIL PROTECTED]>:
Well it didn't work 10 min ago!  ;)

Thanks!

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mustafa
Sent: Friday, August 25, 2006 2:41 PM
To: osg users
Subject: Re: [osg-users] export to obj; do names persist?

This is working for me...


osg::Group *pLoadedModel;
...
osg::Geode *pGeode = dynamic_cast<osg::Geode*>(pLoadedModel->getChild(1));
if (pGeode != NULL)
{
   std::cout << pGeode->getName() << std::endl;
}




2006/8/25, Jeff Kershner <[EMAIL PROTECTED]>:
> That seems to work... thanks...
>
> One problem.  You say that each child of the returning osg::group node is
a
> geode.  Is that true?  I can't dynamic_cast an osg::Group->getChild(x) to
> anything but a Node.  How do I get that child to be a geode?
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mustafa
> Sent: Friday, August 25, 2006 2:15 PM
> To: osg users
> Subject: Re: [osg-users] export to obj; do names persist?
>
> after reading OBJ file, OBJ reader return value is osg::group...
>
> each group in the OBJ file will be a osg::geode as a child of the
> returning osg::group node.
>
> Each osg::geode will have the name of the OBJ group...
>
> you can get the group names  by accessing each child of the OSG::Group
> node ( i.e.  osg::group->getChild(1)->getName()  )
>
>
>
>
> 2006/8/25, Jeff Kershner <[EMAIL PROTECTED]>:
> >
> >
> >
> >
> > I am using MilkShape3D (no joke) to create my models.  I want to create
> > invisible physics proxy shapes and give them names.  Does anyone know if
> the
> > group names are kept when the models are exported to a wavefront *.obj
> file?
> >  I see that the group names are physically in the *.obj data file, but
> does
> > OSG keep those names when osgDB::readNodeFile is called?
> >
> >
> >
> > And if not, is there a better export file format that I should be using
> that
> > Milkshape3D has?
> >
> >
> >
> > Thanks,
> >
> > /jk
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://openscenegraph.net/mailman/listinfo/osg-users
> > http://www.openscenegraph.org/
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/



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

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

Reply via email to