Changing the color of spatials imported from Blender

Hello, this is my first post on Jmonkey. I have a small issue I don’t know how to solve it.

I import objects from blender (.obj) composed of two material. I want to be able to control their colors (which is say blue by default in blender) from Jme. Is this possible?

ALso, I want to so the same thing by printing text on these spatials (stats and other indicators), is that possible?

If so, how do I go about doing that?


1 Like

I believe that this is possible… I am a noob at models also, but I saw a good tutorial on workflow here. About the text, I would just make a custom texture for each sentence, and just apply it (assuming you have a small list of phrases). I hope this helps, coming from a noob…


The unshaded material exposes the “Color” property while the lighting material exposes “diffuse, ambient, specular” you can change those colors.

could you please provide a code sample? or maybe a reference?

great question! I actually could use this too, and same issue having objects from blender needing to modify their colors.

Can you guys be more specific?

1 Like

as i good understand Momoko_Fan wanted you to set loaded objects default unshaded material with diffrent color

examples here:[]=unshaded

simple example:

[java]Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

mat.setColor("Color", ColorRGBA.Blue);

// and apply it to object


or just apply such material to j3o model(if you use j3o - if ogre loader / .obj loader, then upper code)

materials are defined in loader plugins… just modify if needed(you can add color override):

for obj:

欧美Av色爱综合网欧美Av,亚洲 欧洲 日韩 av综合,亚洲 自拍色综合图区

[java] if (material == null){

// create default material

material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

material.setFloat("Shininess", 64);


(if i quoted a good fragment)








1 Like

Thank you guys! works great!

Guys sorry to come back to this topic but if I am reading a file and trying to get the color from it the color is read in the file as a String (e.g. black, white, etc)

how can I change my changeColor function to be able to convert the string as a ColorRGBA, I read the documentation and there’s a toString() but not the opposite.

my current function is:

[java] public void changeColor(String color, String spatialId) {

Spatial spatialToColor = rootNode.getChild(spatialId);

Material material = new Material(assetManager,


material.setColor(“Color”, >>> HOW TO CONVERT string to a ColorRGBA<<<<); <<<< issue here




thanks guys

how about u use a hashmap?

[java]/** Function that attaches the drive commands we want to use

  • the more motion states we add we simply add it here and
  • create a separate class for it. */

    private void attachColors(HashMap<String, ColorRGBA> hm2) {

    hm2.put("black", ColorRGBA.Black);

    hm2.put("blue", ColorRGBA.Blue);

    hm2.put("brown", ColorRGBA.Brown);

    hm2.put("cyan", ColorRGBA.Cyan);

    hm2.put("green", ColorRGBA.Green);

    hm2.put("orange", ColorRGBA.Orange ); // which is also decelerate

    hm2.put("red", ColorRGBA.Red);

    hm2.put("white", ColorRGBA.White);

    hm2.put("pink", ColorRGBA.Pink);

    hm2.put("yellow", ColorRGBA.Yellow);

    hm2.put("magenta", ColorRGBA.Magenta);

    // TODO: add the rest of the colors here


1 Like