com.jme.scene.state
Class MaterialState

java.lang.Object
  extended by com.jme.scene.state.RenderState
      extended by com.jme.scene.state.MaterialState
All Implemented Interfaces:
Savable
Direct Known Subclasses:
JOGLMaterialState, LWJGLMaterialState

public abstract class MaterialState
extends RenderState

MaterialState defines a state to define an objects material settings. Material is defined by the emissive quality of the object, the ambient color, diffuse color and specular color. The material also defines the shininess of the object and the alpha value of the object.

Version:
$Id: MaterialState.java 4336 2009-05-03 20:57:01Z christoph.luder $
Author:
Mark Powell, Joshua Slack - Material Face and Performance enhancements, Three Rings - contributed color material

Nested Class Summary
static class MaterialState.ColorMaterial
           
static class MaterialState.MaterialFace
           
 
Nested classes/interfaces inherited from class com.jme.scene.state.RenderState
RenderState.StateType
 
Field Summary
protected  ColorRGBA ambient
           
protected  MaterialState.ColorMaterial colorMaterial
           
static ColorRGBA defaultAmbient
          Default ambient color for all material states.
static MaterialState.ColorMaterial defaultColorMaterial
          Default color material mode for all material states.
static ColorRGBA defaultDiffuse
          Default diffuse color for all material states.
static ColorRGBA defaultEmissive
          Default emissive color for all material states.
static MaterialState.MaterialFace defaultMaterialFace
          Default material face for all material states.
static float defaultShininess
          Default shininess for all material states.
static ColorRGBA defaultSpecular
          Default specular color for all material states.
protected  ColorRGBA diffuse
           
protected  ColorRGBA emissive
           
protected  MaterialState.MaterialFace materialFace
           
protected  float shininess
           
protected  ColorRGBA specular
           
 
Fields inherited from class com.jme.scene.state.RenderState
QUICK_COMPARE, RS_BLEND, RS_CLIP, RS_COLORMASK_STATE, RS_CULL, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
MaterialState()
          Constructor instantiates a new MaterialState object.
 
Method Summary
 ColorRGBA getAmbient()
          getAmbient retreives the ambient color of the material.
 java.lang.Class<?> getClassTag()
           
 MaterialState.ColorMaterial getColorMaterial()
          getColorMaterial retrieves the color material mode, which determines how geometry colors affect the material.
 ColorRGBA getDiffuse()
          getDiffuse retrieves the diffuse color of the material.
 ColorRGBA getEmissive()
          getEmissive retrieves the emissive color of the material.
 MaterialState.MaterialFace getMaterialFace()
          getMaterialFace retrieves the face this material state affects.
 float getShininess()
          getShininess retrieves the shininess value of the material.
 ColorRGBA getSpecular()
          getSpecular retrieves the specular color of the material.
 RenderState.StateType getStateType()
          getStateType returns the type RenderState.StateType.Material
 int getType()
          Deprecated. As of 2.0, use RenderState.getStateType() instead.
 void read(JMEImporter e)
           
 void setAmbient(ColorRGBA ambient)
          setAmbient sets the ambient color of the material.
 void setColorMaterial(MaterialState.ColorMaterial material)
          setColorMaterial sets the color material mode.
 void setDiffuse(ColorRGBA diffuse)
          setDiffuse sets the diffuse color of the material.
 void setEmissive(ColorRGBA emissive)
          setEmissive sets the emissive color of the material.
 void setMaterialFace(MaterialState.MaterialFace face)
          setMaterialFace sets the face this material state affects.
 void setShininess(float shininess)
          setShininess sets the shininess of the material.
 void setSpecular(ColorRGBA specular)
          setSpecular sets the specular color of the material.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.state.RenderState
apply, createStateRecord, extract, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultAmbient

public static final ColorRGBA defaultAmbient
Default ambient color for all material states.


defaultDiffuse

public static final ColorRGBA defaultDiffuse
Default diffuse color for all material states.


