I use the following code:
package de.visiongamestudios.client;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.debug.Arrow;
public class test extends SimpleApplication {
@Override
public void simpleInitApp() {
Arrow rawSpatial = new Arrow(new Vector3f(10, 0, 0));
Geometry geom = new Geometry("dummy", rawSpatial);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color ", ColorRGBA.White);
mat.getAdditionalRenderState().setLineWidth(1);
geom.setMaterial(mat);
}
public static void main(String[] args) {
new test().start();;
}
}
This crashes with:
java.lang.IllegalArgumentException: Material parameter is not defined: Color
at com.jme3.material.Material.checkSetParam(Material.java:460)
at com.jme3.material.Material.setParam(Material.java:476)
at com.jme3.material.Material.setColor(Material.java:660)
at de.visiongamestudios.client.test.simpleInitApp(test.java:19)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
at java.lang.Thread.run(Thread.java:748)
Debugging into Material
private void checkSetParam(VarType type, String name) {
MatParam paramDef = def.getMaterialParam(name);
if (paramDef == null) {
throw new IllegalArgumentException("Material parameter is not defined: " + name);
}
if (type != null && paramDef.getVarType() != type) {
logger.log(Level.WARNING, "Material parameter being set: {0} with "
+ "type {1} doesn''t match definition types {2}", new Object[]{name, type.name(), paramDef.getVarType()});
}
}
I see that paramDef is null, and thus the code is aborting.
However
def.matParams HashMap<K,V> (id=72) contains this entry:
[18] HashMap$Node<K,V> (id=129) → Color=Vector4 Color
Can anyone explain, why this is not found, as it should have the key Color in it?