Java Reference
In-Depth Information
mMaterial.setColor(Material.DIFFUSE, 0xFF0000);
mMaterial.setColor(Material.SPECULAR, 0xFF0000);
mMaterial.setShininess(100.0f);
mAppearance.setMaterial(mMaterial);
mBackground.setColor(0x00ee88);
An Appearance is an M3G class that groups together a set of objects that control how a
submesh will appear when it is rendered. These objects are called rendering attributes . One of
the rendering attributes is Material . As the name implies, the Material attribute controls the
color and how light will reflect off the submesh being rendered. In the preceding code, the
Material is set to be DIFFUSE and SPECULAR , with a red color (an RGB value of 0xFF0000 ). The
possible values for the first parameter of the setColor() method of a Material are listed in
Table 15-1.
Table 15-1. Possible Values for Specifying the Reflective Quality of a Material's Color
Value
Description
AMBIENT
The ambient color component, the color of the material that is revealed by
ambient (evenly distributed) lighting
DIFFUSE
The diffuse color component, the color of the material that is revealed by a
directional lighting
EMISSIVE
The emission color component, the color of the material that appears to
be glowing
SPECULAR
The specular color component, the color displayed in the reflection highlights
The setShininess() method controls how shiny the material appears to be. It actually
adjusts the concentration of the specular lighting component and can take on a value from 0 (dull)
to 128 (very shiny).
The Background object is an M3G object that is used to render the background. You can
specify either a color or an Image2D . These are the methods of Background to set color or image:
void setColor(int rgbColor);
void setImage(Image2D image);
In the code in Listing 15-1, the Background of our rendering is set to a light green color (RGB
value of 0x00ee88 ).
In summary, the code in the init() method of Listing 15-1 places a shiny red triangle
against a light green background for the 3D rendering.
Setting Up Light and Camera
The last part of the init() method sets up the light and camera. Camera is an M3G class that
controls what you see in the rendering. It has a position and an orientation. In addition, you
can control other attributes such as the field of view, the aspect ratio, and clipping panes. These
Search WWH ::




Custom Search