简体   繁体   中英

How to display, zoom cubes in 3D, in Java's Frame's panel?

I need to be able to display a scene... :

  1. 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)

  2. 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

  3. I have coordinates X, Y and Z to place each cube in the scene

  4. I must be able to rotate the entire scene (ie : each cube must rotate/move)

  5. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM