Class MaterialState

java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.MaterialState
All Implemented Interfaces:
Savable

public class MaterialState extends RenderState
MaterialState defines parameters used in conjunction with the lighting model to produce a surface color. Please note therefore that this state has no effect if lighting is disabled. It is also worth noting that material properties set for Front face will in fact affect both front and back unless two sided lighting is enabled.
See Also:
  • Field Details

    • DEFAULT_AMBIENT

      public static final ReadOnlyColorRGBA DEFAULT_AMBIENT
      Default ambient color for all material states. (.2, .2, .2, 1)
    • DEFAULT_DIFFUSE

      public static final ReadOnlyColorRGBA DEFAULT_DIFFUSE
      Default diffuse color for all material states. (.8, .8, .8, 1)
    • DEFAULT_SPECULAR

      public static final ReadOnlyColorRGBA DEFAULT_SPECULAR
      Default specular color for all material states. (0, 0, 0, 1)
    • DEFAULT_EMISSIVE

      public static final ReadOnlyColorRGBA DEFAULT_EMISSIVE
      Default emissive color for all material states. (0, 0, 0, 1)
    • DEFAULT_SHININESS

      public static final float DEFAULT_SHININESS
      Default shininess for all material states.
      See Also:
    • DEFAULT_COLOR_MATERIAL

      public static final MaterialState.ColorMaterial DEFAULT_COLOR_MATERIAL
      Default color material mode for all material states.
    • DEFAULT_COLOR_MATERIAL_FACE

      public static final MaterialState.MaterialFace DEFAULT_COLOR_MATERIAL_FACE
      Default color material face for all material states.
    • _frontAmbient

      protected final ColorRGBA _frontAmbient
    • _frontDiffuse

      protected final ColorRGBA _frontDiffuse
    • _frontSpecular

      protected final ColorRGBA _frontSpecular
    • _frontEmissive

      protected final ColorRGBA _frontEmissive
    • _frontShininess

      protected float _frontShininess
    • _backAmbient

      protected final ColorRGBA _backAmbient
    • _backDiffuse

      protected final ColorRGBA _backDiffuse
    • _backSpecular

      protected final ColorRGBA _backSpecular
    • _backEmissive

      protected final ColorRGBA _backEmissive
    • _backShininess

      protected float _backShininess
    • _colorMaterial

      protected MaterialState.ColorMaterial _colorMaterial
    • _colorMaterialFace

      protected MaterialState.MaterialFace _colorMaterialFace
  • Constructor Details

    • MaterialState

      public MaterialState()
      Constructor instantiates a new MaterialState object.
  • Method Details

    • getAmbient

      public ReadOnlyColorRGBA getAmbient()
      Returns:
      the ambient color (or front face color, if two sided lighting is used) of this material.
    • getBackAmbient

      public ReadOnlyColorRGBA getBackAmbient()
      Returns:
      the ambient back face color of this material. This is only used if two sided lighting is used.
    • setAmbient

      public void setAmbient(ReadOnlyColorRGBA ambient)
      Sets the ambient color for front and back to the given value.
      Parameters:
      ambient - the new ambient color
    • setAmbient

      public void setAmbient(MaterialState.MaterialFace face, ReadOnlyColorRGBA ambient)
      Parameters:
      face - the face to apply the ambient color to
      ambient - the new ambient color
    • getDiffuse

      public ReadOnlyColorRGBA getDiffuse()
      Returns:
      the diffuse color (or front face color, if two sided lighting is used) of this material.
    • getBackDiffuse

      public ReadOnlyColorRGBA getBackDiffuse()
      Returns:
      the diffuse back face color of this material. This is only used if two sided lighting is used.
    • setDiffuse

      public void setDiffuse(ReadOnlyColorRGBA diffuse)
      Sets the diffuse color for front and back to the given value.
      Parameters:
      diffuse - the new diffuse color
    • setDiffuse

      public void setDiffuse(MaterialState.MaterialFace face, ReadOnlyColorRGBA diffuse)
      Parameters:
      face - the face to apply the diffuse color to
      diffuse - the new diffuse color
    • getEmissive

      public ReadOnlyColorRGBA getEmissive()
      Returns:
      the emissive color (or front face color, if two sided lighting is used) of this material.
    • getBackEmissive

      public ReadOnlyColorRGBA getBackEmissive()
      Returns:
      the emissive back face color of this material. This is only used if two sided lighting is used.
    • setEmissive

      public void setEmissive(ReadOnlyColorRGBA emissive)
      Sets the emissive color for front and back to the given value.
      Parameters:
      emissive - the new emissive color
    • setEmissive

      public void setEmissive(MaterialState.MaterialFace face, ReadOnlyColorRGBA emissive)
      Parameters:
      face - the face to apply the emissive color to
      emissive - the new emissive color
    • getSpecular

      public ReadOnlyColorRGBA getSpecular()
      Returns:
      the specular color (or front face color, if two sided lighting is used) of this material.
    • getBackSpecular

      public ReadOnlyColorRGBA getBackSpecular()
      Returns:
      the specular back face color of this material. This is only used if two sided lighting is used.
    • setSpecular

      public void setSpecular(ReadOnlyColorRGBA specular)
      Sets the specular color for front and back to the given value.
      Parameters:
      specular - the new specular color
    • setSpecular

      public void setSpecular(MaterialState.MaterialFace face, ReadOnlyColorRGBA specular)
      Parameters:
      face - the face to apply the specular color to
      specular - the new specular color
    • getShininess

      public float getShininess()
      Returns:
      the shininess value (or front face shininess value, if two sided lighting is used) of the material.
    • getBackShininess

      public float getBackShininess()
      Returns:
      the shininess value of the back face of this material. This is only used if two sided lighting is used.
    • setShininess

      public void setShininess(float shininess)
      Sets the shininess value for front and back to the given value.
      Parameters:
      shininess - the new shininess for this material. Must be between 0 and 128. Higher numbers result in "tighter" specular reflections.
    • setShininess

      public void setShininess(MaterialState.MaterialFace face, float shininess)
      Parameters:
      face - the face to apply the shininess color to
      shininess - the new shininess for this material. Must be between 0 and 128. Higher numbers result in "tighter" specular reflections.
    • getColorMaterial

      public MaterialState.ColorMaterial getColorMaterial()
      Returns:
      the color material mode of this material, which determines how geometry colors affect the material.
      See Also:
    • setColorMaterial

      public void setColorMaterial(MaterialState.ColorMaterial material)
      Parameters:
      material - the new color material mode
      Throws:
      IllegalArgumentException - if material is null
    • getColorMaterialFace

      public MaterialState.MaterialFace getColorMaterialFace()
      Returns:
      the color material face of this material, which determines how geometry colors affect the material.
      See Also:
    • setColorMaterialFace

      public void setColorMaterialFace(MaterialState.MaterialFace face)
      Parameters:
      face - the new color material face
      Throws:
      IllegalArgumentException - if face is null
    • getType

      public RenderState.StateType getType()
      Specified by:
      getType in class RenderState
      Returns:
      An statetype enum value for the subclass.
      See Also:
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class RenderState
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class RenderState
      Throws:
      IOException
    • createStateRecord

      public StateRecord createStateRecord(ContextCapabilities caps)
      Specified by:
      createStateRecord in class RenderState