Hello all,
I am trying to have a model transition from its normal textured color to red. I was going to try doing this by creating a new material and reapplying it to the model every frame. Seems kinda slow to do it that way, but Im not really sure of another way (im a new to this).
Anyways, I was trying it and I keep getting the following error:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Material parameter is not defined: ColorMap
at com.jme3.material.Material.checkSetParam(Material.java:250)
at com.jme3.material.Material.setTextureParam(Material.java:281)
at com.jme3.material.Material.setTexture(Material.java:321)
at mygame.DogVisualization.Update(DogVisualization.java:66)
at mygame.Main.simpleUpdate(Main.java:69)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:208)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:141)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:198)
at java.lang.Thread.run(Thread.java:662)
The code that is running when I get this error is:
if(this.currentColor != this.changeToColor)
{
//must change color to next phase in colors.
Texture ninjaTexture = assetManager.loadTexture(“Models/Ninja/Ninja.jpg”);
//Material newMat = new Material(assetManager, “Models/Ninja/Ninja.material”);
Material newMat = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);
newMat.setTexture(“ColorMap”,ninjaTexture); <
line 66, the problem line
newMat.setColor("Color", new ColorRGBA(1.0f,0.0f,0.0f,0.5f));
this.currentColor = this.changeToColor;
}
Anybody know whats going wrong? Thanks for any advise. I would also be interested in more run-time friendly ways of doing this, than reloading the texture everytime, I was hoping there was a way to get the material from the model and then just set the color, and then reapply it without having to touch the assetManager.
Here is the code used for initially loading the model:
dogModel = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
dogModel.scale(0.028f, 0.028f, 0.028f);
dogModel.rotate(0.0f, -3.0f, 0.0f);
dogModel.setLocalTranslation(0.0f, -2.5f, -2.0f);
THe ninja is just a stand in for now, to be replaced soon.
Thanks again,
~David