Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 12 ■ 3D MoDel Design anD priMitives: Using JavaFX 9 shape3D Classes

To change the rotation axis that your .setRotate() method uses to configure its rotation algorithm, there
is a second .setRotationAxis() method that you can use to change the default Rotate.Z_AXIS setting to the
Rotate.X_AXIS constant, which as you can see by the dot notation in the Rotate class.
Obviously, as you have learned by now, the .setRotationAxis() method call will have to take place before
the .setRotate(45) method call so that the rotation axis will be changed before the rotate algorithm is actually
utilized.
Add a .setRotateAxis() method call off your box object after the box.setTranslateX(500); method call,
using the Rotate.X_AXIS constant to configure the Rotate algorithm for use. The Java statement sequence
should look like the following Java code and can be seen near the bottom of Figure 12-9:


box.setTranslateX(500);
box.setRotationAxis(Rotate.X_AXIS);
box.setRotate( 45 );
pole = new Cylinder(50, 250, 24);
pole.setTranslateX(250);


Figure 12-8. All three primitives are now spaced apart; the box still looks 2D

Free download pdf