Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 14 ■ 3D MoDel hierarChy Creation: Using priMitives to Create a gaMe BoarD

From an optimization standpoint, we have created a relatively complex SceneGraph hierarchy for
the 2D UI and 3D GameBoard components using only nine .getChildren().addAll() method chain Java
programming statements, as shown in Figure 14-17. This is relatively compact as we are referencing dozens
of 2D and 3D game component leaf nodes in a highly organized fashion and using only nine SceneGraph
hierarchy construction statements.
Adding the other four squares and the other three quadrants could be accomplished by using the
following Java programming statements, which are shown highlighted in yellow and light blue at the bottom
of Figure 14-17:


root.getChildren().addAll(gameBoard, uiLayout);
gameBoard.getChildren().addAll(Q1, Q2, Q3, Q4);
Q1.getChildren().addAll(q1, Q1S1, Q1S2, Q1S3, Q1S4, Q1S5);
Q2.getChildren().addAll(q2);
Q3.getChildren().addAll(q3);
Q4.getChildren().addAll(q4);


Figure 14-18 shows the Run ➤ Project JavaFX 9 code testing work process. As you can see, we already
have a quarter of the game board in place, and it looks very good for a first go-round at assembling all these
assets, including 3D Box primitives and 2D texture map images, which we have declared at the top of our
class and are about to create.


Figure 14-18. Use the Run ➤ Project work process to see if the completed 3D game board quadrant is aligning
properly

Free download pdf