我在3D环境中显示图像,将它们用作QuadArray对象上的纹理,到目前为止工作正常。但现在我想“调暗”我使用的纹理,以便生成的图像显示比以前更暗(我需要在3D环境中显示图片的背面;为此我创建了第二个QuadArray对象,相同的纹理,只是镜像和更暗,以便用户知道它不是他正在看的背面)。我怎样才能做到这一点? 我使用ColoringAttributes,TransparencyAttributes +彩色QuadArray,Materials和TextureAttributes几个小时,但每次背面都像前面一样明亮......是什么方式达到我想要的正常方式?
这是创建图片背面的代码,以及我已经尝试过的一些评论。我使用白色环境光btw。
QuadArray plane2 = new QuadArray(4, QuadArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.ALLOW_COLOR_WRITE | QuadArray.COLOR_3 | Primitive.GENERATE_NORMALS);
plane2.setColor(0, new Color3f(0.f, 0.f, 0.f));
plane2.setColor(1, new Color3f(0.f, 0.f, 0.f));
plane2.setColor(2, new Color3f(0.f, 0.f, 0.f));
plane2.setColor(3, new Color3f(0.f, 0.f, 0.f));
plane2.setCoordinate (3, new Point3f (-0.005f * image.getWidth(), -0.005f * image.getHeight(), 0f));
plane2.setCoordinate (2, new Point3f (0.005f * image.getWidth(), -0.005f * image.getHeight(), 0f));
plane2.setCoordinate (1, new Point3f (0.005f * image.getWidth(), 0.005f * image.getHeight(), 0f));
plane2.setCoordinate (0, new Point3f (-0.005f * image.getWidth(), 0.005f * image.getHeight(), 0f));
plane2.setTextureCoordinate (0, 3, new TexCoord2f(0f,0f));
plane2.setTextureCoordinate (0, 2, new TexCoord2f(1f,0f));
plane2.setTextureCoordinate (0, 1, new TexCoord2f(1f,1f));
plane2.setTextureCoordinate (0, 0, new TexCoord2f(0f,1f));
Appearance planeAppearance2 = new Appearance();
planeAppearance2.setTexture(image);
// Material material = new Material();
// material.setAmbientColor(0.0f, 0.0f, 0.0f);
TextureAttributes tex = new TextureAttributes();
tex.setTextureMode(TextureAttributes.BLEND);
tex.setTextureBlendColor(.0f, .0f, .0f, .5f);
planeAppearance2.setTextureAttributes(tex);
// TransparencyAttributes tAtt = new TransparencyAttributes(TransparencyAttributes.BLENDED, 0.0f); //BLENDED
// planeAppearance2.setTransparencyAttributes(tAtt);
// planeAppearance2.setMaterial(material);
// planeAppearance2.setColoringAttributes(new ColoringAttributes(1f, 0.f, 0.f, ColoringAttributes.NICEST));
objectTG.addChild(new Shape3D (plane2, planeAppearance2));