ok, I understand...
but is there anyway to have a Geometry object from a osg::Node?

I am trying with this lines of code but I have no success because "no geode is 
found" is printed.

Code:

osg::Geode *geode = dynamic_cast<osg::Geode*>(_oggettoObj.get());
        if (geode)
        {
            std::cout << "number of drawables in geode is " << 
geode->getNumDrawables() << std::endl;
            
            for (unsigned int i = 0; i < geode->getNumDrawables(); i++)
            {
                std::cout << "inside cycle " << i << std::endl;

                osg::Geometry *geo = dynamic_cast<osg::Geometry 
*>(geode->getDrawable(i));
                if (!geo) continue;
                else std::cout << "geode has geometry "<< i << std::endl;
                
                osg::StateSet *stateset = geo->getStateSet();
                if (!stateset) continue;
                else std::cout << "geometry has stateset "<< i << std::endl;
                
                
                osg::StateAttribute *state = 
stateset->getAttribute(osg::StateAttribute::MATERIAL);
                if (state)
                {
                    osg::Material *mat = dynamic_cast<osg::Material *>(state);
                    std::cout << "material name is: " << mat->getName() << 
std::endl;

                }
                else std::cout << "no material state "<< i << std::endl;
                
                osg::ref_ptr<osgUtil::TangentSpaceGenerator> tsg = new 
osgUtil::TangentSpaceGenerator;
                tsg->generate(geo, 1);//tex unit for bump map
                geo->setVertexAttribArray(8, tsg->getTangentArray());
                geo->setVertexAttribArray(7, tsg->getBinormalArray());
                std::cout<< "binormals are: " << 
tsg->getBinormalArray()->getTotalDataSize() << std::endl;
                std::cout<< "tangents are: " << 
tsg->getTangentArray()->getTotalDataSize() << std::endl;

            }
            
        }
        else
            std::cout <<"no geode found" << std::endl;




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49196#49196





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to