Java3d: How to draw a 2d overlay on a Java 3d scene?
There are several techniques, I'd like some feedback on the pros/cons of them. As far as I know there are :
- "Raster" technique
Have to use images, and it is not a real overlay, just another object in the 3D scene. Other bjects could hide it.
- the Canvas3D "postRender" technique Java3D: Painting 2D HUD over a Canvas3D开发者_高级运维
Easy but I cannot get rid of the flickering
Are there other techniques I am not aware of ? Would it be easier to use another library like LWJGL or JME ?
This "flickering" you mention is called the Z-fighting , and it occurs because your 3D render does not know which polygon is in front of the other, because the Z position values are truncated before rendering, and when they are too close (or the same), it leads to that undefined situation that results in the flickering you mentioned.
Z-fighting can be mitigated, but you can't really eliminate it completely, so, eventually you could either apply a texture with the letters you want, to the surface, or you can try to manually adjust the values of the 2D overlay position, trying to increase it's distance from the other polygons progressively, by small bits, till it is small enough that it looks like if it's there, and big enough to make the Z values be different after they are truncated, eliminating the doubt for the render, and consequently eliminating the Z-fighting.
精彩评论