org.xith3d.scenegraph
Class Material

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.NodeComponent
          extended by org.xith3d.scenegraph.Material
All Implemented Interfaces:
java.lang.Comparable<Material>, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, StateTrackable<Material>

public class Material
extends NodeComponent
implements StateTrackable<Material>

The Material object defines the appearance of an object under illumination. If the Material object in an Appearance object is null, lighting is disabled for all nodes that use that Appearance object. The properties that can be set for a Material object are:

The Material object also enables or disables lighting.


Field Summary
static org.jagatoo.opengl.enums.ColorTarget AMBIENT
           
static org.jagatoo.opengl.enums.ColorTarget AMBIENT_AND_DIFFUSE
           
static org.jagatoo.opengl.enums.ColorTarget DIFFUSE
           
static org.jagatoo.opengl.enums.ColorTarget EMISSIVE
           
static org.jagatoo.opengl.enums.ColorTarget NONE
           
static org.jagatoo.opengl.enums.ColorTarget SPECULAR
           
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
Material()
          Constructs a new Material object with default values.
Material(boolean lightEnabled)
          Constructs a new Material object with lighting enabled or not.
Material(boolean lightEnabled, float shininess)
          Constructs a new Material object with light enabled or not and setting the shininess value.
Material(org.openmali.vecmath2.Colorf ambientColor, org.openmali.vecmath2.Colorf emissiveColor, org.openmali.vecmath2.Colorf diffuseColor, org.openmali.vecmath2.Colorf specularColor, float shininess)
          Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time.
Material(org.openmali.vecmath2.Colorf ambientColor, org.openmali.vecmath2.Colorf emissiveColor, org.openmali.vecmath2.Colorf diffuseColor, org.openmali.vecmath2.Colorf specularColor, float shininess, boolean lightingEnabled)
          Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time.
Material(org.openmali.vecmath2.Colorf ambientColor, org.openmali.vecmath2.Colorf emissiveColor, org.openmali.vecmath2.Colorf diffuseColor, org.openmali.vecmath2.Colorf specularColor, float shininess, org.jagatoo.opengl.enums.ColorTarget colorTarget, boolean lightingEnabled)
          Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time.
Material(org.openmali.vecmath2.Colorf ambientColor, org.openmali.vecmath2.Colorf emissiveColor, org.openmali.vecmath2.Colorf diffuseColor, org.openmali.vecmath2.Colorf specularColor, float shininess, org.jagatoo.opengl.enums.ColorTarget colorTarget, boolean normalizeNormals, boolean lightingEnabled)
          Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time.
Material(float shininess)
          Constructs a new Material object and also setting the shininess value.
 
Method Summary
 Material cloneNodeComponent(boolean forceDuplicate)
          
 int compareTo(Material o)
          
