Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 15 ■ 3D Gameplay UI CreatIon: UsInG the sphere prImItIve to Create a UI noDe


Now we can use the Run ➤ Project work process and test our new Java code to add the Sphere
spinner UI to the board game we are creating in this 3D Scene. We’ll also be able to see whether adding the
algorithms for anti-aliasing and depth buffering (which check for proper face order rendering and apply
smoothing to rough edges in the render pass, respectively) have solved our visual quality problems by using
the more complex overloaded Scene() constructor method, with five parameters, instead of only three.
As you can see in Figure 15-14, the 3D gameBoard hierarchy, with two dozen 3D primitive objects as
game board squares and game board quadrants, is now rendering as one cohesive 3D model. It finally looks
like the board game (cardboard game boards) that you see in most popular board games, and each square
and quadrant will be able to be accessed and controlled individually in your code, even though the game
board model appears to be only one 3D object in the 3D Scene. This is what we’ve been striving to learn
about, and achieve, during the past several chapters.


Figure 15-13. Add your spinner Sphere object to the top of the SceneGraph hierarchy using root.getChildren().
addAll()

Free download pdf