Cloned materials and parameter changes

Hey again.

I’m trying to change the transparency of a single object at runtime, but I’m having some issues with cloned materials.

From what I understand, cloning an object creates an entirely new, unrelated object to the one from which it was cloned. Unfortunately it doesn’t seem to be working for my materials. I cloned a material for each object, but when I set the diffuse colour for that material, all the other objects change colour in the same way. I printed out the materials and they do have different ids, but this doesn’t seem to make a difference.

Also, is this the best way to be going about selectively changing the alpha of an object, or is there some other more efficient way?

There was an issue like that in older jME3 versions, make sure you’re using SVN/nightly.

Next, make sure you’re not setting the same reference on the material param, e.g.:


Material mat1 = …

Material mat2 = …

ColorRGBA color = new ColorRGBA(1,1,1,1);

mat1.setColor(“Color”, color);


mat2.setColor(“Color”, color);


This won’t work because the color reference is the same

Thanks for the info - the reference thing was the issue. I guess cloned materials must still reference the same colour object, so changing it changes the whole lot of them.