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


As you can see in Figure 14-31, we have now set the “extremes” of your game board to fit into the
window, using these new camera settings with the ParallelCamera algorithm, which seems to distort the
game board less than the PerspectiveCamera does. If we now rotate the game board, it should all stay inside
of the window (viewable) area.


Summary


In this fourteenth chapter, we constructed the 3D portion of our JavaFX SceneGraph hierarchy, that is,
the gameBoard Group (Node subclass) branch node underneath the root (we had previously created the
uiLayout StackPane Node subclass). We created a subgroup of four game board quadrant Group branch
nodes named Q1 through Q4 that each contained a quarter of the game board interior, which were Box
primitives named q1 through q4 to match up with their Group Node Parent objects. Underneath these
quadrants we grouped five game board square leaf node objects, which will correspond in the gameplay
design to the quadrant game functionality.
We created two new method bodies, one for creating game board squares since there are dozens of
them and the other for creating Phong materials since there are going to be dozens of them! This keeps
things organized. We now have eight (nine if you count main(), which is still in the bootstrap code state)
method bodies, seven of which are custom, and we have more than 400 lines of Java code, all organized
into logical collapsing and expanding sections. We created colorful shaders for each game board square,
mapping the appropriate diffuse texture maps onto each one.
In Chapter 15 , we’re going to further refine our game board design and Java code organization and
create a way for game players to manipulate the board in 3D space so they (or the gameplay AI code) can
access the game board content and topic section that interests them.


Figure 14-31. Use your Run ➤ Project work process to see if the new camera algorithm and settings fit the
game board

Free download pdf