Java Reference
In-Depth Information
Figure 25. Code segment and result of Material_Attribute.java
35.
Color3f none = new Color3f(0.0f,0.0f,0.0f);
36.
Color3f green = new Color3f(0.0f,0.2f,0.0f);
37.
Color3f blue = new Color3f(0.0f,0.0f,1.0f);
38.
Color3f red = new Color3f(1.0f,0.0f,0.0f);
39.
Color3f dirtygreen = new Color3f(0f,0.4f,0.4f);
40.
int SH =128;
41.
42. Appearance look = new Appearance();
43.
44. ColoringAttributes ca = new
45. ColoringAttributes(none,ColoringAttributes.NICEST);
46. PolygonAttributes pa = new PolygonAttributes();
47.
48. Material ma = new Material();
49. ma.setAmbientColor(green);
50. //ma.setDiffuseColor(blue);
51. //ma.setSpecularColor(red);
52. //ma.setEmissiveColor(dirtygreen);
53. //ma.setShininess(SH);
Figure 26. Results from Material_Attribute.java, after changing the diffuse color to blue
(0.0f,0.0f, 1.0f), and then the specular color to red (1.0f,0.0f,0.0f), followed by the emis-
sive color to dirty green (1.0f,0.4f,0.4f) resulting in the left, center and right hand displays,
respectively.
The shininess parameter is used to control the extent of the specular reflection. The higher
the value, the smaller the extent of the reflection and the area being highlighted. Figure 27
shows the effect for different shininess of the same object with ambient and diffuse colors
maintained at green and blue, and specular and emissive colors set to default.
Search WWH ::




Custom Search