JavaFX: Working with JavaFX Graphics

6 Material

This chapter describes the Material class of the JavaFX 3D Graphics library.

The Material class contains a set of rendering properties. Example 6-1 shows the Material class hierarchy and that the PhongMaterial class is sub-classed from the Material class.

Example 6-1 Material Class Hierarchy

  javafx.scene.paint.Material (abstract)

The PhongMaterial class provides definitions of properties that 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 object, 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

// Use the material for a shape

The application and buildMolecule() method show how the PhongMaterial API is used. Both are available in the appendices sections.

Close Window

Table of Contents

JavaFX: Working with JavaFX Graphics

Expand | Collapse