public final class MatParamOverride extends MatParam
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.
name, prefixedName, type, value| Modifier | Constructor and Description |
|---|---|
protected |
MatParamOverride()
Serialization only.
|
|
MatParamOverride(VarType type,
java.lang.String name,
java.lang.Object value)
Create a new
MatParamOverride. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
boolean |
isEnabled()
Determine if the
MatParamOverride is enabled or disabled. |
void |
read(JmeImporter im) |
void |
setEnabled(boolean enabled)
Enable or disable this
MatParamOverride. |
void |
write(JmeExporter ex) |
clone, getName, getPrefixedName, getValue, getValueAsString, getVarType, setValue, toStringprotected MatParamOverride()
public MatParamOverride(VarType type, java.lang.String name, java.lang.Object value)
MatParamOverride.
Overrides are created enabled by default.type - The type of parameter.name - The name of the parameter.value - The value to set the material parameter to.public boolean isEnabled()
MatParamOverride is enabled or disabled.setEnabled(boolean)public void setEnabled(boolean enabled)
MatParamOverride.
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.enabled - Whether to enable or disable this override.public void write(JmeExporter ex) throws java.io.IOException
public void read(JmeImporter im) throws java.io.IOException