void FltExportVisitor::apply( osg::LOD& lodNode ) { _firstNode = false; ScopedStatePushPop guard( this, lodNode.getStateSet() ); // LOD center - same for all children osg::Vec3d center = lodNode.getCenter(); // Iterate children of the LOD and write a separate LOD record for each, // with that child's individual switchIn and switchOut properties for ( size_t i = 0; i < lodNode.getNumChildren(); ++i ) { osg::Node* lodChild = lodNode.getChild(i); // Switch-in/switch-out distances may vary per child double switchInDist = lodNode.getMaxRange(i); double switchOutDist = lodNode.getMinRange(i); writeLevelOfDetail( lodNode, center, switchInDist, switchOutDist); writeMatrix( lodNode.getUserData() ); writeComment( lodNode ); // Traverse each child of the LOD writePushTraverseWritePop( *lodChild ); } }
static bool writeUserCenter( osgDB::OutputStream& os, const osg::LOD& node ) { os << osg::Vec3d(node.getCenter()) << (double)node.getRadius() << std::endl; return true; }
void daeWriter::apply( osg::LOD &node ) { debugPrint( node ); updateCurrentDaeNode(); lastDepth = _nodePath.size(); currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) ); currentNode->setId(getNodeName(node,"LOD").c_str()); if (writeExtras) { // Store LOD data as extra "LOD" data in the "OpenSceneGraph" technique // Adds the following to a node //<extra type="LOD"> // <technique profile="OpenSceneGraph"> // <Center>1 2 3</Center> (optional ) // <Radius>-1</Radius> (required if Center is available) // <RangeMode>0</RangeMode> // <RangeList> // <MinMax>0 300</MinMax> // <MinMax>300 600</MinMax> // </RangeList> // </technique> //</extra> domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA )); extra->setType("LOD"); domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) ); teq->setProfile( "OpenSceneGraph" ); if (node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER) { domAny *center = (domAny*)teq->add("Center"); center->setValue(toString(node.getCenter()).c_str()); domAny *radius = (domAny*)teq->add("Radius"); radius->setValue(toString<osg::LOD::value_type>(node.getRadius()).c_str()); } domAny *rangeMode = (domAny*)teq->add("RangeMode"); rangeMode->setValue(toString<osg::LOD::RangeMode>(node.getRangeMode()).c_str()); domAny *valueLists = (domAny*)teq->add("RangeList"); unsigned int pos = 0; const osg::LOD::RangeList& rangelist = node.getRangeList(); for(osg::LOD::RangeList::const_iterator sitr=rangelist.begin(); sitr!=rangelist.end(); ++sitr,++pos) { domAny *valueList = (domAny*)valueLists->add("MinMax"); std::stringstream fw; fw << sitr->first << " " << sitr->second; valueList->setValue(fw.str().c_str()); } } writeNodeExtra(node); // Process all children traverse( node ); }