Pro Java 9 Games Development Leveraging the JavaFX APIs

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

As you can see in Figure 11-15, I have commented out the code relating to your StackPane UI
compositing pipeline; I have added statements relating to removing the UI control panel from view and to
setting the 3D Scene Camera object to the position we want to have it is when the game is initially started.
The new code statements look like the following Java code and are shown highlighted in the middle of
Figure 11-15:


uiLayout.setVisible(false);
camera.setTranslateZ(-1000);


Now when you use your Run ➤ Project work process and click the Start Game Button, your StackPane
will disappear and the empty (black) 3D scene will be revealed.
Now it is time to learn about 3D Scene lighting using the JavaFX 9 LightBase superclass and its
AmbientLight and PointLight subclasses. We will cover these in detail before implementing them in our
JavaFXGame class, before we end this chapter on core 3D Scene elements (Camera and LightBase) that need
to be at the root of our SceneGraph in our i3D pro Java 9 game design and development pipeline. Getting
excited yet? Lights, Camera...ActionEvents!


Figure 11-15. Add a .setVisible(false) method call off of uiLayout and a .setTranslateZ(-1000) method call off
the camera

Free download pdf