Hi!
We�re trying to measure distances between a given point and the closest
Shape3D object in a given direction. Therefore we sent a ray in that
direction and successfully chose the nearest Shape3D object using the
pickClosest method. Then we used the returned SceneGraphPath with the
intersect method of Shape3D to find out the distance between the given
point and the object hitten by the pickRay. But: for no apparent reasons

the intersect method always returns false (and of course no distance!).
Attached is the interesting part of our code.

Can anybody help us find out what the problem is???
Thanks in advance

Thorsten, Frieder

-----
public class rhino extends Applet {
    public static BranchGroup scene;

    public rhino() {
        setLayout(new BorderLayout());
        Canvas3D canvas3D = new Canvas3D(null);
        add("Center", canvas3D);
        scene = createSceneGraph();
        scene.compile();
        SimpleUniverse u = new SimpleUniverse(canvas3D);
        u.addBranchGraph(scene);
    }
    public BranchGroup createSceneGraph() {
        BranchGroup scene = new BranchGroup();
        scene.setCapability(Node.ENABLE_PICK_REPORTING);
        Vector3d v1 = new Vector3d(0,0,0);
        Matrix3d m1 = new Matrix3d(1,0,0,0,1,0,0,0,1);
        Transform3D translate1 = new Transform3D(m1,v1,1);
        translate1.rotY(Math.PI/4.0d);
        TransformGroup cube = new TransformGroup(translate1);
        cube.setCapability(Node.ENABLE_PICK_REPORTING);
        ColorCube CCube = new ColorCube(0.1);
        CCube.getGeometry().setCapability(Geometry.ALLOW_INTERSECT);
        CCube.setCapability(Node.ENABLE_PICK_REPORTING);
        cube.addChild(CCube);
        scene.addChild(cube);
        return scene;
    }

    public static double[] distance(Point3d origin, Vector3d direction){

        PickRay Fire = new PickRay(origin, direction);

        SceneGraphPath target = scene.pickClosest(Fire);

        System.out.println(target.nodeCount());
        double[] dist = new double[1];
        System.out.println(target.toString());
        if(((Shape3D)target.getObject()).intersect(target, Fire, dist)){

            System.out.println("Hit!!!!!!");
            return dist;
        }
        System.out.println("No Hit!!!!!!");
        return null;
    }

    public static void main(String[] args) throws InterruptedException {

        rhino world = new rhino();
        Frame frame = new MainFrame(world, 512, 512);

        double[] d = world.distance(new Point3d(0, 0, 2),
                                 new Vector3d(0, 0, -1));
   }

}

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