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

Before we will be able to render your 3D Scene and look at the new spinner UI to see whether we need
to tweak the diffuse texture map in any way, we’ll need to add it to the JavaFX SceneGraph. I am going to
add it at the top, directly under the root, as the 3D UI will eventually have its own hierarchy, just like the 2D
uiLayout does and just like the 3D gameBoard does. In this way, if we want to affect the 3D UI elements as a
whole at any time, we can do this using one line of code referencing the 3D UI branch, and that will affect all
the leaf nodes underneath it. For now, the spinner will be a leaf node underneath the root. The Java code to
add the spinner, shown in Figure 15-13, should look like the following:


root.getChildren().addAll(gameBoard, uiLayout, spinner);


Figure 15-12. Add a Sphere primitive named spinner, set the material and translation parameters, and fix the
face order render bug

Free download pdf