Hi Todda

Probably this might help you.

Point3d _point3d = _canvas.getStartPosition ();

Anand






Tor Einar Kj $B�S (Bkleiv <[EMAIL PROTECTED]> on 07/13/2001 03:53:12 PM

Please respond to Discussion list for Java 3D API <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Anand PILLAI/dassault-systemes)
Subject:  [JAVA3D] Picking a cube

Hi all!

I have implemented a mouseReleased method where I want to pick a cube in the
scene. The only problem is that the cube is picked no matter where I click
on the screen. What have I done wrong?

Thanks for helping me!

Todda


Point3d _point3d = new Point3d();
Vector3d _vector3d = new Vector3d(0,0,-1);

public void mousePressed(MouseEvent e){
        if(e.isControlDown()==true)
        _ray = new PickRay(_point3d, _vector3d);
}

public void mouseReleased(MouseEvent e){

        if(e.isControlDown()==true) {
        int x = e.getX();
        int y = e.getY();
        _canvas.getPixelLocationInImagePlate(x, y, _point3d);
        _ray.set(_point3d, _vector3d);

        try{
        _results = _branchgroup.pickAny(_ray);
        Node pickedObject = _results.getObject();
        System.out.println("object picked :" + pickedObject );
        }
        catch(Exception ex){
        System.out.println("No objects picked");
        }
        }
}
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.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".




Reply via email to