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


Next, close the loadImageAssets() method body. Open the new createMaterials() method body
and copy and paste the Shader1 Java statements four times underneath themselves. Then rename them
to Shader2 through Shader5. Set the Image objects representing your game board square diffuseMap
properties to reference the diffuse2 through diffuse5 Image objects that you just created.
This could all be accomplished by using the following ten Java statements, which are highlighted in
yellow and blue at the bottom of Figure 14-15:


Shader1 = new PhongMaterial(Color.WHITE);
Shader1.setDiffuseMap(diffuse1);
Shader2 = new PhongMaterial(Color.WHITE);
Shader2.setDiffuseMap(diffuse2);
Shader3 = new PhongMaterial(Color.WHITE);
Shader3.setDiffuseMap(diffuse3);
Shader4 = new PhongMaterial(Color.WHITE);
Shader4.setDiffuseMap(diffuse4);
Shader5 = new PhongMaterial(Color.WHITE);
Shader5.setDiffuseMap(diffuse5);


Figure 14-15. Copy and paste the Shader1 Java code block four times underneath itself to create Shader2
through Shader5


Figure 14-14. Instantiate diffuse1 through diffuse5 in loadImageAssets() using your first five PNG diffuse
texture maps

Free download pdf