Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 11 ■ 3D SCene Configuration: uSing the perSpeCtiveCamera anD pointLight


The final thing that you will need to do to wire your PointLight and Sphere to each other, to the
camera, and to the GameBoard 3D branch of the SceneGraph is to add your sphere Node object to your
gameBoard Group object using the .getChildren().add() method chain in the proper order inside of your
.addNodesToSceneGraph() method.
The code for your addNodesToSceneGraph() method Java statements is highlighted in the middle of
Figure 11-18 and should look like this Java method body:


private void addNodesToSceneGraph() {
root.getChildren().addAll(gameBoard, uiLayout);
gameBoard.getChildren().add(sphere);
uiLayout.getChildren().addAll(boardGameBackPlate, logoLayer, infoOverlay, uiContainer);
...
}


Figure 11-17. Declare a sphere and light object, and in createBoardGameNodes instantiate and configure
them for use.

Free download pdf