Transparency on a j3o model while retaining it's texture

I have made a model with texture in Blender, exported is as ogre mesh, and converting it to j3o in jMonkeyEngine SDK.

On other nodes/geometry i have managed to achieve transparency using a material with “Common/MatDefs/Light/Lighting.j3md” but when i do it on my j3o model it loses it’s texture.

I googled and found this but it didn’t seem to do anything:


If you’ve done it before I’m not 100% sure why it’s not working now. I’ve smacked the Oto.j3o model around with transparency before by using the diffuse alpha of it’s material.


ColorRGBA diffuse = (ColorRGBA) material.getParam(“m_Diffuse”).getValue();

diffuse.a = transparency;


Only other things I can think of is to make sure you tossed the model into the Transparent render bucket and set the material’s blendstate to alpha as usual.





Oh, I did do this too when I was doing it:


golemMaterial.setColor(“m_Diffuse”, new ColorRGBA(1, 1, 1, 1));

golemMaterial.setBoolean(“m_UseMaterialColors”, true);

golemMaterial.setBoolean(“m_UseAlpha”, true);


Probably need those too :stuck_out_tongue: Let us know how it turns out!


I’ll try that, thanks. Setting a material on my j3o model makes it lose it texture. And my other nodes/geometry doesn’t have a texture. That’s why I haven’t been able to set transparency on my j3o models. So I have not been able to use transparency on j3o models before as you seemed to think.

Is the the correct way to load a j3o model?

[java]Node playerNode = (Node) assetManager.loadModel(“Models/Player.j3o”);[/java]

I’m not sure how to get it’s material after that. playerNode.getChildren().size() returns 2. Should I change the material of those 2 childs?

I’m not 100% certain, but if that’s the case I think you can still get the material from the spatial and set parameters on it this way. No need to set a new texture to it. Pretty sure the loader defaults to using the Lighted.j3md definition so you can use the params from there.


This is my code right now

[java] playerNode = (Node) assetManager.loadModel(“Models/BallGuy.j3o”);


for(Spatial child : playerNode.getChildren()){

Material mat = ((Geometry) child).getMaterial();

((ColorRGBA) mat.getParam(“m_Diffuse”).getValue()).a = .5f;


// mat.setBoolean(“m_UseMaterialColors”, true);

mat.setBoolean(“m_UseAlpha”, true);



And my model ingame looks just the same. When i uncomment mat.setBoolean(“m_UseMaterialColors”, true); i get this exception…

[java]java.lang.ClassCastException: java.lang.Boolean cannot be cast to com.jme3.math.Quaternion

at com.jme3.renderer.lwjgl.LwjglRenderer.updateUniform(

at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderUniforms(

at com.jme3.renderer.lwjgl.LwjglRenderer.setShader(

at com.jme3.material.Material.renderMultipassLighting(

at com.jme3.material.Material.render(

at com.jme3.renderer.RenderManager.renderGeometry(

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(

at com.jme3.renderer.queue.RenderQueue.renderQueue(

at com.jme3.renderer.RenderManager.renderViewPortQueues(

at com.jme3.renderer.RenderManager.flushQueue(

at com.jme3.renderer.RenderManager.renderViewPort(

at com.jme3.renderer.RenderManager.render(


at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



Java Result: -1073741819[/java]

I managed to solve the problem in a very spooky way… I think there is a bug somewhere in jME…

This code:

[java] MatParam mp = mat.getParam(“m_UseMaterialColors”);

System.out.println(mp.getName()+", “+mp.getVarType()+”, “+mp.getValue());

MatParam mp2 = mat.getParam(“m_Diffuse”);

System.out.println(mp2.getName()+”, “+mp2.getVarType()+”, “+mp2.getValue());

MatParam mp3 = mat.getParam(“m_DiffuseMap”);

System.out.println(mp3.getName()+”, “+mp3.getVarType()+”, "+mp3.getValue());[/java]

Gives this output:

[java]m_Diffuse, Vector4, Color[0.0, 0.621177, 0.8, 1.0]

m_Specular, Vector4, Color[0.5, 0.5, 0.5, 0.5]

m_UseMaterialColors, Boolean, true[/java]

So when i ask for “m_UseMaterialColors”. It returns “m_Diffuse”… I managed to set the transparency by doing it in reverse:

[java]mat.setColor(“m_UseMaterialColors”, new ColorRGBA(0.0f, 0.621177f, 0.8f, 0.5f));[/java]

This way my character became transparent. So the keys are linked to the wrong objects. I think this explains why i got my ClassCastException that i mentioned in my last post.