Overlapping Meshes

Hello world!



Beginner question here. If I have two mesh surfaces occupying the same space, as in two triangles with the same slope overlapping each other, the game renders a funny graphical artifact as the two surface textures flicker in and out, so to speak.



What I’m wondering is if there is a way I can set a ‘higher priority’ to one geometry over the other so that if their meshes should overlap, then its will render dominant over the other with no flicker occurring.



Hope that’s clear. And thanks for reading ^.^

You could attempt to do that in some way but it would be very complicated, you should avoid such situations, what exactly are you trying to do? The simplest solution would be moving and/or scaling the objects so that they do not really overlap.

The jist of the situation is that my program allows the user to shape and manipulate objects in the game, but this can result in the aforementioned situation. I’d like to make the flickering stop while still allowing the two surface to appear flush when viewed from the side.



I know I could either redefine one of the meshes to have a hole where the other mesh is, or I think I could make the second mesh disappear and use multi-texturing to create the effect of the two overlapping, but both of these solutions would require considerable work to code.



If I were to move one surface forward a tiny amount, say the smallest value a float or double can possibly contain, would that be enough to make the flickering stop?



Guess I could test that myself couldn’t I? >.<

Theres a close to zero constant in FastMath, you might want to try that.

Its probably best to inform your users that they shouldn’t have two planes at the exact same height, however if you know which surface should appear first, you can enable polygon offset for it (material.getAdditionalRenderState().setPolyOffset())

setPolyOffset() did the trick! Thank you kindly : D