Getting Started with JavaFX 3D Graphics
Beta Draft: 2013-09-17
6 Materials
This chapter describes the Material class of the JavaFX 3D Graphics library.
Materials contains a set of rendering properties. Example 6-1 shows the Material class hierarchy and that the PhongMaterial is sub-classed from the Material class.
Example 6-1 Material Class Hierarchy
java.lang.Object javafx.scene.paint.Material (abstract) javafx.scene.paint.PhongMaterial
PhongMaterial class provides definitions of properties represent a form of Phong shaded material:
-
Diffuse color
-
Diffuse map
-
Specular map
-
Specular color
-
Specular power
-
Bump map or normal map
-
Self-illumination map
Materials are shareable among multiple Shape3D nodes.
Example 6-2 shows how to create a PhongMaterial, set its diffuseMap properties, and use the material for a shape.
Example 6-2 Working with Material
//Create Material Material mat = new PhongMaterial(); Image diffuseMap = new Image("diffuseMap.png"); Image normalMap = new Image("normalMap.png"); // Set material properties mat.setDiffuseMap(diffuseMap); mat.setBumpMap(normalMap); mat.setSpecularColor(Color.WHITE); // Use the material for a shape shape3d.setMaterial(mat);