Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 11 ■ 3D SCene Configuration: uSing the perSpeCtiveCamera anD pointLight

The first thing I tried was to place the StackPane origin in the upper-left corner by using
.setTranslateX(-640) and .setTranslateY(-320), which worked to some extent as the result looked like
Figure 11-2; however, it was up in the upper-left corner, with the entire StackPane layout visible, and it was
scaled down 200 percent (four times, or one-quarter screen).
What this told me was that the StackPane was a 2D object, technically a “plane,” that was in “perfect
parallel” with the camera projection plane, facing the z-axis of the camera object. By contrast, now the
StackPlane is part of the 3D rendering pipeline because it’s a child of (underneath the renderer processing
pipeline) PerspectiveCamera.
This means that the StackPane and all of its children (VBox, ImageView, and TextFlow) are being
processed through the PerspectiveCamera object. This includes all of its algorithms and coordinate systems
(and similar “rules of engagement” if you will), all of which change how and where it will be rendered to the
screen (the Scene object).
The next thing I tried was logically setting the uiLayout object X and Y coordinates back to the 0,0 origin
settings using the .setTranslateX(0) and .setTranslateY(0) method calls. This is accomplished by adding the
following two Java statements to relocate your StackPane to 0,0 inside of the .start() method somewhere after
your uiLayout StackPane object instantiation Java statement.


Figure 11-2. Run the Project and notice that the StackPane is now located at the PerspectiveCamera 0,0,0
center origin

Free download pdf