You wanted to see the code. Here is it (I tried to remove unimportant stuff, because then it would be even more, the code is from my terrain-loader. It splits the terrain in many different pieces).
I marked the areas bold, where I set Transparency Attributes , cause I believe there could lie the problem)
// g is the Geometry
for(int i = 0; i < texTypeSplit.length; i++) {
System.out.println("----------------------------- "+ i);
AppearanceResult res = getAppearance(texTypeSplit[i], x, y, x+SEGMENT_LENGTH, y+SEGMENT_WIDTH);
if(res != null) {
Shape3D shape = new Shape3D(g,res.getAppearance());
og.addChild(shape);
}
}
public AppearanceResult getappearance(String type, int start_x, int start_y, int end_x, int end_y) {
....
Texture tiles = texloader.loadTexture(tilePath,"RGB",true,Texture.BASE_LEVEL,Texture.BASE_LEVEL_LINEAR,Texture.WRAP);
states[0] = new TextureUnitState();
states[0].setTexture(tiles);
TextureAttributes texAttrib = new TextureAttributes();
texAttrib.setTextureMode(TextureAttributes.DECAL);
states[0].setTextureAttributes(texAttrib);
if(checkoutBelow) { // For the purely opaque level at the ground, I don't have an alpha layer, so I skip setting the alpha
Texture alphamap = texloader.getMinMapAlphaTexture(alphaPath);
states[1] = new TextureUnitState();
states[1].setTexture(alphamap);
TextureAttributes alphaAttrib = new TextureAttributes();
alphaAttrib.setTextureMode(TextureAttributes.MODULATE);
states[1].setTextureAttributes(alphaAttrib);
TransparencyAttributes transAttr = new TransparencyAttributes( // These Transparency Attributes are for the Layers,
TransparencyAttributes.BLENDED, // that get layed over others, so they are more
0f, // transparent in some places than in others.
TransparencyAttributes.BLEND_SRC_ALPHA,
TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA);
transAttr.setSortEnabled(true);
a.setTransparencyAttributes(transAttr);
}
else {
TransparencyAttributes transAttr = new TransparencyAttributes(); // that’s for layer at the bottom, which is fully
transAttr.setSortEnabled(true); // opaque
a.setTransparencyAttributes(transAttr);
}
a.setTextureUnitState(states);
AppearanceResult res = new AppearanceResult(a, checkoutBelow);
return(res);
}
Note, that it works, if I don’t use the DecalGroup, but Transformgroups, that moves the alpha-layers a bit up, so they get shown over the opaque layer.
Arne