Java3D: Problem with order of objects that have a transparent PNG texture

Posted by Sebastian on Stack Overflow See other posts from Stack Overflow or by Sebastian
Published on 2010-03-19T19:16:29Z Indexed on 2010/03/19 19:21 UTC
Read the original article Hit count: 446

Filed under:
|

Hello!

Today I tried to program a little fish tank with Java 3D. The fish tank rotates and fishes are placed in it. The fishes in the box are Java 3D Boxes with a PNG picture that has an alpha channel. Without activated transparency the order of the objects is correct. But when I enable it, some fishes in the back come to the front what looks really wrong. I tried NICEST, FASTEST and BLENDED as Transparency Options but I had no effort.

Does someone know what the problem could be?

Vector3f[] posf = new Vector3f[5];
posf[0] = new Vector3f(-0.22f, -0.1f, -0.2f);
posf[1] = new Vector3f(-0.34f, 0.1f, 0.2f);
posf[2] = new Vector3f(0.3f, -0.2f, 0.3f);

Appearance fischapp = new Appearance();
fischapp.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, 1f));

try
{
  fischapp.setTexture(new TextureLoader(ImageIO.read(new File("nemo.png")), this).getTexture());
}
catch(IOException exc)
{
  System.out.println(exc.getMessage());
}

for(int i = 0; i 

Thank you!

© Stack Overflow or respective owner

Related posts about java

Related posts about java3d