GameSpawn Site Map
GameSpawn Update mailing list
Lee's Lessons

Basic Appearance 2


I hope yesterday's Appearance example helped to shed the light not necessarily so much on the Appearance object itself as much as the difference between it and a Geometry object. It should also have been helpful in showing how Java3D builds a scene from the ground up. The ground being Geometry and Appearance objects. Today I wanted to get more into Appearance objects and what they can do. Today's code demonstrates just some of what Appearance objects can do. It is in a file called Here we can see some of the effects of changing the color and emissiveness of an Appearance. The lighting is directional but there is ambient lighting code there also. It is commented out. All you have to do is then comment out the directional lighting. You can change the color of the lighting and see its effect on the Appearance. You can, by the same logic, change some of the Appearance attributes while leaving the lighting the same to see its effects. For directional lighting you can not only change the color but also the direction (Vector) of the light and the point in space for the light.
Demonstrating the Appearance color and emissiveness properties. You can also toy with the type of lighting and its properties.

As you can see this is similar to yesterdays example in that there is just a simple cube in the middle of the screen. Not too exciting until you realize how easy something like this is to create and modify. Today, however, instead of texture mapped Appearances I deal with color and emissive properties of Appearance objects. The cube in todays example is at a slight angle to get a better look at the effects of the code. The color of the cube has been made green and its emissive levels have been set high. You can change the color of the cube and the lighting for cool effects and to aid in clarifying the capabilities of the Appearance object and lighting abilities. It is recommended that the reader go to the code and change some of the properties of the Appearance object and lighting objects to see their effects. Here are some key lines to look at:

Primitive shape = new Box(.3f, .3f, .3f, null);



You can't set the color properties of the Appearance until you generate the normals. This makes sense because it doesn't know how to reflect the color. You set the appearance after you generate the normals. I use the Box to generate the normals instead of the Primitive class.

Appearance app = new Appearance();

Color3f green = new Color3f(0.0f, 1.0f, 0.0f);

Color3f white = new Color3f(1.0f, 1.0f, 1.0f);


  new Material(white, green, white, green, 1.0f));

Here is where the Appearance is actually set. You can see that I set it green. You can play with the numbers and check out the javadoc for further explanation.

-Simple Behaviors

-Getting Java3D as an Applet
-Benchmarking Java3D
-Multiple 3D Model Format Viewer

Michael C. Lee, Jr.