javax.media.j3d
Class ColoringAttributes

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.NodeComponent
          extended by javax.media.j3d.ColoringAttributes

public class ColoringAttributes
extends NodeComponent

The ColoringAttributes object defines attributes used in color selection and shading model.

Color

The setColor methods set the current intrinsic red, green, and blue color values of this ColoringAttributes component object. This color is only used for unlit geometry. If lighting is enabled, the material colors are used in the lighting equation to produce the final color. When vertex colors are present in unlit geometry, those vertex colors are used in place of this ColoringAttributes color, unless the vertex colors are ignored.

There are two variations on the setColor methods, one that takes a Color3f and one that takes three floats. No alpha value is allowed (it's automatically set to 1.0). The float values range between 0.0 and 1.0, with 1.0 being full intensity of the color. A color value of (1.0, 1.0, 1.0) is white.

Shading Model

The setShadeModel method sets the shade model for this ColoringAttributes component object. The shade model may be one of the following:

See Also:
Appearance

Field Summary
static int ALLOW_COLOR_READ
          Specifies that this ColoringAttributes object allows reading its color component information.
static int ALLOW_COLOR_WRITE
          Specifies that this ColoringAttributes object allows writing its color component information.
static int ALLOW_SHADE_MODEL_READ
          Specifies that this ColoringAttributes object allows reading its shade model component information.
static int ALLOW_SHADE_MODEL_WRITE
          Specifies that this ColoringAttributes object allows writing its shade model component information.
static int FASTEST
          Use the fastest available method for shading.
static int NICEST
          Use the nicest available method for shading.
private static int[] readCapabilities
           
static int SHADE_FLAT
          Do not interpolate color across the primitive.
static int SHADE_GOURAUD
          Smoothly interpolate the color at each vertex across the primitive.
 
Fields inherited from class javax.media.j3d.NodeComponent
forceDuplicate
 
Fields inherited from class javax.media.j3d.SceneGraphObject
nodeHashtable, retained
 
Constructor Summary
ColoringAttributes()
          Constructs a ColoringAttributes node with default parameters.
ColoringAttributes(Color3f color, int shadeModel)
          Construct ColoringAttributes object with specified values.
ColoringAttributes(float red, float green, float blue, int shadeModel)
          Construct ColoringAttributes object with specified values.
 
Method Summary
 NodeComponent cloneNodeComponent()
          Deprecated. replaced with cloneNodeComponent(boolean forceDuplicate)
(package private)  void createRetained()
          Creates a retained mode ColoringAttributesRetained object that this ColoringAttributes component object will point to.
(package private)  void duplicateAttributes(NodeComponent originalNodeComponent, boolean forceDuplicate)
          Copies all node information from originalNodeComponent into the current node.
 void getColor(Color3f color)
          Gets the intrinsic color of this ColoringAttributes component object.
 int getShadeModel()
          Gets the shade mode for this ColoringAttributes component object.
 void setColor(Color3f color)
          Sets the intrinsic color of this ColoringAttributes component object.
 void setColor(float r, float g, float b)
          Sets the intrinsic color of this ColoringAttributes component object.
 void setShadeModel(int shadeModel)
          Sets the shade mode for this ColoringAttributes component object.
 java.lang.String toString()
          Returns a String representation of this ColoringAttributes object.
 
Methods inherited from class javax.media.j3d.NodeComponent
checkDuplicateNodeComponent, cloneNodeComponent, duplicateChild, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree, validateImageIllegalSharing
 
Methods inherited from class javax.media.j3d.SceneGraphObject
capabilityBitsEmpty, checkForLiveOrCompiled, clearCapability, clearCapabilityIsFrequent, clearLive, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getNamePrefix, getNodeComponent, getUserData, isCompiled, isLive, isLiveOrCompiled, setCapability, setCapabilityIsFrequent, setCompiled, setDefaultReadCapabilities, setLive, setName, setUserData, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALLOW_COLOR_READ

public static final int ALLOW_COLOR_READ
Specifies that this ColoringAttributes object allows reading its color component information.

See Also:
Constant Field Values

ALLOW_COLOR_WRITE

public static final int ALLOW_COLOR_WRITE
Specifies that this ColoringAttributes object allows writing its color component information.

See Also:
Constant Field Values

ALLOW_SHADE_MODEL_READ

public static final int ALLOW_SHADE_MODEL_READ
Specifies that this ColoringAttributes object allows reading its shade model component information.

See Also:
Constant Field Values

ALLOW_SHADE_MODEL_WRITE

public static final int ALLOW_SHADE_MODEL_WRITE
Specifies that this ColoringAttributes object allows writing its shade model component information.

See Also:
Constant Field Values

FASTEST

public static final int FASTEST
Use the fastest available method for shading.

See Also:
Constant Field Values

NICEST

public static final int NICEST
Use the nicest available method for shading.

See Also:
Constant Field Values

SHADE_FLAT

public static final int SHADE_FLAT
Do not interpolate color across the primitive.

See Also:
Constant Field Values

SHADE_GOURAUD

public static final int SHADE_GOURAUD
Smoothly interpolate the color at each vertex across the primitive.

See Also:
Constant Field Values

readCapabilities

private static final int[] readCapabilities
Constructor Detail

ColoringAttributes

public ColoringAttributes()
Constructs a ColoringAttributes node with default parameters. The default values are as follows:


ColoringAttributes

public ColoringAttributes(Color3f color,
                          int shadeModel)
Construct ColoringAttributes object with specified values.

Parameters:
color - the intrisic color
shadeModel - the shade model used; one of FASTEST, NICEST, SHADE_FLAT, or SHADE_GOURAUD

ColoringAttributes

public ColoringAttributes(float red,
                          float green,
                          float blue,
                          int shadeModel)
Construct ColoringAttributes object with specified values.

Parameters:
red - red component of the intrisic color
green - green component of the intrisic color
blue - blue component of the intrisic color
shadeModel - the shade model used; one of FASTEST, NICEST, SHADE_FLAT, or SHADE_GOURAUD
Method Detail

setColor

public void setColor(Color3f color)
Sets the intrinsic color of this ColoringAttributes component object. This color is only used for unlit geometry; if lighting is enabled, then the material colors are used in the lighting equation to produce the final color. When vertex colors are present in unlit geometry, those vertex colors are used in place of this ColoringAttributes color unless the vertex colors are ignored.

Parameters:
color - the color that is used when lighting is disabled or when material is null
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
See Also:
Material, RenderingAttributes.setIgnoreVertexColors(boolean)

setColor

public void setColor(float r,
                     float g,
                     float b)
Sets the intrinsic color of this ColoringAttributes component object. This color is only used for unlit geometry; if lighting is enabled, then the material colors are used in the lighting equation to produce the final color. When vertex colors are present in unlit geometry, those vertex colors are used in place of this ColoringAttributes color unless the vertex colors are ignored.

Parameters:
r - the red component of the color
g - the green component of the color
b - the blue component of the color
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph
See Also:
Material, RenderingAttributes.setIgnoreVertexColors(boolean)

getColor

public void getColor(Color3f color)
Gets the intrinsic color of this ColoringAttributes component object.

Parameters:
color - the vector that will receive color
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

setShadeModel

public void setShadeModel(int shadeModel)
Sets the shade mode for this ColoringAttributes component object.

Parameters:
shadeModel - the shade mode to be used; one of FASTEST, NICEST, SHADE_FLAT, or SHADE_GOURAUD
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

getShadeModel

public int getShadeModel()
Gets the shade mode for this ColoringAttributes component object.

Returns:
shadeModel the shade mode
Throws:
CapabilityNotSetException - if appropriate capability is not set and this object is part of live or compiled scene graph

createRetained

void createRetained()
Creates a retained mode ColoringAttributesRetained object that this ColoringAttributes component object will point to.

Overrides:
createRetained in class NodeComponent

cloneNodeComponent

public NodeComponent cloneNodeComponent()
Deprecated. replaced with cloneNodeComponent(boolean forceDuplicate)

Overrides:
cloneNodeComponent in class NodeComponent

duplicateAttributes

void duplicateAttributes(NodeComponent originalNodeComponent,
                         boolean forceDuplicate)
Copies all node information from originalNodeComponent into the current node. This method is called from the duplicateNode method. This routine does the actual duplication of all "local data" (any data defined in this object).

Overrides:
duplicateAttributes in class NodeComponent
Parameters:
originalNodeComponent - the original node to duplicate.
forceDuplicate - when set to true, causes the duplicateOnCloneTree flag to be ignored. When false, the value of each node's duplicateOnCloneTree variable determines whether NodeComponent data is duplicated or copied.
See Also:
Node.cloneTree(), NodeComponent.setDuplicateOnCloneTree(boolean)

toString

public java.lang.String toString()
Returns a String representation of this ColoringAttributes object. If the scene graph is live only those values with their Capability read bit set will be displayed.

Overrides:
toString in class SceneGraphObject


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.