Package com.jme3.material
Class MatParamOverride
java.lang.Object
com.jme3.material.MatParam
com.jme3.material.MatParamOverride
MatParamOverride
is a mechanism by which
material parameters
can be overridden on the scene graph.
A scene branch which has a MatParamOverride
applied to it will
cause all material parameters with the same name and type to have their value
replaced with the value set on the MatParamOverride
. If those
parameters are mapped to a define, then the define will be overridden as well
using the same rules as the ones used for regular material parameters.
MatParamOverrides
are applied to a Spatial
via the
Spatial.addMatParamOverride(com.jme3.material.MatParamOverride)
method. They are propagated to child Spatials
via
Spatial.updateGeometricState()
similar to how lights are propagated.
Example:
Geometry box = new Geometry("Box", new Box(1,1,1));
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
box.setMaterial(mat);
rootNode.attachChild(box);
// ... later ...
MatParamOverride override = new MatParamOverride(Type.Vector4, "Color", ColorRGBA.Red);
rootNode.addMatParamOverride(override);
// After adding the override to the root node, the box becomes red.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Serialization only.MatParamOverride
(VarType type, String name, Object value) Create a newMatParamOverride
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
boolean
Determine if theMatParamOverride
is enabled or disabled.void
read
(JmeImporter im) void
setEnabled
(boolean enabled) Enable or disable thisMatParamOverride
.void
write
(JmeExporter ex) Methods inherited from class com.jme3.material.MatParam
clone, getName, getPrefixedName, getValue, getValueAsString, getVarType, isTypeCheckEnabled, setTypeCheckEnabled, setValue, toString
-
Constructor Details
-
MatParamOverride
protected MatParamOverride()Serialization only. Do not use. -
MatParamOverride
Create a newMatParamOverride
. Overrides are created enabled by default.- Parameters:
type
- The type of parameter.name
- The name of the parameter.value
- The value to set the material parameter to.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
isEnabled
public boolean isEnabled()Determine if theMatParamOverride
is enabled or disabled.- Returns:
- true if enabled, false if disabled.
- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Enable or disable thisMatParamOverride
. When disabled, the override will continue to propagate through the scene graph like before, but it will have no effect on materials. Overrides are enabled by default.- Parameters:
enabled
- Whether to enable or disable this override.
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classMatParam
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classMatParam
- Throws:
IOException
-