Appearance Example Code

Create an Appearance node, then set one or more of its attribute components

Most of the following example are detailed... there are shorter way to do by using constructors !

Appearance app = new Appearance( ); 


// Coloring Attributes
// Intrinsic color, Gouraud shading 
ColoringAttributes ca = new ColoringAttributes( );
ca.setColor( 1.0f, 1.0f, 0.0f );
ca.setShadeModel( ColoringAttributes.SHADE_GOURAUD );
app.setColoringAttributes( ca ); //Material Attributes //Ambient, emissive, diffuse, and specular colors
Material mat = new Material( );
mat.setAmbientColor( 0.3f, 0.3f, 0.3f );
mat.setDiffuseColor( 1.0f, 0.0f, 0.0f );
mat.setEmissiveColor( 0.0f, 0.0f, 0.0f );
mat.setSpecularColor( 1.0f, 1.0f, 1.0f );
mat.setShininess( 80.0f );
app.setMaterial( mat ); // Transparency Attributes // Semi-transparent, alpha-blended
TransparencyAttributes ta = new TransparencyAttributes( );
ta.setTransparency( 0.5f );
ta.setTransparencyMode( TransparencyAttributes.BLENDED );
app.setTransparencyAttributes( ta ); // Point Attributes // 10 pixel points, not anti-aliased
PointAttributes pta = new PointAttributes( ); pta.setPointSize( 10.0f );
pta.setPointAntialiasingEnable( false );
app.setPointAttributes( pta ); // Line Attributes // 10 pixel lines, solid, not anti-aliased LineAttributes lta = new LineAttributes( ); lta.setLineWidth( 10.0f ); lta.setLineAntialiasingEnable( false ); lta.setLinePattern( LineAttributes.PATTERN_SOLID ); app.setLineAttributes( lta ); // Polygon Attributes // Filled polygons, front and back faces
PolygonAttributes pa = new PolygonAttributes( );
pa.setPolygonMode( PolygonAttributes.POLYGON_FILL );
pa.setCullFace( PolygonAttributes.CULL_NONE );
app.setPolygonAttributes( pa );