Why allow Group::Geode to call Goup::addChild()

46 views
Skip to first unread message

JIANJIE JING

unread,
Aug 26, 2022, 12:01:56 AM8/26/22
to OpenSceneGraph Users

Hi,

I am new to OSG. 

I'm curious about the public method `addChild()` of `Gourp` class which can be called by the leaf class `geode`.

The geode is defined as leaf but: 

why allow this ambiguous semantic (i.e. geode->addchild() )?
why not prevent this behaviour?
why the framework of Node-group-child is designed as so?
thanks if anyone talk with me

Btw: Any latest book recommanded for a newcomer  ?


JIANJIE JING

unread,
Sep 15, 2022, 2:25:28 AM9/15/22
to OpenSceneGraph Users
anyone help?: )

alexandre.vai...@gmail.com

unread,
Sep 15, 2022, 8:41:51 AM9/15/22
to OpenSceneGraph Users
Hello Jing (?)

I'm not entirely sure where the confusion comes from. Although a geode is a "leaf" in terms of "tree"/"nodes", it is still a group in the sense that it is a group of geometries/drawables. In that sense, adding a child drawable to a geode makes perfect sense.

I agree though that there are are no feature that prevents adding a non-drawable to a geode in the code, but one good habit you could take when dealing with geode and drawables is make sure to cast your geode node as a geode, and add drawables to it through the addDrawable() method instead of using the addChild() method; this way, the compiler will tell you that there is something wrong if you try to do something funny.

As for the books on OSG, I'm not aware of anything recent. The last one I saw was about OSG 3.0. Also, given the state of the development of OSG, since the focus has been shifted to VSG, I don't expect to see any other books ever published about it.

I hope it helps.

- Vaillancourt
Reply all
Reply to author
Forward
0 new messages