Class MatParam

java.lang.Object
com.jme3.material.MatParam
All Implemented Interfaces:
Savable, Cloneable
Direct Known Subclasses:
MatParamOverride, MatParamTexture

public class MatParam extends Object implements Savable, Cloneable
Describes a material parameter. This is used for both defining a name and type as well as a material parameter value.
  • Field Details

    • type

      protected VarType type
    • name

      protected String name
    • prefixedName

      protected String prefixedName
    • value

      protected Object value
    • typeCheck

      protected boolean typeCheck
  • Constructor Details

    • MatParam

      public MatParam(VarType type, String name, Object value)
      Create a new material parameter. For internal use only.
      Parameters:
      type - the type of the parameter
      name - the desired parameter name
      value - the desired parameter value (alias created)
    • MatParam

      protected MatParam()
      Serialization only. Do not use.
  • Method Details

    • isTypeCheckEnabled

      public boolean isTypeCheckEnabled()
    • setTypeCheckEnabled

      public void setTypeCheckEnabled(boolean v)
      Enable type check for this param. When type check is enabled a RuntimeException is thrown if an object of the wrong type is passed to setValue.
      Parameters:
      v - (default = true)
    • getVarType

      public VarType getVarType()
      Returns the material parameter type.
      Returns:
      the material parameter type.
    • getName

      public String getName()
      Returns the name of the material parameter.
      Returns:
      the name of the material parameter.
    • getPrefixedName

      public String getPrefixedName()
      Returns the name with "m_" prefixed to it.
      Returns:
      the name with "m_" prefixed to it
    • getValue

      public Object getValue()
      Returns the value of this material parameter.

      Material parameters that are used for material definitions will not have a value, unless there's a default value declared in the definition.

      Returns:
      the value of this material parameter.
    • setValue

      public void setValue(Object value)
      Sets the value of this material parameter.

      It is assumed the value is of the same type as this material parameter.

      Parameters:
      value - the value of this material parameter.
    • getValueAsString

      public String getValueAsString()
      Returns the material parameter value as it would appear in a J3M file. E.g.
       MaterialParameters {
           ABC : 1 2 3 4
       }
       
      Assuming "ABC" is a Vector4 parameter, then the value "1 2 3 4" would be returned by this method.
      Returns:
      material parameter value as it would appear in a J3M file.
    • clone

      public MatParam clone()
      Overrides:
      clone in class Object
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object