|
Hi all,
I have two small questions about
picking:
1) I created my own classes for picking. The below
lines create a ray and select object/s from the scene:
//BranchGroup objRoot
PickRay ray = createPickRay(canvas, x,
y);
SceneGraphPath[] path =
objRoot.pickAll(ray);
private PickRay createPickRay(Canvas3D canvas, int x, int
y)
{ 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); return new PickRay(eye_pos, direction);
} The problem is that if there are two objects
behind one PickRay selects all of them. How can I select the closest one? I
replace the pickAll(ray) method with pickClosest(ray). But I am getting the
below error message.
c:\book\MousePickBehaviour.java:82: incompatible
types
found : javax.media.j3d.SceneGraphPath required: javax.media.j3d.SceneGraphPath[] SceneGraphPath[] path = ModelClipTest.IFCRoot.pickClosest(ray); ^ 1 error 2) Secondly, how can I pick the objects within a
window created a window created by mouse? Now I can get the clicked point on the
canvas and select single object? How can I proceed to select with mouse
windows?
Thanks
Murat
|
