[osg-users] Show children with hidden parent

Robert Osfield robert.osfield at gmail.com
Thu Apr 27 02:35:54 PDT 2017

Hi Yura,

Thanks for the explanation.  I'm not entirely clear on what you are
after, so will provide some general comments.

First up, in the OSG a parent node is always traversed before
children, so if you stop traversal at a parent none of the children
will be traversed.  So if you set the NodeMask of the parent ot 0 then
non of the children will be traversed.   So you can't use this to
achieve the result you want.

The osg::Node's NodeMask is a 32bit mask which is and'd against the
NodeVisitor's TraversalMask, for the cull traversal this TraversalMask
is set by the View(er)'s Camera's(inherited from osg::CullSettings)

If the classes of objects you have are limited to 32 different
components then it might be possible to use the NodeMask to toggle
on/off different subgraphs by changing the CullMask.    For insrtance
your A, B, C, D etc. classifications could each be mapped to a
separate bit, then your CullMask would set the appropriate bit you
want to see at one time.  If possible to use this approach it's really
lightweight and utilizes standard OSG features.

Another approach is to use osg::Switch to toggle on/off different subgrahs.

Another approach is to use a custom osg::Group or NodeCallback that
overrides the traverse implementation and makes it's own judgement on
whether to traverse the children or not.  For instance you might have
some global state that tells you want parts you want to see, and this
could global state could be shared between the callbacks/Nodes.


On 27 April 2017 at 06:58, Yura Ivanov <dev3d at protonmail.com> wrote:
> Hi,
> We have scene with a lot of objects (1_Scene.png). Objects that have same name are instances of one object. Instances differ by transform. The count of instances of the same object can be up to 1000. User at a single time must see:
> 1) all instances of one object (2_C_only.png, 4_F_only.png), or
> 2) all instances of one object and it's direct children only (3_C_and_1st_level.png).
> Thank you!
> Cheers,
> Yura[/img]
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70845#70845
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list