void SimpleDotVisitor::handle(osg::Group &node, int id) { std::stringstream label; label << "<top> " << node.className(); if (!node.getName().empty()) { label << "| " << node.getName(); } drawNode(id, "record", "solid", label.str(), "black", "white"); }
/** Attacca al/ai nodi che corrispondono a nodeName */ void LoadThreadsHandler::AttachNodeToSceneByName::apply(osg::Group& grp) { if (grp.getName() == _nodeName) { if(!_attached || _multipleattach) { if(_ranged) { osg::ref_ptr<osg::LOD> newlod = new osg::LOD; newlod->setName("RangedLOD_" + _attachNode->getName()); newlod->addChild(_attachNode.get(), _min, _max); grp.addChild(newlod.get()); } else { grp.addChild(_attachNode.get()); } _attached = true; } } traverse(grp); }
void FltExportVisitor::writeObject(const osg::Group &group, osgSim::ObjectRecordData *ord) { uint16 length(28); IdHelper id(*this, group.getName()); if (!ord) { std::string warning("fltexp: writeObject has invalid ObjectRecordData."); OSG_WARN << warning << std::endl; _fltOpt->getWriteResult().warn(warning); return; } _records->writeInt16((int16) OBJECT_OP); _records->writeInt16(length); _records->writeID(id); _records->writeInt32(ord->_flags); _records->writeInt16(ord->_relativePriority); _records->writeUInt16(ord->_transparency); _records->writeUInt16(ord->_effectID1); _records->writeUInt16(ord->_effectID2); _records->writeUInt16(ord->_significance); _records->writeUInt16(0); // reserved }
void FltExportVisitor::writeGroup(const osg::Group &group, int32 flags, int32 loopCount, float32 loopDuration, float32 lastFrameDuration) // <-- placeholder: ignored { int16 length(44); IdHelper id(*this, group.getName()); _records->writeInt16((int16) GROUP_OP); _records->writeInt16(length); _records->writeID(id); _records->writeInt16(0); // Relative priority _records->writeInt16(0); // Reserved _records->writeUInt32(flags); _records->writeInt16(0); // Special effect ID1 _records->writeInt16(0); // Special effect ID2 _records->writeInt16(0); // Significance _records->writeInt8(0); // Layer code _records->writeInt8(0); // Reserved _records->writeInt32(0); // Reserved _records->writeInt32(loopCount); _records->writeFloat32(loopDuration); _records->writeFloat32(lastFrameDuration); }
void FindByNameVisitor::apply(osg::Group &group) { if (Misc::StringUtils::ciEqual(group.getName(), mNameToFind)) { mFoundNode = &group; return; } traverse(group); }
void TileMapper::apply(osg::Group& node) { if (node.getName()=="TileContent") { _containsGeode = true; return; } if (isCulled(node)) return; // push the culling mode. pushCurrentMask(); TileIdentifier* tid = dynamic_cast<TileIdentifier*>(node.getUserData()); if (tid) { _containsGeode = false; } traverse(node); if (tid) { if (_containsGeode) { insertTile(*tid); _containsGeode = false; } } // pop the culling mode. popCurrentMask(); }
void TileMapper::apply(osg::Group& node) { if (node.getName()=="TileContent") { _containsGeode = true; return; } if (isCulled(node)) return; // push the culling mode. pushCurrentMask(); TileIdentifier* tid = dynamic_cast<TileIdentifier*>(node.getUserData()); if (tid) { _tileStack.push_back(TileStack::value_type(*tid,&node)); _containsGeode = false; } traverse(node); if (tid) { if (_containsGeode) { insertTile(*tid); _containsGeode = false; #if 0 std::cout<<"found Group="<<tid->lod <<" X="<<tid->x <<" Y="<<tid->y <<" ptr="<<&node<<std::endl; std::cout<<" inheritance list "<<_tileStack.size()<<std::endl; for(TileStack::iterator itr=_tileStack.begin(); itr!=_tileStack.end(); ++itr) { std::cout<<" LOD="<<itr->first.lod <<" X="<<itr->first.x <<" Y="<<itr->first.y <<" className="<<itr->second->className() <<" ptr="<<itr->second<<std::endl; } osg::StateSet* stateset = node.getOrCreateStateSet(); osg::Material* material = new osg::Material; material->setColorMode(osg::Material::OFF); stateset->setAttribute(material); switch(tid->lod) { case(0): material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); break; case(1): material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,0.0f,0.0f,1.0f)); break; case(2): material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,1.0f,0.0f,1.0f)); break; case(3): material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(0.0f,0.0f,1.0f,1.0f)); break; case(4): material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,0.0f,1.0f,1.0f)); break; } #endif } _tileStack.pop_back(); } // pop the culling mode. popCurrentMask(); }
void AddQueries::apply( osg::Group& node ) { if( node.getName() == std::string( "__QueryStats" ) ) // This is the QueryStats subtree. Don't instrument it with any OQ stuff. return; if( node.getCullCallback() != NULL ) { traverse( node ); return; } // Do not add callbacks to redundant Groups because the parent Group's // bounding volume (and query geometry) would also be redundant. // This Group is not redundant if it has no parents, or if its parents // are all Cameras, or if any one of its non-Camera parents has // more than one child. Otherwise, it's redundant. bool redundantGroup( false ); unsigned int parentsWithOneChild( 0 ); const unsigned int numParents( node.getNumParents() ); unsigned int idx; for( idx=0; idx < numParents; idx++ ) { osg::Group* parent = node.getParent( idx ); bool parentIsCamera = ( dynamic_cast< osg::Camera* >( parent ) != NULL ); if( parentIsCamera ) continue; if( parent->getNumChildren() == 1 ) { parentsWithOneChild++; // If all parents have one child, then we are redundant. if( numParents == parentsWithOneChild ) redundantGroup = true; } } if( redundantGroup ) { if( ( _qs != NULL ) && ( &node == _qs->getNode() ) ) osg::notify( osg::ALWAYS ) << "Debug: Unable to add QueryStats to redundant Group \"" << node.getName() << "\"." << std::endl; traverse( node ); return; } // Create QueryComputation for this node. // Add a QueryStats only if a) we have one and // b) the node addresses match. osgwQuery::QueryStats* debugStats( NULL ); if( ( _qs != NULL ) && ( &node == _qs->getNode() ) ) { osg::notify( osg::ALWAYS ) << "Debug: Adding QueryStats to node \"" << node.getName() << "\"." << std::endl; debugStats = _qs; } QueryComputation* nd = new QueryComputation( debugStats ); QueryCullCallback* qcc = new QueryCullCallback(); qcc->setName( node.getName() ); qcc->attach( &node, nd ); node.setCullCallback( qcc ); _queryCount++; traverse( node ); }