Java Reference
In-Depth Information
In this chapter, we will discuss the use of different types of light source and their ef-
fects after describing the lighting properties or materials of visual objects. We will then
outline the use of fogging techniques to turn a hard and straight computer image into a
more realistic and smoother scene before discussing methods for immersing active visual
objects in a background.
materIal
The use of the material class has been discussed in Chapter III on appearance. Basically,
four components, ambient, emissive, diffuse, specular and shininess, are involved in
specifying a material.
Emissive corresponds to the color of the material that will be emitted, and is indepen-
dent of other external light color and intensity. Ambient is associated with reflection from
ambient light sources, specular and shininess are associated with highlight and strong
reflections, while diffuse corresponds to normal reflection from diffused sources. Figure
1 gives a summary on how the various material components can be specified.
Note, however, that the material appearance of an object under various light sources
will be properly seen only after setting the normal of the object properly. This is because
the reflection of light is with respect to the normal direction, and changing the normal
direction will affect the direction of the reflected lights.
Figure 2 illustrates the concepts of face normal and vertex normal, using a pyramid as
an example. For the triangular face formed with vertices 1, 2, and 3 or points A, B, and C,
the face normal will be the cross product of the vectors AC and AB. On the other hand, the
vertex normal is the sum of all the normals of the faces that intercept to form the vertex.
The setting of the normal of faces can be carried out manually or automatically using
com.sun.j3d.utils.geometry.GeometryInfo and com.sun.j3d.utils.geometry.NormalGenera-
tor. This is illustrated in the examples in Figure 3.
Figure 1. Specifying material
Material material = new Material();
// create default material
Material material = new Material(Color3f ambient_colour, Color3f emissive_color,
Color3f diffuse_color, Color3f specular_colour, float shinness);
// create material with specific lighting properties
Appearance appearance = new Appearance();
Appearance.setMaterial(material);
Search WWH ::




Custom Search