Changeset 11992 for OpenSceneGraph/trunk/examples/osgterrain/osgterrain.cpp
- Timestamp:
- 12/09/10 13:16:11 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgterrain/osgterrain.cpp
r11306 r11992 191 191 192 192 // load the nodes from the commandline arguments. 193 osg:: Node*rootnode = osgDB::readNodeFiles(arguments);193 osg::ref_ptr<osg::Node> rootnode = osgDB::readNodeFiles(arguments); 194 194 195 195 if (!rootnode) … … 199 199 } 200 200 201 osg Terrain::Terrain*terrain = findTopMostNodeOfType<osgTerrain::Terrain>(rootnode);201 osg::ref_ptr<osgTerrain::Terrain> terrain = findTopMostNodeOfType<osgTerrain::Terrain>(rootnode); 202 202 if (!terrain) 203 203 { 204 // no Terrain node present insert one above the loaded model. 204 205 terrain = new osgTerrain::Terrain; 205 terrain->addChild(rootnode); 206 207 rootnode = terrain; 206 207 // if CoordinateSystemNode is present copy it's contents into the Terrain, and discard it. 208 osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode);; 209 if (csn) 210 { 211 terrain->set(*csn); 212 for(unsigned int i=0; i<csn->getNumChildren();++i) 213 { 214 terrain->addChild(csn->getChild(i)); 215 } 216 } 217 else 218 { 219 terrain->addChild(rootnode.get()); 220 } 221 222 rootnode = terrain.get(); 208 223 } 209 224 … … 216 231 217 232 // add a viewport to the viewer and attach the scene graph. 218 viewer.setSceneData( rootnode );233 viewer.setSceneData( rootnode.get() ); 219 234 220 235
