Hi Chien,

here is a test program, which illustrates the points 1 and 3.

I was not able to reproduce the depth buffer problem in a simple test
program. I also think, that it is not a Raster specific problem. I
have not used setDepthBufferEnable(false) before I started playing
with Raster. But my understanding is, that objects, which have the
depth buffer disabled, should always be drawn on top of all other
objects with an enabled depth buffer, regardless of their z-location
in the world. Is this assumption right?
When I tested disabling the depth buffer on a LineStripArray in my
applet, where this would be quite usefull, I noticed, that it did not
work either. But again, for me it's difficult to isolate the problem.

Regards,

Ingo


===File ~/RasterTest.java===================================
import java.awt.image.BufferedImage;
import java.awt.*;
import javax.swing.JFrame;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.geometry.Sphere;

public class RasterTest extends JFrame {
    public RasterTest() {
        Canvas3D canvas = new Canvas3D(
            SimpleUniverse.getPreferredConfiguration());
        SimpleUniverse universe = new SimpleUniverse(canvas);
        universe.addBranchGraph(createSceneGraph());

        Transform3D vpLocation = new Transform3D();
        TransformGroup vptg = universe.getViewingPlatform(
            ).getViewPlatformTransform();
        vptg.getTransform(vpLocation);
        vpLocation.setTranslation(new Vector3d(0.0, 0.0, 8.0));
        vptg.setTransform(vpLocation);
        canvas.setSize(300, 300);
        getContentPane().add(canvas);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
    }

    public static void main(String[] args) {
        RasterTest frame = new RasterTest();
        frame.show();
    }

    private BranchGroup createSceneGraph() {
        BranchGroup branch = new BranchGroup();

        // TransformGroup for MouseBehaviors
        TransformGroup tg = new TransformGroup();
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        branch.addChild(tg);

        MouseZoom myMouseZoom = new MouseZoom();
        myMouseZoom.setTransformGroup(tg);
        myMouseZoom.setSchedulingBounds(new BoundingSphere());
        branch.addChild(myMouseZoom);

        DirectionalLight light = new DirectionalLight();
        light.setInfluencingBounds(new BoundingSphere(new Point3d(), 1000));
        branch.addChild(light);

        // Add a Background
        Background background = new Background(new Color3f(1.0f, 0.0f, 0.0f));
        background.setApplicationBounds(new BoundingSphere(new Point3d(),
                                                           1000));
        branch.addChild(background);

        // Add a lit Sphere
        Appearance app = new Appearance();
        app.setMaterial(new Material());
        Sphere sphere = new Sphere(1.0f, app);
        tg.addChild(sphere);

        // Add the Raster
        tg.addChild(createLabel("Cl"));

        return branch;
    }

    private Shape3D createLabel(String text) {
        Point3f rasterPos = new Point3f(0.0f, 0.0f, 0.0f);
        Color textColor = new Color(0, 255, 255, 255); // cyan
        Color bgColor = new Color(255, 255, 255, 0); // transparent white
        BufferedImage bufferedImage = new BufferedImage(
            35, 15, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bufferedImage.createGraphics();

        // Appearance for Raster
        Appearance labelApp = new Appearance();
        RenderingAttributes ra = new RenderingAttributes(
            false, false, 0.0f, RenderingAttributes.ALWAYS);
        // To get a real transparent background, uncomment the following line!
        //ra.setAlphaTestFunction(RenderingAttributes.GREATER);
        labelApp.setRenderingAttributes(ra);

        // Clear the background
        g.setBackground(bgColor);
        g.clearRect(0, 0, 35, 15);

        // Draw the text
        g.setColor(textColor);
        g.drawString(text, 2, 12);
        g.dispose();

        ImageComponent2D imageComponent2D = new ImageComponent2D(
            ImageComponent2D.FORMAT_RGBA, bufferedImage);
        Raster labelRaster = new Raster(rasterPos, Raster.RASTER_COLOR, 0, 0,
                                        35, 15, imageComponent2D, null);
        labelRaster.setDstOffset(0, 50); // This has no effect!!!
        // To see the effect of the y-offset, you also have to set the x-offset!
        //labelRaster.setDstOffset(-50, 50);

        return new Shape3D(labelRaster, labelApp);
    }
}
============================================================


>Ingo,
>       Please send us test programs for all 3 cases. It will be great
>if we can have them ASAP; we're near to our next code freeze for j3d1.3beta2
>release.
>
>thanks,
>
>- Chien Yang.
>  Java 3D Team.
>
>>
>> Hi all,
>>
>> after playing with Raster for labelling objects to get rid of my
>> Text2D/OrientedShape3D combination and getting it to work, I want to
>> tell you about three things I have noticed with j3d 1.3b1. I don't
>> know if these are intended or bugs.
>>
>> 1) To make transparency work with the Background node you have to set
>>    another alpha test function in your Rendering Attributes than the
>>    default function ALWAYS (assuming you have an ImageComponent2D with
>>    a transparent background).
>>
>> 2) If you disable the depth buffer in the RenderingAttributes in order
>>    to have your label staying always on top but you set your Raster
>>    position to (0, 0, 0) the depth buffer is enabled regardless of
>>    your settings.
>>
>> 3) If you use setDstOffset(x, y) with x = 0, the y-coordinate is also
>>    ignored.

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