Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 13 ■ 3D MoDel ShaDer Creation: USing the JavaFX 9 phongMaterial ClaSS

glowMap = new Image("/beachball2grayscale256px", 256, 256, true, true, true);
bumpMap = new Image("/beachball3grayscale256px", 256, 256, true, true, true);


Next, go into the createBoardGameNodes() method, change the diffuse and specular color settings to a
Color.WHITE value, and add a setDiffuseMap(diffuseMap) method call off of the phongMaterial object. The
Java code for the diffuse color texture map statements, highlighted in blue in Figure 13-13, should look like
the following:


phongMaterial = new PhongMaterial(Color.WHITE);
phongMaterial.setSpecularColor(Color.WHITE);
phongMaterial.setSpecularPower( 20 );
phongMaterial.setDiffuseMap(diffuseMap);


Figure 13-13. Add a diffuseMap to the shader pipeline to add some surface color and set the specular and
diffuse colors to white


Figure 13-12. Declare and instantiate Image objects to hold texture map data for a diffuse, specular, glow, or
bump map

Free download pdf