From 0b778533c83392541fec6c94d48f5ccd8061b9c8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 6 Sep 2012 13:53:58 +0000 Subject: [PATCH] From Piotr Domagalski, "I've added reading of node names ('DEF' element) to the VRML reading plugin. The changes were based on trunk's version of the plugin." --- src/osgPlugins/vrml/ReaderWriterVRML2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp index 84d16b69c..c2acc73bc 100644 --- a/src/osgPlugins/vrml/ReaderWriterVRML2.cpp +++ b/src/osgPlugins/vrml/ReaderWriterVRML2.cpp @@ -255,6 +255,9 @@ osg::Node* ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) const osg::ref_ptr osg_group = new osg::Group; + if (!obj->id().empty()) + osg_group->setName(obj->id()); + try { std::auto_ptr fv = obj->field("children"); @@ -290,6 +293,9 @@ osg::Node* ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) const openvrml::mat4f vrml_m = vrml_transform->transform(); osg::ref_ptr osg_m = new osg::MatrixTransform(osg::Matrix(vrml_m[0][0], vrml_m[0][1], vrml_m[0][2], vrml_m[0][3], vrml_m[1][0], vrml_m[1][1], vrml_m[1][2], vrml_m[1][3], vrml_m[2][0], vrml_m[2][1], vrml_m[2][2], vrml_m[2][3], vrml_m[3][0], vrml_m[3][1], vrml_m[3][2], vrml_m[3][3])); + if (!obj->id().empty()) + osg_m->setName(obj->id()); + try { std::auto_ptr fv = obj->field("children"); @@ -354,11 +360,16 @@ osg::Node* ReaderWriterVRML2::convertFromVRML(openvrml::node *obj) const { // other geometry types not handled yet } + + if (osg_geom.valid() && !node_ptr->id().empty()) + osg_geom->setName(node_ptr->id()); } } } osg::ref_ptr osg_geode = new osg::Geode(); + if (!obj->id().empty()) + osg_geode->setName(obj->id()); osg_geode->addDrawable(osg_geom.get()); osg::StateSet *osg_stateset = osg_geode->getOrCreateStateSet();