You can use visitor for that purpose:
class TSVisitor: public osg::NodeVisitor {
public:
TSVisitor(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{}
void apply(osg::Geode& geode)
{
for (unsigned i=0; i<geode.getNumDrawables(); ++i) {
osg::Geometry* geo = dynamic_cast<osg::Geometry*
>(geode.getDrawable(i));
if (geo) {
osg::ref_ptr<osgUtil::TangentSpaceGenerator> tsg = new
osgUtil::TangentSpaceGenerator;
tsg->generate(geo, 0);//tex unit for bump map
//set resulting arrays to geometry here with
setVertexAttribArray(...)
}
}
osg::NodeVisitor::apply(geode);
}
};
TSVisitor tsv;
_oggettoObj->accept(tsv)
Cheers.
07.08.2012, 17:32, "John Moore" <[email protected]>:
> Hi Sergey,
> I am looking to TangentSpaceGenerator and I need to pass a Geometry to the
> generate method. However I have a osg::Node data structure because I load
> data using obj reader.
>
> Code:
> _oggettoObj = osgDB::readNodeFile("provaBump/objconbump.obj");
>
> then I create a tangent space with these lines:
>
> Code:
>
> osg::ref_ptr<osgUtil::TangentSpaceGenerator> tangentSpace = new
> osgUtil::TangentSpaceGenerator;
> tangentSpace->generate(objectNode->asGeode()->getDrawable(0)->asGeometry());
>
> but the application is crashing with a BAD_ACCESS exception at the moment
> when getDrawable is called.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=49191#49191
>
> _______________________________________________
> 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