0

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 (i.e. : 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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70
  • 1
    *"Is it possible?"* Sure, 'just' implement a 3D rendering API much in the same vein as already implemented in the API you've rejected using *"What class do you advice me?"* Do a class on 3D geometry for starters. I realise you meant the 'magic standard API class that does not exist', but seriously - you think 3D rendering is that easy? Start with simpler things. – Andrew Thompson Apr 04 '17 at 12:19
  • There isn't any standard "3D scene" ? I must make use of OpenGL ? – JarsOfJam-Scheduler Apr 04 '17 at 12:30
  • 1
    *There isn't any standard "3D scene"* Short answer, no. Long answer, nope. – Andrew Thompson Apr 04 '17 at 13:22

1 Answers1

1

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.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045