[osg-users] RE : Re: Getting texture coordinates of loadedmodels

Gordon Tomlinson gordon.tomlinson at sensor.com
Thu Jul 31 07:06:45 PDT 2008


Once again the ShapeDrawbles confuse the issue 

1) YOU CANNOT do what you want with ShapeDrawables END of story 

1) DON’T USE ShapeDrawable they are there as an aid to some geometric
operations  and not designed FOR Rendering use ( Robert has said many times
he regrets the dang things)

2) Shape drawables DO NOT override the base class virtual functions
osg::DrawAble::asGeometry so will ALWAYS return NULL

3) Normal Geometry is created similar to this
osg::Node->osg::Geode->osg::Geometry[has](Verts,Text coords, Normals etc)
And osg::Geometry does override osg::DrawAble::asGeometry thus will return
correctly

SO you can then do some along the lines of:

So you travesre the osg::Node ( what ever type is maybe) retrieve each Geode

For each Geode retrieve one or more Drawables osg::Geode::getDrawable( int i
)

For each Drawable retrieve on or more Geometry pointers ( with a cast )

>From each Geoemtry node retrieve the require geoemtry arrays/info required


But to be clear you CANNOT do this with ShapeDrawables it is not an instance
of osg::Geometry


-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Alberto
Luaces
Sent: Thursday, July 31, 2008 9:45 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] RE : Re: Getting texture coordinates of
loadedmodels

Franclin,

El Jueves 31 Julio 2008ES 14:33:30 Franclin Foping escribió:
>  visitorto retrieve its Drawable objects, turn them into Geometry 
> objects and use your trick but I was wrong as it is impossible to 
> convert from Drawable to Geometry.

You still don't get it. You are not converting one type to another, but the
pointers that reference those objects. This is only possible if the object
pointed is really of the type you are requesting. I have been doing this a
zillion times until now, provided that I know beforehand that my meshes are
stored as Geometry(s).

As you have been recommended, it's important that you know how polymorphism
works in C++ and the rest of OO languages. Then you will understand why you
can't magically convert one object of one class to another.

As for the retrieval of the UV coordinates of a ShapeDrawable, they are
hard-wired directly into the code, so I'm afraid you'll have to read OSG
code to find how they are calculated (ShapeDrawable.cpp). The good news is
that you won't have to do this work at runtime anymore :)

Alberto
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





More information about the osg-users mailing list