Hi!
I'm building a little factory simulation game, where the player plops machines onto a factory floor where they can interact. It's also my first JME project, so I'm learning the ropes. I appreciate your patience with a newbie question.
My problem is that the ZBufferState I put on my root node isn't working for me. Here is what I've done so far:
Initialize my "empty factory" scene onto the root node. A quad to act as the factory floor, a texture state for the quad, and an AxisRods primitive at the origin so I don't get confused. I'm leaving the texture stuff out of the snippet, it shouldn't affect zbuffer stuff. Then I set up a ZBufferState with LessThanEqualTo, make it writable and enabled, then add it to my root node.
Am I correct in assuming that if my root node has a ZBufferState on it, all of its children it will be treated the same way zbuffer-wise?
mOriginMarker = new Node("Origin");
mOriginMarker.attachChild(new AxisRods("Axes", true, 0.5f));
Quad floor = new Quad("Factory Floor", 16f, 16f);
floor.translatePoints(8f, 8f, 0f);
floor.setModelBound(new BoundingBox());
floor.updateModelBound();
// texture is loaded at this point, fed into a texturestate, and it seems to work
floor.setRenderState(textureState);
// Z Buffer
zBuffer = mDisplay.getRenderer().createZBufferState();
zBuffer.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
zBuffer.setWritable(true);
zBuffer.setEnabled(true);
mRootNode.setRenderState(zBuffer);
mRootNode.attachChild(mOriginMarker);
mRootNode.attachChild(floor);
mRootNode.updateGeometricState(0.0f, true);
mRootNode.updateRenderState();
So when I render that, it looks as I expect (figure A), but I added the nodes in the right order, so that's no surprise.
Later, when you hit a button, a new node is added to the Root Node (a sibling to the floor). This node contains 4 quads that are supposed to be a quick and dirty blueprint-looking of where a new machine will be placed. It's a blue squashed box (2 by 2 by 0.01) as a base with 3 cyan squashed boxes on top of it (each 1x1x0.2). It should look like a square with 3 quadrants covered up. It is very ugly, I'll fix that later ;).
This is what showed me that my ZBuffer isn't on. When I attach the 3 tiles to the blueprint node, THEN add the base, it renders the base above them. When I add the base first, it renders well.

A = Before
B = What I have
C = What I want to do without worrying about the order I attach my spatials
Did I set up my ZBufferState incorrectly? Do I have to add it to every node that I want depth-checking on (even if it is already on the parent)? Do I need to do something other than update the geometry when I add the new blueprint node to my scene?
Thanks for your help,
Fletch