Particular use of "Selector Programs"

Hi, in my Project, objects are arranged in a hierarchical structure. The nodes of the Tree are currently made with Groups and the leafs are made with GeometryGroup+GeometryInstance+Geometry

As Geometry I use triangle meshes.

Here is the question.

I want to be able to show and hide, at runtime, part of the Tree without removing objects.

Current solution is to check a variable “IsVisible” in the intersection program, but this is not the optimum.

I’d like to use a selector node between a Group node and a GeometryGroup node in order to “block” in advance the visit of a sub-part of the tree during the traversal phase.

I’ve read into the Programing Guide that a Selector can be used to chose between child.

In my case I don’t want to chose, I want to discard(hide) the child. In particular I want to stop the analisis of the sub-tree basing my choice on the value of a particular variable (at each node).

I hope I’ve made myself clear…



You can implement it like this:

Each selector only has 1 child.
The visit program then only checks whether its child is visible:

rtDeclareVariable(int, isVisible, , );

RT_PROGRAM void visit_program( void )
    if (isVisible > 0)

So, it is not mandatory to call the function “rtIntersectChild” within the Selector visiting program.

Thank you very much.