I have an image with alpha values set pixel by pixel for the background
color, that I want to place in the face of a flat box, and have only the
background transparent. Despite all possible combinations on the
TransparencyAttributes, I get the whole image transparent, except if the
mode is set to NONE. Any suggestions ?
Below is the code I am using.
HT
private synchronized Appearance getAppearance(PlanarImage pi) {
ImageComponent2D image = new (ImageComponent2D Component2D.FORMAT_RGBA,
pi);
//Builds texture
Appearance appear = new Appearance();
Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
image.getWidth(), pi.getHeight());
//Set alpha values for the background to 0
image.set(giveAlfa(image));
texture.setImage(0, image);
appear.setTexture(texture);
TextureAttributes txtAttrib = new TextureAttributes();
txtAttrib.setTextureMode(TextureAttributes.REPLACE);
appear.setTextureAttributes(txtAttrib);
RenderingAttributes rdrAttrib = new RenderingAttributes();
rdrAttrib.setIgnoreVertexColors(true);
appear.setRenderingAttributes(rdrAttrib);
Material material = new Material();
material.setLightingEnable(false);
appear.setMaterial(material);
TransparencyAttributes transAttrib = new TransparencyAttributes();
transAttrib.setTransparencyMode(TransparencyAttributes.BLENDED);
transAttrib.setSrcBlendFunction
(TransparencyAttributes.BLEND_SRC_ALPHA);
transAttrib.setDstBlendFunction(TransparencyAttributes.BLEND_ONE);
transAttrib.setTransparency(0.0f);
appear.setTransparencyAttributes(transAttrib);
listo = true;
return appear;
}
===========================================================================
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".