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


Next, let’s start applying the diffuse texture maps to our 3D boardgame elements and finish creating the 3D.

Texture Mapping the 3D Game Board Quadrants: The Java Code


Open your createGameBoardNodes() method body, and cut and paste the q1 through q4 object code into
the top of the method so that your quadrant Box primitives q1 through q4 are instantiated and configured
all in the same block of Java 9 statements. You can now more clearly see the pattern of X, Z movements from
different 225 and 525 combinations relative to each quadrant, with no identical X, Z coordinate pairs, which
would overlap your quadrants.
Add q1.setMaterial(Shader21); to the first one, as shown in Figure 15-8, using the following Java code:


q1 = new Box(300, 5, 300);
q1.setMaterial(Shader21);
q1.setTranslateX( 225 );
q1.setTranslateZ( 225 );
q2 = new Box(300, 5, 300);
q2.setTranslateX( 225 );
q2.setTranslateZ( 525 );
q3 = new Box(300, 5, 300);
q3.setTranslateX( 525 );
q3.setTranslateZ( 525 );
q4 = new Box(300, 5, 300);
q4.setTranslateX( 525 );
q4.setTranslateZ( 225 );


Figure 15-7. Name your new diffuse color texture map file gameboardspin.png and then save it into your /src
folder

Free download pdf