Hi,
I would like to retrieve the texture and normal coordinates of a loaded model.
But not sure how to do it. My first attempt was to use a visitor to traverse
the node, retrieve its Drawable objects, convert them to Geometry and finally
extract texture coordinates but unfortunately, it doesn't work.
Here is a fully commented code snippet for your information.
class myVisitor : public osg::NodeVisitor
{
public:
myVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN){ }
void apply(osg::Geode& geode)
{
for (unsigned int i = 0; i < geode.getNumDrawables(); ++i)
{
osg::Drawable* draw = geode.getDrawable(i);
//At this level, everything is ok since the Draw pointer contains at least
one valid Drawable objects. If I use a TriangleFunctor, it will return all
triangles of that Drawable :)
// However I would like to get the texture coordinates as well.
// HERE IS THE ISSUE.
const osg::Geometry* geometryd = dynamic_cast<const osg::Geometry*>
(draw);
// geometryd is dangling !!!
if (geometryd)
const osg::Array* tc = geometryd->getTexCoordArray(0);
}
}
};
osg::Node* myNode = osgDB::readNodeFile("my3DModel.3ds");
myVisitor visit;
myNode->accept (visit);
//Rest of the program irrelevant for this post.
Hopefully, I have clarified the matter further and can expect some help from
you guys.
Kinds regards,
Franclin.
---------------------------------
Envoyé avec Yahoo! Mail.
Une boite mail plus intelligente. _______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org