When you create the GIF image you have to be sure that the
transparency color is set.  Check it because it is easy to overlook.
If you want to see through the texture as well as the shape that it is
texture mapped on, you need to set the transparency in the shape's
appearance.

The following method configures the transparency attributes that must
be set in the host shape's Appearance object.

        private final Shape3D _shape = new Shape3D
        private final Appearance _app = new Appearance();
        private final TransparencyAttributes _transAtt =
         new TransparencyAttributes();

        /**
        Sets the object transparency.  If out of range the
        transparency will be disabled.
        @param trans New transparency.
        */
        public void setTransparency(double trans) {
                if(trans<0.0 || trans>1.0) {
                        // disable transparency
                        _transAtt.setTransparencyMode(
                         TransparencyAttributes.NONE);
                        _transAtt.setTransparency((float)trans);
                } else {
                        // set transparency (Java 3D 1.1.2 has a bug with
                        // NICEST and transparent textures)
                        _transAtt.setTransparencyMode(
                         TransparencyAttributes.FASTEST);
                        _transAtt.setTransparency((float)trans);
                }

                _app.setTransparencyAttributes(_transAtt);
                _shape.setAppearance(_app);
        }

Be forewarned that, unlike VRML, Java 3D is pretty klunky in its
handling of multiple overlapping transparent textures.  Some pretty
unexpected things can appear.  If you really don't need shape
transparency you have to set it to NONE -- setting it to 0.0 won't do
-- which is why the code tests for an out-of-range transparency factor
(i.e. interpreted as no transparency).

good luck
--jon

> Date:    Sun, 21 Nov 1999 21:00:48 -0500
> From:    David Charles Hirschfield <[EMAIL PROTECTED]>
> Subject: Transparent GIF texture question
>
> Does anyone have any sample code for simple transparency using
> transparent gif textures in java3d?
>
> I simply want to load a gif image as a texture and have the
> single-see-through color of the gif be my transparent color.
>
> Alternatively, does anyone know how to add an alpha layer to a texture
> loaded via the textureloader class (the pixel format defaults to RGBA,
> but the texture has no Alpha layer).
>
> Thanks,
> -David

____________________ Peculiar Technologies ____________________
Jon Barrilleaux       3800 Lake Shore Ave.         Purveyors of
[EMAIL PROTECTED]        Oakland, CA 94610      Alternate Reality
510.444.4370 voc                           Augmented Simulation
510.444.0231 fax        www.augsim.com         and 3D Solutions

===========================================================================
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