Problems with alpha textures

I recently tried to import a tree in JME, which I created in Blender and exported as .mesh, .mesh.xml and .material.

The tree consists of different planes with a texture on them, and part of this texture is supposed to be transparent. It all works within Blender, but when I import the tree in JME, the transparent surfaces become black. Am I missing some settings?

[java]material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);[/java]

and

[java]geometry.setQueueBucket(Bucket.Transparent);[/java]

See this tutorial: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material

Is it not possible to change something in the export settings etc.? Otherwise, I would have to create the whole material and the textures in code, wouldn’t I?

pk123, did you find a solution by chance? I have the same problem, I export everything (scene included) from blender and load the scene itself in jm3 (converted into j3o), so I can’t really go through each item that need transparency by code.



thank you

@coersum said:
so I can't really go through each item that need transparency by code.


Sure you can. It might be tough to be discriminate about it, but...

[java]
myModel.setQueueBucket(Bucket.Transparent);
myModel.depthFirstTraverser( new SceneGraphVisitor() {
public void visit(Spatial spatial) {
if( spatial instanceof Geometry ) {
Material m = ((Geometry)spatial).getMaterial();
m.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
}
}
});
[/java]

Whether there is some way to get blender to export this or the importer to recognize it, I don't know. But the code to switch it isn't too bad.
@coersum said:
pk123, did you find a solution by chance? I have the same problem,


Try setting the Ogre exporter blend type to "alpha_blend" on the "Ogre Material" panel in Blender before you export.
1 Like