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.
Material(boolean lightEnabled)
           
Material(boolean lightEnabled, float shininess)
           
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.
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.
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.
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.
Material(float shininess)
           
 
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()
           
 void getAmbientColor(org.openmali.vecmath2.Colorf c)
           
 org.jagatoo.opengl.enums.ColorTarget getColorTarget()
           
 Material getCopy()
          
 org.openmali.vecmath2.Colorf getDiffuseColor()
           
 void getDiffuseColor(org.openmali.vecmath2.Colorf c)
           
 org.openmali.vecmath2.Colorf getEmissiveColor()
           
 void getEmissiveColor(org.openmali.vecmath2.Colorf c)
           
 boolean getNormalizeNormals()
          Retrieves the current value of normal normalization flag
 float getShininess()
           
 org.openmali.vecmath2.Colorf getSpecularColor()
           
 void getSpecularColor(org.openmali.vecmath2.Colorf c)
           
 long getStateId()
           
 StateNode getStateNode()
           
 boolean isLightingEnabled()
           
 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)
           
 void setLightingEnabled(boolean enabled)
          Turns lighting on or off.
 void setNormalizeNormals(boolean normalizeNormals)
          Sets flag indicating the normal vecrots 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.


Material

public Material(boolean lightEnabled)

Material

public Material(boolean lightEnabled,
                float shininess)

Material

public Material(float shininess)

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.


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.


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.


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.

Method Detail

setAmbientColor

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


setAmbientColor

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

Parameters:
r -
g -
b -

getAmbientColor

public final void getAmbientColor(org.openmali.vecmath2.Colorf c)

getAmbientColor

public final org.openmali.vecmath2.Colorf getAmbientColor()
Returns:
the ambient color value.

setEmissiveColor

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

Parameters:
r -
g -
b -

setEmissiveColor

public final void setEmissiveColor(float r,
                                   float g,
                                   float b)

getEmissiveColor

public final void getEmissiveColor(org.openmali.vecmath2.Colorf c)

getEmissiveColor

public final org.openmali.vecmath2.Colorf getEmissiveColor()
Returns:
the emissive color value.

setDiffuseColor

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


setDiffuseColor

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

Parameters:
r -
g -
b -

getDiffuseColor

public final void getDiffuseColor(org.openmali.vecmath2.Colorf c)

getDiffuseColor

public final org.openmali.vecmath2.Colorf getDiffuseColor()
Returns:
the diffuse color value.

setSpecularColor

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


setSpecularColor

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

Parameters:
r -
g -
b -

getSpecularColor

public final void getSpecularColor(org.openmali.vecmath2.Colorf c)

getSpecularColor

public final org.openmali.vecmath2.Colorf getSpecularColor()
Returns:
the specular color value.

setShininess

public final void setShininess(float shininess)
Sets the shininess value.


getShininess

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

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 -

getColorTarget

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

setNormalizeNormals

public final void setNormalizeNormals(boolean normalizeNormals)
Sets flag indicating the normal vecrots 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 normal normalization flag

getNormalizeNormals

public final boolean getNormalizeNormals()
Retrieves the current value of normal normalization flag

Returns:
Normal normalization flag currently set for this material

setLightingEnabled

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


isLightingEnabled

public final boolean isLightingEnabled()
Returns:
Is lighting enabled or not.

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 -

getStateNode

public final StateNode getStateNode()
Specified by:
getStateNode in interface StateTrackable<Material>
Returns:
the id of the object. This should return -1 if there is no assigned id.

getStateId

public final long getStateId()

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