Hi all,
   I have a requirement to build a list of all textures used in a scene graph. 
For this purpose, I have used a NodeVisitor derived class with the apply 
function given below. 
Problem:  I am not able to get the details of textures used by the attached 
Particle systems. I would be very grateful if someone can help with some hints 
/ pointers.
Regards 
Harash 
Apply Function:
----------------void
{ 
    osg::Node* Ptr = &searchNode; 
    osg::StateSet* state = Ptr->getStateSet(); 
FindTextureVisitor::apply(osg::Node &searchNode) // get the state set for the 
node    osg::StateSet::TextureAttributeList Attr; //         Attr = 
state->getTextureAttributeList();     if(state != NULL) {        intSz = 
Attr.size();        // for all the attributes, find the ones related to 
texture            osg::ref_ptr<osg::Texture> texture = 
                                                                    
(j,osg::StateAttribute::TEXTURE));        // if a texture is found            
{            if(texture.valid())                // This is a valuable node 
containing texture                foundNodeList.push_back(&searchNode);         
       // also store the Texture object related to this node so we              
   // don't have to repeat the call to get Texture attribute List               
 foundTextureList.push_back(texture);                // Now search if the 
texture has already been used by an earlier node                // get the 
image related to the texture                osg::ref_ptr<osg::Image> texImage = 
texture->getImage(0);                // check if it is already in the list      
  
         std::string filename = texImage->getFileName();                
intTexSz = foundImageList.size(); // TextureList.size();                        
flag = 
                    }
                }                boolflag = true;                for(intk = 0; 
k < TexSz; k++) {                    if(foundImageList[k]->getFileName() == 
filename) {false;                        break;                if(flag) {       
             // No it is not on the List                    
foundImageList.push_back(texImage);
                }
            }
        }
    }
    traverse(searchNode); 
}                 // add it to the node list        for(intj = 0; j< Sz; j++) 
{dynamic_cast<osg::Texture*>(state->getTextureAttribute        


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

Reply via email to