Pro Java 9 Games Development Leveraging the JavaFX APIs

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

The ObjectProperty specularMapProperty() method call returns the specularMap property
for the PhongMaterial that it is called off of. This specular color map is stored as an RGB Image object.
The getBumpMap() method call gets the Image object for the PhongMaterial property bumpMap.
The getDiffuseColor() method call gets the Color value for the PhongMaterial property diffuseColor.
The getDiffuseMap() method call gets the Image object for the PhongMaterial property diffuseMap.
The getSelfIlluminationMap() method call gets the Image object for the property
selfIlluminationMap.
The getSpecularColor() method call gets the Color value for the PhongMaterial property
specularColor.
The getSpecularMap() method call gets the Image object for the PhongMaterial property
specularMap.
The getSpecularPower() method call gets a double value for a PhongMaterial property
specularPower.
The void setBumpMap(Image image) method call sets the Image reference for the property
bumpMap.
The void setDiffuseColor(Color color) method call sets the Color value for the property diffuseColor.
The void setDiffuseMap(Image image) method call sets an Image reference for the property
diffuseMap.
The void setSelfIlluminationMap(Image) method call sets the Image for the property
selfIlluminationMap.
The void setSpecularColor(Color color) method call sets the Color value for the property
specularColor.
The void setSpecularMap(Image image) method call sets an Image object for a property
specularMap.
The void setSpecularPower(double value) method call sets the value of the property specularPower.
The toString() method call converts any data in a nontext (binary, numeric, etc.) format into a text
format.
Next, let’s implement some of the core color attributes in our JavaFXGame class and see how they
function.


Implementing PhongMaterial: Assigning Color and Power Values


Let’s get down to business now that we’ve perused the PhongMaterial class. Let’s declare a PhongMaterial
object at the top of the JavaFXGame class and name it phongMaterial. In the createBoardGameNodes()
method after the light object code, add a PhongMaterial instantiation using the second overloaded
constructor method and set the diffuse color to Color.GOLD, as shown highlighted in Figure 13-1 as well as
in the following Java code statement:


PhongMaterial phongMaterial; // Declared at the top of the JavaFXGame class
...
phongMaterial = new PhongMaterial(Color.GOLD); // In the createBoardGameNodes() method body

Free download pdf