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

Thrall, Bryan bryan.thrall at flightsafety.com
Thu Jul 31 07:31:45 PDT 2008


Franclin Foping wrote on Thursday, July 31, 2008 7:34 AM:
> Hi Alberto,
>  Indeed, that conversion is not possible. Do you know any other algorithms to
>  retrieve texture coordinates of nodes made of a loaded model? In your
>  previous post, you mention using indexes but assuming a Geometry node. The
>  problem here is that here there is no Geometry node so your previous advice
>  was not a huge boon. I thought that I could use a 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. Here is
> the situation. Waiting for your reply. F.   

If the Drawable's supports(AttributeFunctor&) returns true, you can write a subclass of AttributeFunctor to access the texture coordinates. ShapeDrawable's supports(ConstAttributeFunctor) returns true, so if you have ShapeDrawables you could use that.

Something like (untested):

class GetTextureCoords : public osg::Drawable::ConstAttributeFunctor
{
public:
    void apply(AttributeType type, unsigned int count, const GLbyte* coords)
    {
       if (type != TEXTURE_COORDS)
         return;
       // coords contains texture coordinates here
    }
    // ... other apply() functions ...
};

HTH

> Alberto Luaces <aluaces at udc.es> a écrit :
> 
> 	Hi Franclin,
> 
> 	El Jueves 31 Julio 2008ES 14:10:13 Franclin Foping escribió:
> 	> retrieve its Drawable objects, convert them to Geometry
> 
> 	As you have been told earlier, that conversion can only be done if the
> 	Drawable pointer really points to a Geometry object. Otherwise no conversion
> 	is made and you get a null pointer.
> 
> 	Alberto
-- 
Bryan Thrall
FlightSafety International
bryan.thrall at flightsafety.com



More information about the osg-users mailing list