Thank you

Not exactly; what I want is that any black pixels within the star (a
skull in my case) stay opaque at all times, as black is needed for
proper rendering, and the remaining background to be transparent. I
don't want the background showing through the main subject of the image
(a skull floating in a room).

Humberto

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Booth
Sent: Friday, June 06, 2003 3:13 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Selective transparent background

Hi Humberto
   I use the following code to create a lens flare effect
http://darkvoid.newdawnsoftware.com/ -> screen shots, has some screen
shots with
them in, the image is an gray scale image where the black parts are
totally
transparent, and the while is opaque, anything in between is semi
transparent, I
hope it's what you were after. You might want to adjust the transparency
src and
dst functions as they are set up to act like lens flare, so they are
additive.

Jeremy

=================

         //Create the geometry for the oriented shape
         lightObject = new QuadArray(4,QuadArray.COORDINATES |
QuadArray.NORMALS
| QuadArray.TEXTURE_COORDINATE_2);
         Point3f[] vertecies = {new Point3f(-shapeEdge,-shapeEdge,0f),
new
Point3f(shapeEdge,-shapeEdge,0),
                 new Point3f(shapeEdge,shapeEdge,0f), new
Point3f(-shapeEdge,shapeEdge,0)};
         lightObject.setCoordinates(0,vertecies);

         //create the texture coordinates
         TexCoord2f[] lightTextCoords = {new TexCoord2f(0f,0f), new
TexCoord2f(1f,0f),
             new TexCoord2f(1f,1f), new TexCoord2f(0f,1f)};
         lightObject.setTextureCoordinates(0,0,lightTextCoords);

         //set the normals
         Vector3f[] lightNormals = {new Vector3f(0f,0f,1f), new
Vector3f(0f,0f,1f),
             new Vector3f(0f,0f,1f), new Vector3f(0f,0f,1f)};
         lightObject.setNormals(0,lightNormals);

         //create the oriented shape and set the geometry
         lightShape = new OrientedShape3D();
         lightShape.setRotationPoint(0f,0f,0f);
         lightShape.setGeometry(lightObject);

lightShape.setAlignmentMode(OrientedShape3D.ROTATE_ABOUT_POINT);
         lightShape.setPickable(false);

         //load the texture
         URL textURL = ClassLoader.getSystemResource("data/star.jpg");

         if(textURL == null) {
             Logger.log(Logger.ERROR, "Couldn't find data/star.jpg");
             throw new RuntimeException("Couldn't find data/star.jpg");
         }

         Texture texture = TextureResourcePool.getTexture(textURL);
         TextureAttributes texAttr = new TextureAttributes();
         texAttr.setTextureMode(TextureAttributes.MODULATE);
         lightApp = new Appearance();
         lightApp.setTexture(texture);
         lightApp.setTextureAttributes(texAttr);

         TransparencyAttributes t_attr =
             new
TransparencyAttributes(TransparencyAttributes.BLENDED,0f,
         TransparencyAttributes.BLEND_SRC_ALPHA,
         TransparencyAttributes.BLEND_SRC_ALPHA);
         lightApp.setTransparencyAttributes( t_attr );
         lightApp.setMaterial(new Material(black, colour, black, black,
0));

         RenderingAttributes renderAttributes = new
RenderingAttributes();

         lightApp.setRenderingAttributes(renderAttributes);

         lightShape.setAppearance(lightApp);

--

Homepage: http://www.computerbooth.com/
Code page: http://www.newdawnsoftware.com/

========================================================================
===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA3D-INTEREST".  For general help, send email
to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to