Model with transparent PNG Texture

Hi

I have a big problem rendering a tree with a PNG texture with transparent parts.



My code to render the model:

[java]

Geometry s = (Geometry)getAssetManager().loadModel(“Models/tree/tree.j3o”);

s.getMaterial().getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

s.setQueueBucket(Bucket.Transparent);

s.setLocalTranslation(100, -100,100);

s.setLocalScale(30);

rootNode.attachChild(s);

[/java]



Result without BlendMode.Alpha and Bucket.Transparent:

http://i.imgur.com/CmmCq.png



Result with BlendMode.Alpha and Bucket.Transparent:

http://i.imgur.com/zCn7a.png



I did some research about this topic but all I found was that I should set BlendMode to Alpha an the Bucket to Transparent. But when I do this all leaves (the whole texture) are rendered transparent and not only the transparent parts in the PNG.



Texture used:

http://i.imgur.com/mzuST.png



Thanks for any help!

What is the material? Do you have a light? What is the light color and/or ambient color?

My lights:

[java]

DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(-1f,-1f,-1f).normalizeLocal());

sun.setColor(ColorRGBA.White);

rootNode.addLight(sun);



AmbientLight al = new AmbientLight();

al.setColor(ColorRGBA.White.mult(1.3f));

rootNode.addLight(al);

[/java]



The material used is Lightning.j3md

The actual material is needed to help debug this, not the material definition (ie. j3md). We need the .j3m file, or the code if you create the material in code.

OK, I DID IT!



Thank you Sploreg. As you mentioned the j3m file, I realized that I do not have one.



I have converted my model this way: .blend → export from Blender as .obj/.mtl → import into jMokney SDK. jMonkey created only a j3o and a j3odata file (and the texture).

After your post I opened the j3o in the SceneComposer. In the properties panel there was something about “Material: Generate j3m file”. I clicked on it and suddenly there where 2 identical j3m files.

In the j3m file I discovered that the DiffuseMap and the AlphaMap is the same Texture. I deleted the AlphaMap line and everything is working. (I have to load the material manually now)

ah cool, glad you got it working.

@lfrst05 said:
(I have to load the material manually now)

Just apply it to the geometry in the scene composer and save the j3o.