00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 # include <simgear_config.h>
00024 #endif
00025
00026 #include "SGTextureStateAttributeVisitor.hxx"
00027
00028 SGTextureStateAttributeVisitor::SGTextureStateAttributeVisitor() :
00029 osg::NodeVisitor(osg::NodeVisitor::NODE_VISITOR,
00030 osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
00031 {
00032 }
00033
00034 void
00035 SGTextureStateAttributeVisitor::apply(int textureUnit, osg::StateSet::RefAttributePair& refAttr)
00036 {
00037 }
00038
00039 void
00040 SGTextureStateAttributeVisitor::apply(int textureUnit, osg::StateSet::AttributeList& attrList)
00041 {
00042 osg::StateSet::AttributeList::iterator i;
00043 i = attrList.begin();
00044 while (i != attrList.end()) {
00045 apply(textureUnit, i->second);
00046 ++i;
00047 }
00048 }
00049
00050 void
00051 SGTextureStateAttributeVisitor::apply(osg::StateSet::TextureAttributeList& attrList)
00052 {
00053 for (unsigned i = 0; i < attrList.size(); ++i)
00054 apply(i, attrList[i]);
00055 }
00056
00057 void
00058 SGTextureStateAttributeVisitor::apply(osg::StateSet* stateSet)
00059 {
00060 if (!stateSet)
00061 return;
00062 apply(stateSet->getTextureAttributeList());
00063 }
00064
00065 void
00066 SGTextureStateAttributeVisitor::apply(osg::Node& node)
00067 {
00068 apply(node.getStateSet());
00069 traverse(node);
00070 }
00071
00072 void
00073 SGTextureStateAttributeVisitor::apply(osg::Geode& node)
00074 {
00075 unsigned nDrawables = node.getNumDrawables();
00076 for (unsigned i = 0; i < nDrawables; ++i)
00077 apply(node.getDrawable(i)->getStateSet());
00078 apply(node.getStateSet());
00079 traverse(node);
00080 }