How to make a plane semi-transparent

Hi everyone. I am new here, and would like to thank you in advance.

I am trying to make a semi-transparent plane using 3D with QuadArray. Have set TransparencyAttributes accordingly; and have even tried TextureAttributes. It just doesn't cut it.

Without setting transparency, the plane is visible both sides. But once transparency set, it becomes invisible.

Can anyone give me some ideas? Thanks!

Here's the code snippet dealing with this plane:

*********************

Appearance ap = new Appearance();

TransparencyAttributes transparency = new

TransparencyAttributes(TransparencyAttributes.NICEST, 0.5f);

ap.setTransparencyAttributes(transparency);

PolygonAttributes cullAttribute = new PolygonAttributes();

cullAttribute.setCullFace(PolygonAttributes.CULL_NONE);

ap.setPolygonAttributes(cullAttribute);

TextureAttributes texture = new TextureAttributes();

texture.setTextureMode(TextureAttributes.BLEND);

ap.setTextureAttributes(texture);

Point3f points[] = new Point3f[4];

points[0] = new Point3f(-0.2f, 0.2f, 1.0f);

points[1] = new Point3f(0.2f, 0.2f, 1.0f);

points[2] = new Point3f(0.2f, -0.2f, 1.0f);

points[3] = new Point3f(-0.2f, -0.2f, 1.0f);

QuadArray planeVertices = new QuadArray(4, QuadArray.COORDINATES|QuadArray.COLOR_3);

planeVertices.setCoordinates(0, points);

Color3f colors[ ] = new Color3f[4];

for(int i = 0; i < colors.length; i++){

colors = new Color3f(1.0f, 1.0f, 0.0f);

}

planeVertices.setColors(0, colors);

Shape3D plane = new Shape3D( );

plane.setGeometry(planeVertices);

plane.setAppearance(ap);

********************

[1748 byte] By [senore100a] at [2007-11-26 22:48:06]
# 1

I just found that if I leave the colors undefined for the plane (a Shape3D); that is, remove the QuadArray.COLOR_3 flag, then the transparency works. Unfortunately, in that case, I can only have a white plane, and there's still no way for me to add color to the plane with its transparency maintained.

The right way seems to be using QuadArray.COLOR_4 flag instead. But somehow I can't get it to work. That is, no matter what value I am using for the Alpha value, the plane just remains opaque.

Can anyone give me some suggestions? Thanks a lot!

Message was edited by:

senore100

senore100a at 2007-7-10 12:07:32 > top of Java-index,Security,Cryptography...