protected  void duplicateNodeComponent(NodeComponent original, boolean forceDuplicate)
          
 boolean equals(java.lang.Object o)
          
 void freeOpenGLResources(CanvasPeer canvasPeer)
          This method frees OpenGL resources (names) for all this NodeComponent and all child-components.
 org.openmali.vecmath2.Colorf getAmbientColor()
          Returns the current ambient color for this material.
 void getAmbientColor(org.openmali.vecmath2.Colorf color)
          Gets the current ambient color for this material.
 org.jagatoo.opengl.enums.ColorTarget getColorTarget()
          Returns the current ColorTarget for this material.
 Material getCopy()
          
 org.openmali.vecmath2.Colorf getDiffuseColor()
          Returns the current diffuse color for this material.
 void getDiffuseColor(org.openmali.vecmath2.Colorf color)
          Gets the current diffuse color for this material.
 org.openmali.vecmath2.Colorf getEmissiveColor()
          Returns the current emissive color for this material.
 void getEmissiveColor(org.openmali.vecmath2.Colorf color)
          Gets the current emissive color for this material.
 boolean getNormalizeNormals()
          Returns the current value of normals normalization flag.
 float getShininess()
          Returns the current shininess value.
 org.openmali.vecmath2.Colorf getSpecularColor()
          Returns the current specular color for this material.
 void getSpecularColor(org.openmali.vecmath2.Colorf color)
          Gets the current specular color for this material.
 long getStateId()
          Returns the current state id of the object.
 StateNode getStateNode()
          Returns the current state node of the object.
 boolean isLightingEnabled()
          Returns a flag whether the lighting is enabled or not.
 void setAmbientColor(org.openmali.vecmath2.Colorf color)
          Sets the ambient color value.
 void setAmbientColor(float r, float g, float b)
          Sets the ambient color value.
 void setColorTarget(org.jagatoo.opengl.enums.ColorTarget colorTarget)
          Sets the color target for per-vertex colors.
 void setDiffuseColor(org.openmali.vecmath2.Colorf color)
          Sets the diffuse color value.
 void setDiffuseColor(float r, float g, float b)
          Sets the diffuse color value.
 void setEmissiveColor(org.openmali.vecmath2.Colorf color)
          Sets the emissive color value.
 void setEmissiveColor(float r, float g, float b)
          Sets the emissive color value.
 void setLightingEnabled(boolean enabled)
          Turns lighting on or off.
 void setNormalizeNormals(boolean normalizeNormals)
          Sets flag indicating the normal vectors should be normalized after transformations applied.
 void setShininess(float shininess)
          Sets the shininess value.
 void setSpecularColor(org.openmali.vecmath2.Colorf color)
          Sets the specular color value.
 void setSpecularColor(float r, float g, float b)
          Sets the specular color value.
 void setStateNode(StateNode stateNode)
          Used by the render engine to set the state id for the node.
 java.lang.String toString()
          
 
Methods inherited from class org.xith3d.scenegraph.NodeComponent
freeOpenGLResources, getDuplicateOnCloneTree, getModListener, isChanged, isChanged2, setChanged, setDuplicateOnCloneTree, setModListener
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final org.jagatoo.opengl.enums.ColorTarget NONE
See Also:
ColorTarget.NONE

AMBIENT

public static final org.jagatoo.opengl.enums.ColorTarget AMBIENT
See Also:
ColorTarget.AMBIENT

EMISSIVE

public static final org.jagatoo.opengl.enums.ColorTarget EMISSIVE
See Also:
ColorTarget.EMISSIVE

DIFFUSE

public static final org.jagatoo.opengl.enums.ColorTarget DIFFUSE
See Also:
ColorTarget.DIFFUSE

SPECULAR

public static final org.jagatoo.opengl.enums.ColorTarget SPECULAR
See Also:
ColorTarget.SPECULAR

AMBIENT_AND_DIFFUSE

public static final org.jagatoo.opengl.enums.ColorTarget AMBIENT_AND_DIFFUSE
See Also:
ColorTarget.AMBIENT_AND_DIFFUSE
Constructor Detail

Material

public Material()
Constructs a new Material object with default values.


Material

public Material(boolean lightEnabled)
Constructs a new Material object with lighting enabled or not.

Parameters:
lightEnabled - true to enable lighting, false to disable

Material

public Material(boolean lightEnabled,
                float shininess)
Constructs a new Material object with light enabled or not and setting the shininess value.

Parameters:
lightEnabled - true to enable light, false to disable
shininess - The shininess value to use

Material

public Material(float shininess)
Constructs a new Material object and also setting the shininess value.

Parameters:
shininess - The shininess value to use

Material

public Material(org.openmali.vecmath2.Colorf ambientColor,
                org.openmali.vecmath2.Colorf emissiveColor,
                org.openmali.vecmath2.Colorf diffuseColor,
                org.openmali.vecmath2.Colorf specularColor,
                float shininess)
Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time. Also sets the shinininess value.

Parameters:
ambientColor - The ambient color to use
emissiveColor - The emissive color to use
diffuseColor - The diffuse color to use
specularColor - The specular color to use
shininess - the shininess value to set

Material

public Material(org.openmali.vecmath2.Colorf ambientColor,
                org.openmali.vecmath2.Colorf emissiveColor,
                org.openmali.vecmath2.Colorf diffuseColor,
                org.openmali.vecmath2.Colorf specularColor,
                float shininess,
                boolean lightingEnabled)
Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time. Also sets the shinininess value and turns on/off the lighting.

