#include <OSGMakeTransparentGraphOp.h>
Inheritance diagram for osg::MakeTransparentGraphOp:

Public Member Functions | |
| MakeTransparentGraphOp (const char *name="MakeTransparent") | |
| GraphOp * | create () |
| bool | traverse (NodePtr &node) |
| void | setParams (const std::string params) |
| std::string | usage (void) |
Static Public Member Functions | |
| static const char * | getClassname (void) |
Protected Attributes | |
| std::list< NodePtr > | _excludeListNodes |
| std::list< std::string > | _excludeListNames |
Private Types | |
| typedef std::list< MaterialObject > | MaterialObjectList |
| typedef std::map< MaterialPtr, MaterialObjectList > | MaterialObjectMap |
Private Member Functions | |
| Action::ResultE | traverseEnter (NodePtr &node) |
| Action::ResultE | traverseLeave (NodePtr &node, Action::ResultE res) |
| void | addObject (MaterialObject m) |
| void | applyTransparency (MaterialPtr m) |
Private Attributes | |
| MaterialObjectMap | _materialObjects |
| Real32 | _transparency |
Classes | |
| class | MaterialObject |
Definition at line 59 of file OSGMakeTransparentGraphOp.h.
|
|
Definition at line 122 of file OSGMakeTransparentGraphOp.h. |
|
|
Definition at line 123 of file OSGMakeTransparentGraphOp.h. |
|
|
Definition at line 47 of file OSGMakeTransparentGraphOp.cpp. Referenced by create(). 00048 : GraphOp(name), 00049 _transparency(0.5) 00050 { 00051 }
|
|
|
Reimplemented from osg::GraphOp. Definition at line 103 of file OSGMakeTransparentGraphOp.h.
|
|
|
Implements osg::GraphOp. Definition at line 53 of file OSGMakeTransparentGraphOp.cpp. References MakeTransparentGraphOp(). 00054 { 00055 return new MakeTransparentGraphOp(); 00056 }
|
|
|
Reimplemented from osg::GraphOp. Definition at line 68 of file OSGMakeTransparentGraphOp.cpp. References _materialObjects, applyTransparency(), osg::AttachmentContainerPtr::dcast(), osg::deepClone(), osg::NullFC, and osg::GraphOp::traverse(). 00069 { 00070 // Find the materials. 00071 if (!GraphOp::traverse(node)) { 00072 return false; 00073 } 00074 00075 // Now do the merge. 00076 MaterialObjectMap::iterator itr = _materialObjects.begin(); 00077 for (; itr != _materialObjects.end(); ++itr) 00078 { 00079 MaterialPtr oldMaterial = itr->first; 00080 MaterialPtr newMaterial = MaterialPtr::dcast(deepClone(oldMaterial)); 00081 if (newMaterial != NullFC) 00082 { 00083 std::cout << "Applying transparency: "; 00084 00085 applyTransparency(newMaterial); 00086 00087 // Put the new material in the objects in this subtree. 00088 MaterialObjectList& currentList = itr->second; 00089 MaterialObjectList::iterator i = currentList.begin(); 00090 for (; i != currentList.end(); ++i) 00091 { 00092 i->setMaterial(newMaterial); 00093 } 00094 } 00095 } 00096 00097 return true; 00098 }
|
|
|
Implements osg::GraphOp. Definition at line 101 of file OSGMakeTransparentGraphOp.cpp. References _transparency, and FWARNING. 00102 { 00103 ParamSet ps(params); 00104 00105 ps("transparency", _transparency); 00106 00107 std::string out = ps.getUnusedParams(); 00108 if(out.length()) 00109 { 00110 FWARNING(("MakeTransparentGraphOp doesn't have parameters '%s'.\n", 00111 out.c_str())); 00112 } 00113 }
|
|
|
Implements osg::GraphOp. Definition at line 115 of file OSGMakeTransparentGraphOp.cpp. 00116 { 00117 return 00118 "MakeTransparent: make used Materials transparent\n" 00119 " Based on MaterialMergeGraphOp, merges Materials and sets their\n" 00120 " transparency.\n" 00121 "Params: name (type, default)\n" 00122 " transparency (Real32, 0.5f): transparency value\n"; 00123 }
|
|
|
Implements osg::GraphOp. Definition at line 125 of file OSGMakeTransparentGraphOp.cpp. References addObject(), osg::Action::Continue, osg::AttachmentContainerPtr::dcast(), osg::NodePtr::getCore(), and osg::NullFC. 00126 { 00127 GeometryPtr geo = GeometryPtr::dcast(node->getCore()); 00128 if (geo != NullFC) 00129 { 00130 addObject(MaterialObject(geo)); 00131 return Action::Continue; 00132 } 00133 00134 MaterialGroupPtr mg = MaterialGroupPtr::dcast(node->getCore()); 00135 if (mg != NullFC) 00136 { 00137 addObject(MaterialObject(mg)); 00138 return Action::Continue; 00139 } 00140 00141 // Otherwise, keep looking. 00142 return Action::Continue; 00143 }
|
|
||||||||||||
|
Implements osg::GraphOp. Definition at line 145 of file OSGMakeTransparentGraphOp.cpp.
|
|
|
Definition at line 150 of file OSGMakeTransparentGraphOp.cpp. References _materialObjects, osg::MakeTransparentGraphOp::MaterialObject::getMaterial(), and osg::NullFC. Referenced by traverseEnter(). 00151 { 00152 MaterialPtr mat = m.getMaterial(); 00153 if (mat == NullFC) 00154 return; 00155 00156 _materialObjects[mat].push_back(m); 00157 }
|
|
|
Definition at line 183 of file OSGMakeTransparentGraphOp.cpp. References _transparency, osg::beginEditCP(), osg::AttachmentContainerPtr::dcast(), osg::endEditCP(), and osg::NullFC. Referenced by traverse(). 00183 { 00184 00185 SimpleMaterialPtr sm = SimpleMaterialPtr::dcast(m); 00186 if (sm != NullFC) { 00187 std::cout << "SimpleMaterial" << std::endl; 00188 beginEditCP(sm); 00189 sm->setTransparency(1.0f - (1.0f - sm->getTransparency()) * 00190 _transparency); 00191 sm->setColorMaterial(GL_NONE); 00192 endEditCP(sm); 00193 00194 PolygonChunkPtr polygonChunk = getOrAddChunk<PolygonChunk>(sm); 00195 beginEditCP(polygonChunk); 00196 polygonChunk->setCullFace(GL_BACK); 00197 endEditCP(polygonChunk); 00198 return; 00199 } 00200 00201 ChunkMaterialPtr cm = ChunkMaterialPtr::dcast(m); 00202 if (cm != NullFC) { 00203 std::cout << "ChunkMaterial" << std::endl; 00204 BlendChunkPtr blendChunk = getOrAddChunk<BlendChunk>(cm); 00205 beginEditCP(blendChunk); 00206 blendChunk->setColor(Color4f(1, 1, 1, _transparency)); 00207 blendChunk->setSrcFactor(GL_SRC_ALPHA); 00208 blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA); 00209 endEditCP(blendChunk); 00210 return; 00211 } 00212 }
|
|
|
Definition at line 112 of file OSGGraphOp.cpp. References osg::GraphOp::_name. Referenced by osg::GraphOpFactory::registerOp(), and osg::GraphOpFactory::unRegisterOp(). 00113 { 00114 return _name; 00115 };
|
|
|
Definition at line 117 of file OSGGraphOp.cpp. References osg::GraphOp::_name. 00118 { 00119 _name = name; 00120 };
|
|
|
Definition at line 124 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNodes, and osg::GraphOp::isInExcludeListNodes(). Referenced by osg::MergeGraphOp::excludeListLeave(), and osg::GraphOpSeq::setGraphOps(). 00125 { 00126 if (!isInExcludeListNodes(node)) 00127 _excludeListNodes.push_back(node); 00128 }
|
|
|
Definition at line 130 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNames, and osg::GraphOp::isInExcludeListNames(). 00131 { 00132 if (!isInExcludeListNames(name)) 00133 _excludeListNames.push_back(name); 00134 }
|
|
|
Definition at line 136 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNodes. 00137 { 00138 _excludeListNodes.remove(node); 00139 }
|
|
|
Definition at line 141 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNames. 00142 { 00143 _excludeListNames.remove(name); 00144 }
|
|
|
Definition at line 146 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNames, and osg::GraphOp::_excludeListNodes. 00147 { 00148 _excludeListNames.clear(); 00149 _excludeListNodes.clear(); 00150 }
|
|
|
Definition at line 152 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNodes. Referenced by osg::GraphOp::addToExcludeList(), and osg::GraphOp::isInExcludeList(). 00153 { 00154 std::list<NodePtr>::iterator list_iter; 00155 list_iter = std::find(_excludeListNodes.begin(),_excludeListNodes.end(),node); 00156 00157 if (list_iter==_excludeListNodes.end()) 00158 return false; 00159 else 00160 return true; 00161 }
|
|
|
Definition at line 163 of file OSGGraphOp.cpp. References osg::GraphOp::_excludeListNames. Referenced by osg::GraphOp::addToExcludeList(), and osg::GraphOp::isInExcludeList(). 00164 { 00165 std::list<std::string>::iterator namelist_iter; 00166 namelist_iter = std::find(_excludeListNames.begin(),_excludeListNames.end(),name); 00167 00168 if (namelist_iter==_excludeListNames.end()) 00169 return false; 00170 else 00171 return true; 00172 }
|
|
|
Definition at line 174 of file OSGGraphOp.cpp. References osg::getName(), osg::GraphOp::isInExcludeListNames(), and osg::GraphOp::isInExcludeListNodes(). Referenced by osg::MergeGraphOp::processGeometries(), osg::MergeGraphOp::processGroups(), osg::MergeGraphOp::processTransformations(), osg::SplitGraphOp::splitNode(), and osg::SplitGraphOp::traverseLeave(). 00175 { 00176 if (isInExcludeListNodes(node) || (OSG::getName(node)!=NULL && isInExcludeListNames(OSG::getName(node)))) 00177 return true; 00178 else 00179 return false; 00180 }
|
|
|
Definition at line 125 of file OSGMakeTransparentGraphOp.h. Referenced by addObject(), and traverse(). |
|
|
Definition at line 127 of file OSGMakeTransparentGraphOp.h. Referenced by applyTransparency(), and setParams(). |
|
|
Definition at line 161 of file OSGGraphOp.h. Referenced by osg::GraphOp::addToExcludeList(), osg::GraphOp::clearExcludeList(), osg::GraphOp::isInExcludeListNodes(), osg::MergeGraphOp::mergeOnce(), and osg::GraphOp::removeFromExcludeList(). |
|
|
Definition at line 162 of file OSGGraphOp.h. Referenced by osg::GraphOp::addToExcludeList(), osg::GraphOp::clearExcludeList(), osg::GraphOp::isInExcludeListNames(), and osg::GraphOp::removeFromExcludeList(). |
1.4.3