I need to be able to display a scene... :
Containing N cubes (with precise width, height and depth : each in the shape of "-/+[0|1|2].[0|1|...|9]+" - with seven digits after the comma : need a displaying with high-precision), with a given color (the same on all the faces of the cube)
I must be able to overlay a cube colored with white with another cube colored with red, of the same width, height and depth (of course, with same coordinates X, Y and Z) and the latter must hide the first without any problem of Z-fighting
I have coordinates X, Y and Z to place each cube in the scene
I must be able to rotate the entire scene (ie : each cube must rotate/move)
I must be able to zoom/unzoom in the scene, before or after having rotated the latter
I don't want to use OpenGL, or something else than the standard Java's API.
For the moment, I just display pixels in a 2D JFrame
's panel (with the class Graphics
and the overrided paint()
). But my project makes me in need of switching with a 3D approach. I would want to just change my use of Graphics
and paint()
, and to keep my JFrame
's panel.
Is it possible? What class do you advice me?
Consider JavaFX, as shown in Getting Started with JavaFX 3D Graphics . It uses the platform's available rendering pipeline internally, as discussed in JavaFX Architecture . Several related examples are shown here . If you stay with Swing, you can embed JavaFX content using JFXPanel
, seen here . In particular, you can test overlap with this example .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.