Culling Question

First off, I'll state that I'm using the last version of JME, but I think my question still applies to the current version.



I have a root node then two child nodes under that. On one of the child nodes I have sun, planets, ships, on another child node I have projectiles. My projectiles are made up of billboard nodes with quads attached. I'm setting a bounding sphere on the quad and updating the billboard node's world bounds. The root node and children node are set to CULL_DYNAMIC. The problem is the projectiles don't render unless I have the sun (for example) on the screen at the same time. It sounds to me like the bounds information is not propagating up the node hierarchy. I can get the projectiles to render if I set the root node and two child nodes to CULL_NEVER, but I'm thinking that shouldn't be necessary. Am I right? Was there a bug in the previous version? Does it sound like I'm missing something?



Many thanks.

What does it look like when you render the scene bounds?  Perhaps you are not updating the model bound after setting it?

What happens is if I'm looking away from the sun, and firing with no bullets rendering, I'm seeing no bounds. Then I turn toward the sun, poof the bounds suddenly appear where they previously weren't. Here's how I'm setting up the bullets:




      bulletQuad = new Quad("bulletQuad", 3f, 3f);
      bulletQuad.setModelBound(new BoundingSphere());
      bulletQuad.updateModelBound();
      bulletQuad.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
      
      zbuff.setWritable(false);
      zbuff.setEnabled(true);
      zbuff.setFunction(ZBufferState.CF_LEQUAL);
      bulletQuad.setRenderState(zbuff);
      
      as.setBlendEnabled(true);
      as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
      as.setDstFunction(AlphaState.DB_ONE);
      as.setTestEnabled(true);
      as.setTestFunction(AlphaState.TF_GREATER);

      bulletQuad.setRenderState(as);
      bulletQuad.setRenderState(ms2);
      bulletQuad.setLightCombineMode(LightState.OFF);
      bulletQuad.setTextureCombineMode(TextureState.REPLACE);
      bulletQuad.setRenderState(TexturesManager.getTexture(textureId));
      bulletQuad.updateRenderState();
      
      billboardNode = new BillboardNode("BulletBillboard");      
      billboardNode.setType(BillboardNode.CAMERA_ALIGNED);
      billboardNode.attachChild(bulletQuad);
      billboardNode.updateGeometricState(0, true);
      
      this.setModelBound(new BoundingSphere());
      this.updateModelBound();
      this.updateWorldBound();

      IngameState.getInstance().getProjectileNode().attachChild(billboardNode);
      
      this.getLocalTranslation().set(parentWeapon.getWorldTranslation());
      this.updateGeometricState(0, true);
      billboardNode.setLocalTranslation(this.getWorldTranslation());
      billboardNode.updateGeometricState(0, true);



This code is within a class that extends Sphere. BTW, my attachChild method on projectile node automatically calls updateGeometricState.

from looking at the issue



you have the code



IngameState.getInstance().getProjectileNode()



what is managing the rendering of the projectile node - looks like this is getting culled.




Actually the projectile node was just attached to the root node.



What it appears was the problem (although not shown in the code above) was that I was setting the cull mode on the projectile to CULL_DYNAMIC. Apparantely that's a big no-no. I didn't think it would hurt, but I guess if you do it on a child node it makes it vanish for all intents and purposes.



Thanks to those who responded.

you dont actually need to attach a node to the root node tree to get it updated an drawn, you just need to call draw ( with updateGeommetricState if applicable )



You may wan to consider this cause if your bullets get more complex ( Plasma trails ), you really wont want to draw what you cant see.



There are some threads relating to oct / quad trees. Mr Coders veg is also a good reference