void GeodeFindVisitor::apply(osg::Node &searchNode) { if (!strcmp (searchNode.className(), "Geode")) { _foundGeodes.push_back((osg::Geode*) &searchNode); } traverse(searchNode); }
void InfoVisitor::apply(osg::Node& node) { std::cout << spaces() << node.libraryName() << "::" << node.className() << std::endl; ++_level; traverse(node); --_level; }
void OsgVisitorFirstGeode::apply( osg::Node& node ) { std::string class_name = node.className(); if (class_name == "Geode") found_geode = (osg::Geode *) &node; else traverse(node); }
virtual void apply(osg::Node& node) { for(int i=0;i<_indent;++i) std::cout<<" "; std::cout<<"["<<_indent+1<<"]"<<node.libraryName() <<"::"<<node.className()<<std::endl; _indent++; traverse(node); _indent--; }
void daeWriter::debugPrint(osg::Node &node) { #ifdef _DEBUG std::string indent = ""; for (unsigned int i = 0; i < _nodePath.size(); i++) { indent += " "; } OSG_INFO << indent << node.className() << std::endl; #endif }
virtual void apply(osg::Node& node) { std::cout << spaces() << node.libraryName() << "::" << node.className() << std::endl; level_++; traverse(node); level_--; }
void BuildQtTreeView::apply(osg::Node& node) { osg::Geode *geode = 0L; bool isGroup = false; QString nodeName; if(node.className()!="") nodeName = "[" + QString::fromStdString(node.className()) + "]"; if(node.getName()!="") nodeName += " " + QString::fromStdString(node.getName()); if (nodeName.isEmpty()) nodeName = QObject::tr("[<unknow_type>] <unnamed>"); TreeViewItem *item = new TreeViewItem(_parents.top()); item->setCheckState(0, Qt::Checked); item->setOsgNode(&node); item->setData(0, Qt::DisplayRole, nodeName); if (dynamic_cast<osg::PagedLOD*>(&node)) { item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/LOD.png")); _parents.push(item); isGroup = true; } else if (dynamic_cast<osg::LOD*>(&node)) { item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/LOD.png")); _parents.push(item); isGroup = true; } else if (dynamic_cast<osg::Group*>(&node)) { if (dynamic_cast<osg::MatrixTransform*>(&node)) item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Matrix.png")); else item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Group.png")); _parents.push(item); isGroup = true; } else if (dynamic_cast<osg::Billboard*>(&node)) { item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Billboard.png")); } else if ((geode = dynamic_cast<osg::Geode*>(&node))) { item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Geode.png")); for (unsigned int i=0; i<geode->getNumDrawables(); ++i) { osg::ref_ptr<osg::Drawable> drawable = geode->getDrawable(i); if (drawable.valid()) { TreeViewItem *subItem = new TreeViewItem(item); //item->setCheckState(0, Qt::Checked); //item->setOsgNode(&node); subItem->setOsgObject(drawable.get()); subItem->setData(0, Qt::DisplayRole, "Drawable"); } } } else { item->setData(0, Qt::DecorationRole, QIcon(":/icons/TreeView/Other.png")); } _maxTreeDepth = std::max<int>(_maxTreeDepth, _parents.size()); traverse(node); if (isGroup) { _parents.pop(); } }
void WriterNodeVisitor::apply3DSMatrixNode(osg::Node &node, const osg::Matrix * m, const char * const prefix) { // Note: Creating a mesh instance with no transform and then copying the matrix doesn't work (matrix seems to be a temporary/computed value) Lib3dsMeshInstanceNode * parent = _cur3dsNode; Lib3dsMeshInstanceNode * node3ds = NULL; if (m) { osg::Vec3 osgScl, osgPos; osg::Quat osgRot, osgSo; m->decompose(osgPos, osgRot, osgScl, osgSo); float pos[3]; float scl[3]; float rot[4]; copyOsgVectorToLib3dsVector(pos, osgPos); copyOsgVectorToLib3dsVector(scl, osgScl); copyOsgQuatToLib3dsQuat(rot, osgRot); node3ds = lib3ds_node_new_mesh_instance(NULL, getUniqueName(node.getName().empty() ? node.className() : node.getName(), true, prefix).c_str(), pos, scl, rot); } else { node3ds = lib3ds_node_new_mesh_instance(NULL, getUniqueName(node.getName().empty() ? node.className() : node.getName(), true, prefix).c_str(), NULL, NULL, NULL); } lib3ds_file_append_node(_file3ds, reinterpret_cast<Lib3dsNode*>(node3ds), reinterpret_cast<Lib3dsNode*>(parent)); _cur3dsNode = node3ds; }