Appearance Is Everything : Object Model « 3D « Java






Appearance Is Everything


/*
The Joy of Java 3D

by Greg Hopkins

Copyright Copyright 2001


*/

/*
There are many ways to change the way that objects in your scene look. You can change 
their color, how much light they reflect. You can paint them with two-dimensional images, 
or add rough textures to their surfaces. The Appearance class contains the functions for 
making these changes. This section shows you how to use these functions.

The simplest way of setting the appearance is by specifying only the color and the shading 
method. This works for setting an object to being a simple color, but to make an object 
look realistic, you need to specify how an object appears under lights. You do this by 
creating a Material.



Step                                                        Example
1. Create an object                             Sphere sphere = new Sphere();
----------------------------------------------------------------------------------
2. Create an appearance                         Appearance ap = new Appearance();
----------------------------------------------------------------------------------
3. Create a color                                Color3f col = new Color3f(0.0f, 0.0f, 1.0f);
----------------------------------------------------------------------------------
4. Create the coloring attributes               ColoringAttributes ca = new ColoringAttributes
                                                 (col, ColoringAttributes.NICEST);
----------------------------------------------------------------------------------
5. Add the attributes to the appearance         ap.setColoringAttributes(ca);
----------------------------------------------------------------------------------
6.  Set the appearance for the object             sphere.setAppearance(ap);



*/



           
       








Related examples in the same category

1.Line TypesLine Types
2.Shape: Point outlineShape: Point outline
3.Color YoyoColor Yoyo
4.Yoyo LineYoyo Line
5.The use of the GeometryInfo class and related classesThe use of the GeometryInfo class and related classes
6.Example SwitchExample Switch
7.A Morph object to animate a shape between two key shapesA Morph object to animate a shape between two key shapes
8.ExHenge - create a stone-henge like (vaguely) mysterious temple thing
9.Geometry By ReferenceGeometry By Reference
10.Stereo Girl
11.Red Green GirlRed Green Girl
12.Red Green GriffinRed Green Griffin
13.cg viewer
14.A basic hierarchical model of the top part of a human torsoA basic hierarchical model of the top part of a human torso
15.A large hollow box
16.Java 3D Box and a custom Cuboid implementationJava 3D Box and a custom Cuboid implementation
17.A simple class using the an indexed quadrilateral arrayA simple class using the an indexed quadrilateral array
18.Simple Indexed Quad NormalsSimple Indexed Quad Normals
19.Simple Indexed QuadSimple Indexed Quad
20.Twist Strip visual objectTwist Strip visual object
21.Door AppDoor App
22.ShadowApp creates a single planeShadowApp creates a single plane
23.TeapotTeapot
24.MorphingMorphing
25.VolRend
26.GouraudGouraud
27.An Object An Object