Parameters:
ambientColor - The ambient color to use
emissiveColor - The emissive color to use
diffuseColor - The diffuse color to use
specularColor - The specular color to use
shininess - The shininess value to set
lightingEnabled - true to turn on lighting, false to turn off

Material

public Material(org.openmali.vecmath2.Colorf ambientColor,
                org.openmali.vecmath2.Colorf emissiveColor,
                org.openmali.vecmath2.Colorf diffuseColor,
                org.openmali.vecmath2.Colorf specularColor,
                float shininess,
                org.jagatoo.opengl.enums.ColorTarget colorTarget,
                boolean lightingEnabled)
Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time. Also sets the shinininess value, the color target value and turns on/off the lighting.

Parameters:
ambientColor - The ambient color to use
emissiveColor - The emissive color to use
diffuseColor - The diffuse color to use
specularColor - The specular color to use
shininess - The shininess value to set
colorTarget - The color target value to set
lightingEnabled - true to turn on lighting, false to turn off

Material

public Material(org.openmali.vecmath2.Colorf ambientColor,
                org.openmali.vecmath2.Colorf emissiveColor,
                org.openmali.vecmath2.Colorf diffuseColor,
                org.openmali.vecmath2.Colorf specularColor,
                float shininess,
                org.jagatoo.opengl.enums.ColorTarget colorTarget,
                boolean normalizeNormals,
                boolean lightingEnabled)
Constructs a new Material object setting the ambient, emissive, diffuse and specular colors at the same time. Also sets the shinininess value, the color target value, whether to normalize and turns on/off the lighting.

Parameters:
ambientColor - The ambient color to use
emissiveColor - The emissive color to use
diffuseColor - The diffuse color to use
specularColor - The specular color to use
shininess - The shininess value to set
colorTarget - The color target value to set
normalizeNormals - true to normalize, false otherwise
lightingEnabled - true to turn on lighting, false to turn off
Method Detail

setAmbientColor

public final void setAmbientColor(org.openmali.vecmath2.Colorf color)
Sets the ambient color value.

Parameters:
color - the ambient color to use

setAmbientColor

public final void setAmbientColor(float r,
                                  float g,
                                  float b)
Sets the ambient color value.

Parameters:
r - the red element of the color to use
g - the green element of the color to use
b - the blue element of the color to use

getAmbientColor

public final void getAmbientColor(org.openmali.vecmath2.Colorf color)
Gets the current ambient color for this material.

Parameters:
color - the color to set to the current ambient color

getAmbientColor

public final org.openmali.vecmath2.Colorf getAmbientColor()
Returns the current ambient color for this material.

Returns:
the ambient color.

setEmissiveColor

public final void setEmissiveColor(org.openmali.vecmath2.Colorf color)
Sets the emissive color value.

Parameters:
color - the emissive color to use

setEmissiveColor

public final void setEmissiveColor(float r,
                                   float g,
                                   float b)
Sets the emissive color value.

Parameters:
r - the red element of the color to use
g - the green element of the color to use
b - the blue element of the color to use

getEmissiveColor

public final void getEmissiveColor(org.openmali.vecmath2.Colorf color)
Gets the current emissive color for this material.

Parameters:
color - the color to set to the current emissive color

getEmissiveColor

public final org.openmali.vecmath2.Colorf getEmissiveColor()
Returns the current emissive color for this material.

Returns:
the emissive color.

setDiffuseColor

public final void setDiffuseColor(org.openmali.vecmath2.Colorf color)
Sets the diffuse color value.

Parameters:
color - the diffuse color to use

setDiffuseColor

public final void setDiffuseColor(float r,
                                  float g,
                                  float b)
Sets the diffuse color value.

Parameters:
r - the red element of the color to use
g - the green element of the color to use
b - the blue element of the color to use

getDiffuseColor

public final void getDiffuseColor(org.openmali.vecmath2.Colorf color)
Gets the current diffuse color for this material.

Parameters:
color - the color to set to the current diffuse color

getDiffuseColor