defaultSpecular

public static final ColorRGBA defaultSpecular
Default specular color for all material states.


defaultEmissive

public static final ColorRGBA defaultEmissive
Default emissive color for all material states.


defaultShininess

public static final float defaultShininess
Default shininess for all material states.

See Also:
Constant Field Values

defaultColorMaterial

public static final MaterialState.ColorMaterial defaultColorMaterial
Default color material mode for all material states.


defaultMaterialFace

public static final MaterialState.MaterialFace defaultMaterialFace
Default material face for all material states.


ambient

protected ColorRGBA ambient

diffuse

protected ColorRGBA diffuse

specular

protected ColorRGBA specular

emissive

protected ColorRGBA emissive

shininess

protected float shininess

colorMaterial

protected MaterialState.ColorMaterial colorMaterial

materialFace

protected MaterialState.MaterialFace materialFace
Constructor Detail

MaterialState

public MaterialState()
Constructor instantiates a new MaterialState object.

Method Detail

getAmbient

public ColorRGBA getAmbient()
getAmbient retreives the ambient color of the material.

Returns:
the color of the ambient value.

setAmbient

public void setAmbient(ColorRGBA ambient)
setAmbient sets the ambient color of the material.

Parameters:
ambient - the ambient color of the material.

getDiffuse

public ColorRGBA getDiffuse()
getDiffuse retrieves the diffuse color of the material.

Returns:
the color of the diffuse value.

setDiffuse

public void setDiffuse(ColorRGBA diffuse)
setDiffuse sets the diffuse color of the material.

Parameters:
diffuse - the diffuse color of the material.

getEmissive

public ColorRGBA getEmissive()
getEmissive retrieves the emissive color of the material.

Returns:
the color of the emissive value.

setEmissive

public void setEmissive(ColorRGBA emissive)
setEmissive sets the emissive color of the material.

Parameters:
emissive - the emissive color of the material.

getShininess

public float getShininess()
getShininess retrieves the shininess value of the material.

Returns:
the shininess value of the material.

setShininess

public void setShininess(float shininess)
setShininess sets the shininess of the material.

Parameters:
shininess - the shininess of the material. Must be between 0 and 128.

getSpecular

public ColorRGBA getSpecular()
getSpecular retrieves the specular color of the material.

Returns:
the specular color of the material.

setSpecular

public void setSpecular(ColorRGBA specular)
setSpecular sets the specular color of the material.

Parameters:
specular - the specular color of the material.

getColorMaterial

public MaterialState.ColorMaterial getColorMaterial()
getColorMaterial retrieves the color material mode, which determines how geometry colors affect the material.

Returns:
the color material mode

setColorMaterial

public void setColorMaterial(MaterialState.ColorMaterial material)
setColorMaterial sets the color material mode.

Parameters:
material - the color material mode
Throws:
java.lang.IllegalArgumentException - if material is null

getMaterialFace

public MaterialState.MaterialFace getMaterialFace()
getMaterialFace retrieves the face this material state affects.

Returns:
the current face setting

setMaterialFace

public void setMaterialFace(MaterialState.MaterialFace face)
setMaterialFace sets the face this material state affects.

Parameters:
face - the new face setting
Throws:
java.lang.IllegalArgumentException - if material is null

getType

public int getType()
Deprecated. As of 2.0, use RenderState.getStateType() instead.

getType returns the render state type of this. (RS_MATERIAL).

Specified by:
getType in class RenderState
Returns:
An int identifying this render state.
See Also:
RenderState.getType()

getStateType

public RenderState.StateType getStateType()
getStateType returns the type RenderState.StateType.Material

Specified by:
getStateType in class RenderState
Returns:
RenderState.StateType.Material
See Also:
RenderState.getStateType()

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class RenderState
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class RenderState
Throws:
java.io.IOException

getClassTag

public java.lang.Class<?> getClassTag()
Specified by:
getClassTag in interface Savable
Overrides:
getClassTag in class RenderState