I have a sketch that uses P3D to render a 3D cube which can be rotated an translated. I also have a small menu with two buttons. The buttons are drawn with rect(). Now, this all goes well, untill the cube is becoming to close to the menu, than it overlaps the menu. To be more clear, here's an image:
As you can see, the cube is now over the button. For text I have the option to set textmode(SCREEN) which will render text flat on top of anything else.This is why button 2 is in front of the cube Basically I'd like the same behavior for rect. Also, at a later stage I want to double the width of the sketch and the right part should sho a 2D slice of the 3D cube. Again, I don't want the cube to overlap the slice in any case.
I think you should use two buffers. P3D/OPENGL PApplet for the display, and P2D or JAVA2D PGraphics for the GUI. Probably you will have the same problems later, so you´ll have to disable depth test before drawing the GUI (and enable it again when rendering 3d shapes). I have to say, though, enabling+disabling the depth test is quite expensive sometimes. From hint reference (http://processing.org/reference/hint_.html): "hint(DISABLE_DEPTH_TEST) - Disable the zbuffer, allowing you to draw on
top of everything at will. When depth testing is disabled, items will be
drawn to the screen sequentially, like a painting. This hint is most
often used to draw in 3D, then draw in 2D on top of it (for instance, to
draw GUI controls in 2D on top of a 3D interface). Starting in release
0149, this will also clear the depth buffer. Restore the default with
hint(ENABLE_DEPTH_TEST), but note that with the depth buffer cleared,
any 3D drawing that happens later in draw() will ignore existing shapes
on the screen."
Hi Handlewithcare, did you ever get this sorted out, and would you share your code/solution? I have the same problem. I want to draw a 2D CP5 interface to one side of a window displaying my rotatable 3D OpenGL object. My controls get drawn in 3D space and are rotated with the model.