Java Reference
In-Depth Information
void setSelfIlluminationMap(Image)
•
Image getSelfIlluminationMap()
•
ObjectProperty<Image> selfIlluminationMapProperty()
These methods define seven read-write properties for the
PhongMaterial
class. The
diffuseColor
and
specularColor
are object properties of type
Color
. The
specularPower
is a double property. The
diffuseMap
,
specularMap
,
bumpMap
, and
selfIlluminationMap
properties are object properties of type
Image
. Five of the seven properties can be specified in the
third constructor. However, once a
PhongMaterial
is constructed, its properties can also be altered.
In several of our earlier examples, we have used the one-parameter
PhongMaterial
constructor, in which we
specify the diffuse color of the 3D shapes. The diffuse color is what we normally think of as the color of an object.
The specular color is the color of the highlights reflected off of shiny surfaces, such as a mirror or another
well-polished surface.
In the program in Listing 10-7, we add a specular color to the material of a sphere.
•
Listing 10-7.
SpecularColorExample.java
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PointLight;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;
public class SpecularColorExample extends Application {
private View view;
@Override
public void start(Stage stage) throws Exception {
view = new View();
stage.setTitle("Specular Color Example");
stage.setScene(view.scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
private static class View {
public Scene scene;
public Sphere sphere;
public PointLight light;
private View() {
sphere = new Sphere(100);
PhongMaterial material = new PhongMaterial(Color.BLUE);
material.setSpecularColor(Color.LIGHTBLUE);
material.setSpecularPower(10.0d);
sphere.setMaterial(material);
sphere.setTranslateZ(300);
Search WWH ::
Custom Search