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

