0

今日は、Java 3D を使って小さな水槽をプログラミングしてみました。水槽が回転し、魚が入れられます。ボックス内の魚は、アルファ チャネルを持つ PNG 画像を含む Java 3D ボックスです。透明度を有効にしないと、オブジェクトの順序は正しくなります。しかし、それを有効にすると、後ろの魚が前に出てきて、本当におかしくなりました。透明度オプションとしてNICEST、FASTEST、BLENDEDを試しましたが、何もしませんでした.

誰かが問題の可能性を知っていますか?

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);

外観 fischapp = new Appearance();
fischapp.setTransparencyAttributes(新しいTransparencyAttributes(TransparencyAttributes.NICEST、1f));

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

for(int i = 0; i

![代替テキスト][1]

ありがとうございました!

4

2 に答える 2

1

OrderedGroup を使用して、魚が前後に描画されるようにすることをお勧めします。

于 2010-03-19T19:32:09.420 に答える
0

はい、BranchGroupの代わりにOrderedGroupを使用する必要があります

TextureAttributes texAtt = new TextureAttributes();
texAtt.setTextureMode(TextureAttributes.MODULATE);
fischapp.setTextureAttributes(texAtt);

TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparencyMode( TransparencyAttributes.NICEST );
ta.setTransparency(.5f);
fischapp.setTransparencyAttributes(ta);
于 2012-02-03T15:53:30.763 に答える