attachChild to rootNode's children

I’m playing with a bunch of meshes.
Mesh A is attached to NodeA, and NodeA is attached to rootNode in the simpleInitApp() method, hence gets rendered normally.

Issue: Mesh B is a simple triangle, and in the update(tpf) method is attached or removed from NodeA depending on the distance with the camera (a very primitive LOD). You can never see the triangle :frowning:
NodeA.attachChild(triangle) works only in the simpleInitApp() method??!
Instead, If I attach the dynamic triangle to the “rootNode” you can clearly see it apperaring and disapperaing from the scene as you move back and forth.
But I don’t want to add this mesh to the rootNode. I want it to add to a specific node, should be a simple task, but how to do it? Why can’t I simply attach to the node I want, in UPDATE?

No, I think you should check the translation/scaling of the Node.

1 Like

It’s the first thing I thought. But the scene is really simple, just a sphere on 0,0,0 and the other mesh is a triangle that clones one of the sphere triangles.

Damn. Still it looks the easiest reason. I could have tried using another convex mesh like another sphere… to test the thing, or disable the backculling to be sure. I felt somehow that some gl-statemachine-voodoo weirdness was involved. Never code for hobby until 3AM if you’re going to office at 9.

Maybe this is the issue. Did you try adding a new Box instead?

You definitely can, thus look for an error somewhere. Can’t help much more without seeing the code.

Put together a simple test case. When that works fine (because attaching children during update is of course fine) then you can figure out what’s different about your code. And in the small chance that it doesn’t work then you will have a ready-made sample to give us so we can point out what is wrong.

1 Like