Merge geodes into a single node

34 views
Skip to first unread message

Luca Costantino

unread,
Oct 19, 2020, 10:36:03 AM10/19/20
to OpenSceneGraph Users
Hi All

I have two basic osg shapes that I load like this

osg::ref_ptr<osg::Node> shape1 = osgDB::readNodeFile("shape1.osg");
osg::ref_ptr<osg::Node> shape2 = osgDB::readNodeFile("shape2.osg"); 

I then group them together and save them
osg::ref_ptr<osg::Group> total = new osg::Group;
total->addChild(shape1.get());
total->addChild(shape2.get());
osgDB::writeNodeFile(*total, "ouput.fbx");

The output fbx files contains two geodes... How can I merge them into a single one?

I tried with
osg::ref_ptr<osg::Node> singleNode = new osg::Node;
singleNode = dynamic_cast<osg::Node*>(total.get());

But the output doesn't change...

Thanks to anyone that will help :)

Regards
Luca

OpenSceneGraph Users

unread,
Oct 19, 2020, 10:59:20 AM10/19/20
to osg-...@lists.openscenegraph.org
Hi, Luca. One cannot do this in a general way since under each node any kind of
entities can exist.

I think the task you want to do not possible in a generic way, unless
you get down to the level of the specific drawables each node has and
copy/transfer their contents (for example, if they are osg::Geodes, you
might do that with their drawables).

--
Alberto

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

chris

unread,
Oct 19, 2020, 2:40:58 PM10/19/20
to osg-...@googlegroups.com

Hi,

 

There should be some combination of options for the optimiser stuff in osgUtil that will let you merge geometries. This isn’t always possible (for example, if two nodes need wildly different renderer state, then there’s no way to merge them without the state being wrong when one is drawn) but if your models are fairly similar, it shouldn’t be a problem when you find the right settings.

 

By the way, it’s probably not the best idea to still be using geodes with modern OSG versions. osg::Drawable inherits osg::Node now, so you can put drawables directly into the scene graph like any other node.

 

Good luck,

 

Chris

--

You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/mailman.22744.1603119549.3538.osg-users-openscenegraph.org%40lists.openscenegraph.org.

 

Reply all
Reply to author
Forward
0 new messages