Changeset 6296
- Timestamp:
- 03/01/07 13:10:52
- Files:
-
- OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp (modified) (1 diff)
- OpenSceneGraph/trunk/src/osgPlugins/txp/TXPArchive.cpp (modified) (2 diffs)
- OpenSceneGraph/trunk/src/osgPlugins/txp/TXPArchive.h (modified) (5 diffs)
- OpenSceneGraph/trunk/src/osgPlugins/txp/TXPParser.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp
r6291 r6296 55 55 if (archive) 56 56 { 57 if (options && options->getOptionString().find("loadMaterialsToStateSet")!=std::string::npos) 58 { 59 archive->SetMaterialAttributesToStateSetVar(true); 60 } 61 57 62 int id = _archiveId++; 58 63 archive->setId(id); OpenSceneGraph/trunk/src/osgPlugins/txp/TXPArchive.cpp
r6291 r6296 70 70 _majorVersion(-1), 71 71 _minorVersion(-1), 72 _isMaster(false) 72 _isMaster(false), 73 _loadMaterialsToStateSet(false) 73 74 { 74 75 } … … 195 196 osg_state_set->setAttributeAndModes(osg_material, osg::StateAttribute::ON); 196 197 198 SetUserDataToMaterialAttributes(*osg_state_set, *mat); 199 197 200 if( alpha < 1.0f ) 198 201 { OpenSceneGraph/trunk/src/osgPlugins/txp/TXPArchive.h
r6291 r6296 37 37 #include "trpage_sys.h" 38 38 #include "trpage_read.h" 39 #include "trpage_geom.h" 39 40 40 41 #include <osg/Referenced> … … 44 45 #include <osg/Node> 45 46 #include <osg/PagedLOD> 47 #include <osg/Array> 46 48 #include <osgSim/LightPointNode> 47 49 #include <osgText/Font> … … 167 169 return GetTexMapEntry(id).get(); 168 170 } 169 171 170 172 // Returns scenegraph representing the Tile. 171 173 // For version 2.1 and over this function can only be call … … 199 201 minorVer = _minorVersion; 200 202 } 201 203 204 ////////////////////////////////////////////////////////////////// 205 // This section brought to you by A. Danklefsen and the team @ 206 // Alion Science And Technology 2/12/07 207 // 208 // This will allow you to have smc / fid / swc / stp values and 209 // places them on the userdata of the state set. this way your own 210 // terrain loader / parser can know these values 211 void SetUserDataToMaterialAttributes(osg::StateSet& osg_state_set, const trpgMaterial& mat) 212 { 213 if(!_loadMaterialsToStateSet) 214 return; 215 216 int attr_values = 0; 217 osg::ref_ptr<osg::IntArray> ourValueArray = new osg::IntArray(); 218 for(int attrIter = 0 ; attrIter < 4; ++attrIter) 219 { 220 mat.GetAttr(attrIter, attr_values); 221 ourValueArray->push_back(attr_values); 222 } 223 osg_state_set.setUserData(ourValueArray.get()); 224 } 225 226 void SetMaterialAttributesToStateSetVar(bool value) {_loadMaterialsToStateSet = value;} 227 202 228 protected: 203 229 … … 253 279 254 280 bool _isMaster; 255 281 282 bool _loadMaterialsToStateSet; 283 256 284 }; 257 285 OpenSceneGraph/trunk/src/osgPlugins/txp/TXPParser.cpp
r6291 r6296 491 491 osg_material->setAlpha(osg::Material::FRONT_AND_BACK ,(float)alpha); 492 492 osg_state_set->setAttributeAndModes(osg_material, osg::StateAttribute::ON); 493 493 494 _archive->SetUserDataToMaterialAttributes(*osg_state_set, *mat); 495 494 496 if( alpha < 1.0f ) 495 497 { … … 1458 1460 tmp_ss = (*_parse->getMaterials())[matId]; 1459 1461 } 1460 if( (sset!=0L) &&sset.valid())1462 if(sset.valid()) 1461 1463 { 1462 1464 if(tmp_ss.valid()) 1463 {1465 { 1464 1466 osg::StateAttribute* texenv0 = tmp_ss->getTextureAttribute(0,osg::StateAttribute::TEXENV); 1465 1467 if(texenv0) … … 1468 1470 if(tex0) 1469 1471 sset->setTextureAttributeAndModes(n_mat,tex0,osg::StateAttribute::ON); 1472 // submitted by a. danklefsen 1473 // Alion science and Technology 2/12/07 1474 // copy fid/smc codes over to this new state set from the prev state set. 1475 sset->setUserData(tmp_ss->getUserData()); 1470 1476 } 1471 1477 // sset->merge(*tmp_ss.get()); … … 1602 1608 else 1603 1609 { 1604 osg::notify(osg::WARN)<<"Detected potential memory leak in TXPPar erse.cpp"<<std::endl;1610 osg::notify(osg::WARN)<<"Detected potential memory leak in TXPParser.cpp"<<std::endl; 1605 1611 } 1606 1612
