Forum Stats

  • 3,875,872 Users
  • 2,266,977 Discussions
  • 7,912,361 Comments

Discussions

Picking returns false results when aspect ratio is different from 1:1

843799
843799 Member Posts: 49,999
Hi,

When using picking with perspective projection when the aspect ratio is different from 1:1 I get false results.

Any idea how to fix it ?

Thanks
Ophir

Following is the related code:

// For the perspective projection
Transform3D prespective = new Transform3D();
prespective.perspective(hFov, Math.tan(hFov/2)/Math.tan(vFov/2), 1f, 30f);
view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
view.setLeftProjection(prespective);


// Picking code
Point3d eye_pos = new Point3d();
Point3d mouse_pos = new Point3d();

canvas.getCenterEyeInImagePlate(eye_pos);
canvas.getPixelLocationInImagePlate(x, y, mouse_pos);

Transform3D motion = new Transform3D();
canvas.getImagePlateToVworld(motion);
motion.transform(eye_pos);
motion.transform(mouse_pos);

Vector3d direction = new Vector3d(mouse_pos);
direction.sub(eye_pos);

PickRay ray = new PickRay(eye_pos, direction);
This discussion has been closed.