Java Reference
In-Depth Information
materIal
Another way to add color and enhance visual effects to an object's appearance is to make
use of material class. This, however, requires illumination from one or more light sources.
Once these are specified, the appearance of the object can be determined.
A material object can have the following properties:
Ambient color: The ambient RGB color reflected off the surface of the material.
This gives the overall color of the object and is independent of the light source. The
range of value for each primary color is 0.0f to 1.0f, with a default at (0.2f,0.2f,0.2f).
Ambient color is visible only under ambient lighting.
Diffuse color: The RGB color of the material when illuminated. Obviously, this
color depends on the light source. Provided the object has no shininess, the surface
of the material facing the light source will have this color. The range of value for
each primary color is 0.0f to 1.0f, with a default diffuse color of (1.0f,1.0f,1.0f).
Specular color: The RGB specular color of the material under highlights. The
range of value for each primary color is 0.0f to 1.0f, with a default specular color of
(1.0f,1.0f,1.0f).
Emissivecolor: The RGB color of the light that the material emits, if any. The range
of value for each primary color is 0.0f to 1.0f, with a emissive color of (0.0f,0.0f,0.0f)
or black.
Shininess: The material's shininess. The range is [1.0f, 128.0f], with 128.0f being
not shiny and 1.0 being most shiny. The default value is 64.0f.
Enabling or disabling of lighting.
Figure 25 shows an example using material class in the presence of two light sources,
an ambient one and a directional one. Note that, with the ambient color set to green
(0.0f,0.2f,0.0f), those parts of the object unaffected by the overhead directional light appear
green in color. On the other hand, because the default diffuse and specular colors are white,
the portion of the object illuminated by the overhead light appears white.
Figure 26 shows the result after each stage by changing the diffuse color to blue, the
specular color to red, and then the emissive color to dirty green. Note that without the
emissive color, the bottom part of the object still has an ambience color of green and looks
the same as before. However, the color diffused from the overhead directional white light
source now makes the top part of the object blue. Changing the specular color to red makes
the highest part of the object that faces the directional light source directly red instead of
white. The last change that overwrites the default emissive color of black (meaning that
the object is not emitting any color) to dirty green results in quite a significant change to
the appearance of the object. In general, setting strong emissive color will tend to override
the colors from all the other sources.
Search WWH ::




Custom Search