Culling Issue (Parent Child)

Hi,

I have some problems using the setCullHint method.
I use the following node tree (N=node, G=geometry):

rootNode
|
N1–G1
|
N2–G2

As you can see I’ve created a node (N1) and attached a geometry (G1) as a child. Then I created a second node (N2) and attached that to N1 aswell. Last I created a second geometry (G2) and attached it to N2.

Now my problem:
I try to make G1 invisible, while G2 remains visible. Therefor I used the following code:

for (Spatial child : rootNode.getChildren())
	child.setCullHint(CullHint.Always);
node2.setCullHint(CullHint.Never);

Anyhow, if I run the code nothing is visible. The programm doesnt draw the second geometry.

What do I do wrong? Where is the mistake?
Please help me :slight_smile:

Based on your drawing and your description, Node2’s parent is culled. What did you expect to happen when you indicated that that scene graph branch should always be culled?

N2’s parent (N1) is culled, that is correct. But since N2’s culling state is no longer “inherit” but “never” I assumed that the parents culling state wouldnt matter any longer… o.O

Can you please tell me how I make G1 invisible, while G2 remains visible?

“how I make G1 invisible” - Cull G1?

Haha, ok… :smiley:

You see, my graph is actually a little bit more complex. I just simplyfied it for this question.
So what I really have is the following graph:

rootNode
|
N1–G1
|
N2–G2
|
N3–G3
|
N4–G4
|
N5–G5

The graph grows dynamicly. So I cant refer to G5 or N3 directly.
And now I want to hide everything exepct all the geometrys under a certain node (for example every geometry under N3, which would be G3, G4 and G5)…

If you mark a section of the scene graph to always be culled then the ENTIRE SECTION OF THE SCENE GRAPH is ALWAYS culled. Just like you asked it to. None of the children are checked because you’ve marked the whole section for definite-always-for-sure culling… always. So that section of the scene graph will be culled. The children will be culled no matter what their cull hint is because there parent is culled. In other words, the entire section of the scene graph gets culled when you tell it to be culled. Marking a subgraph as “culled” is like telling the camera that “this isn’t in the frustum so don’t bother doing anything with it”. And if the parent is not in the frustum then by definition none of the children are.

If you want to hide just certain leaves then just hide those leaves… otherwise your scene graph structure is all messed up for what you actually want to be doing and you may want a different design.

the inherit actually only matters for dynamic and never, as only those two have the chance of evaluating the scene-graph deeper again.

Well, thank you guys :slight_smile:

So you basically say I have to loop through all of my spatials and if I find a geometry I want to hide I perform the setCullHint method?
Thats ganna be a lot of looping and therefore I am bit dissapointed… :frowning:

But never the less, thanks for the fast and great help!

@bob_sheknowdas said: Well, thank you guys :)

So you basically say I have to loop through all of my spatials and if I find a geometry I want to hide I perform the setCullHint method?
Thats ganna be a lot of looping and therefore I am bit dissapointed… :frowning:

But never the less, thanks for the fast and great help!

Well, then it sounds like your scene graph structure might be messed up. You need to think about nodes as containing their children. Thus if you culled a node you automatically cull it’s children. Just like if I removed my car, I’m removing all of the stuff inside of it, too.

If your nodes/structure is not representing this sort of containment then it’s kind of broken and you are using the structure as a crutch for something else.

So what kind of node tree do you suggest if I have a car, but at a certain point I just want to see the front tires? Or just the engine. Or maybe even just parts of the engine.

@bob_sheknowdas said: So what kind of node tree do you suggest if I have a car, but at a certain point I just want to see the front tires? Or just the engine. Or maybe even just parts of the engine.

Then you need to just make the parts invisible that you want invisible. Obviously making the whole car invisible makes the whole car invisible. If you just want the body invisible then just make the body invisible.