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 are at a point where our 3D boardgame is designed and coded, and we can get back into some
of the more technical JavaFX classes in the javafx.graphics module that are commonly used for games. One
of the most technical areas is 3D animation, which we’ll get into next so that we can animate the spinner and
game board and so forth to take our 3D boardGame Node hierarchy into the fourth dimension of time! After
that, we can add interactivity and make it an i3D board game! I just needed to get things perfected and a 3D
spinner in place, before we move on to add animation.


Summary


In this fifteenth chapter, we constructed the 3D “spinner” Sphere primitive UI element, which will allow the
user to apply a random spin to the game board to select a topic quadrant. We also finished texture mapping
the game board and figured out how to fix face rendering anomalies that kept the game board model, the
centerpiece for the game, from rendering correctly and therefore from having a professional appearance.
This solution involved using a much more complex Scene object instantiation, including a flag to turn on a
depth buffering algorithm as well as a constant that enables the scene-wide anti-aliasing of all 3D objects.
This eliminated the Y dimension (height) face rendering mistakes, as well as the jagged edges we were
seeing on the edges of game board components.
We created five new texture maps for the four game board center quadrants and for the spinner
UI element that allows the players to spin the board to determine what their next move, in this case an
educational topic, will be.
We added diffuse texture map Image objects and Phong shader definitions that utilized these texture
maps. We also added Java code to add a spinner UI to the SceneGraph hierarchy and got some more practice
using GIMP.
In Chapter 16 , we’re going to learn about all of the powerful Animation-related Transition classes
in JavaFX 9.

Free download pdf