[osg-users] Getting a list of all textures (including the ones used by particle systems) in a scenegraph
Harash Sharma
harashsharma at yahoo.com
Mon Jun 2 06:27:25 PDT 2008
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080602/3740dadf/attachment-0001.htm>
More information about the osg-users
mailing list