Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 12 ■ 3D MoDel Design anD priMitives: Using JavaFX 9 shape3D Classes


Next, let’s use some of the 3D primitive modification (move and rotate) method calls to move these
away from center Scene and rotate the cube so that it does not look like a 2D object. This can all be
accomplished using the .setTranslateX() and setRotate() method calls off the box and pole objects, as is
shown at the bottom of Figure 12-7:


box.setTranslateX(500);
box.setRotate(45);
pole.setTranslateX(250);


Next, use a Run ➤ Project work process to view the primitives individually. As you can see in Figure 12-8,
the .setRotate() method is using the z-axis for its rotation, so your 3D object is still rendering as a 2D object.
Let’s fix that!


Figure 12-7. Use setTranslateX(250) to move primitives 250 units apart and use setRotate(45) to rotate the
box 45 degrees

Free download pdf