Hi, I need help setting the render order. I have a completely flat TerrainBlock, and some Disks at the same Height. Jme sometimes shows the Terrain, sometimes de disk, and sometimes a mix of both (quite ugly).
Is there a way to tell JME which object to render last?
Thanks in advanced, Kanto.
Chances are, you're suffering from a Z fighting issue. If the difference between disk and terrain is jagged edges or a stipple pattern, then that's quite likely the cause. The only real solution is to lower (or raise) one of the geometries slightly.
Or you could use Renderer.setPolygonOffset() between drawing your Terrain and Disks.
public class NewMain extends SimpleGame{
public static void main(String[] args) {
new NewMain().start();
}
Disk disk = new Disk("d", 40, 40, 3f);
Quad terrain = new Quad("q", 10f, 10f);
@Override
protected void simpleInitGame() {
terrain.setSolidColor(ColorRGBA.brown);
disk.setSolidColor(ColorRGBA.orange);
//since terrain and disk are not attached to rootNode, we have to update all state information manually
terrain.updateRenderState();
disk.updateRenderState();
}
@Override
protected void simpleRender() {
Renderer r = display.getRenderer();
r.draw(terrain);
r.setPolygonOffset( 1f, 5f);
r.draw(disk);
}
}