public final org.openmali.vecmath2.Colorf getDiffuseColor()
Returns the current diffuse color for this material.

Returns:
the diffuse color.

setSpecularColor

public final void setSpecularColor(org.openmali.vecmath2.Colorf color)
Sets the specular color value.

Parameters:
color - the specular color to use

setSpecularColor

public final void setSpecularColor(float r,
                                   float g,
                                   float b)
Sets the specular color value.

Parameters:
r - the red element of the color to use
g - the green element of the color to use
b - the blue element of the color to use

getSpecularColor

public final void getSpecularColor(org.openmali.vecmath2.Colorf color)
Gets the current specular color for this material.

Parameters:
color - the color to set to the current specular color

getSpecularColor

public final org.openmali.vecmath2.Colorf getSpecularColor()
Returns the current specular color for this material.

Returns:
the specular color.

setShininess

public final void setShininess(float shininess)
Sets the shininess value. This value must be in the interval [0, 128].

Parameters:
shininess - the shininess value to set

getShininess

public final float getShininess()
Returns the current shininess value.

Returns:
the shininess value between 0 and 128.

setColorTarget

public final void setColorTarget(org.jagatoo.opengl.enums.ColorTarget colorTarget)
Sets the color target for per-vertex colors. When lighting is enabled and per-vertex colors are present (and not ignored) in the geometry for a given Shape3D node, those per-vertex colors are used in place of the specified material color(s) for this Material object. If no per-vertex colors are present in geometry, color from ColoringAttributes used in place of per-vertex colors and will substitute the material color specified by color target. The color target is ignored when lighting is disabled. The default target is NONE, which causes only colors from this Material to be used for lighting calculations.

Parameters:
colorTarget - the ColorTarget to set

getColorTarget

public final org.jagatoo.opengl.enums.ColorTarget getColorTarget()
Returns the current ColorTarget for this material.

Returns:
the used ColorTarget.

setNormalizeNormals

public final void setNormalizeNormals(boolean normalizeNormals)
Sets flag indicating the normal vectors should be normalized after transformations applied. Normals specified in the shape geomerty need not have unit length. If normalization is enabled, then normals are normalized after transformation. By default, normalization is enabled.

Parameters:
normalizeNormals - new value for normals normalization flag

getNormalizeNormals

public final boolean getNormalizeNormals()
Returns the current value of normals normalization flag.

Returns:
Normals normalization flag currently set for this material.

setLightingEnabled

public final void setLightingEnabled(boolean enabled)
Turns lighting on or off.

Parameters:
enabled - true to turn on, false to turn off

isLightingEnabled

public final boolean isLightingEnabled()
Returns a flag whether the lighting is enabled or not.

Returns:
true if on, false if off

setStateNode

public final void setStateNode(StateNode stateNode)
Used by the render engine to set the state id for the node.

Specified by:
setStateNode in interface StateTrackable<Material>
Parameters:
stateNode - The StateNode to set

getStateNode

public final StateNode getStateNode()
Returns the current state node of the object.

Specified by:
getStateNode in interface StateTrackable<Material>
Returns:
The StateNode of the object.

getStateId

public final long getStateId()
Returns the current state id of the object.

Returns:
The state id of the object. This should return -1 if there is no assigned id.

getCopy

public Material getCopy()

Specified by:
getCopy in interface StateTrackable<Material>
Returns:
a copy of the state of the referenced trackable object.

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(Material o)

Specified by:
compareTo in interface java.lang.Comparable<Material>

duplicateNodeComponent

protected void duplicateNodeComponent(NodeComponent original,
                                      boolean forceDuplicate)

Overrides:
duplicateNodeComponent in class NodeComponent

cloneNodeComponent

public Material cloneNodeComponent(boolean forceDuplicate)

Specified by:
cloneNodeComponent in class NodeComponent

freeOpenGLResources

public void freeOpenGLResources(CanvasPeer canvasPeer)
This method frees OpenGL resources (names) for all this NodeComponent and all child-components.

Specified by:
freeOpenGLResources in class NodeComponent

toString

public java.lang.String toString()

Overrides:
toString in class SceneGraphObject