hello,
 
I have a problem with picking an object on screen. When I click on it it works but when I click nor far from it, it picked an object too.
Thanks a lot.
 
Here is the code I use to pick an object:
 

Point3d eyePos= new Point3d ();

c.getCenterEyeInImagePlate (eyePos);

Point3d mousePos= new Point3d ();

c.getPixelLocationInImagePlate (xpos, ypos, mousePos);

Transform3D t3d= new Transform3D ();

c.getImagePlateToVworld (t3d);

t3d.transform (eyePos);

t3d.transform (mousePos);

Vector3d mouseVec= new Vector3d ();

mouseVec.sub (mousePos, eyePos);

mouseVec.normalize ();

PickRay pickRay= new PickRay (mousePos, mouseVec);

//pickRay.set (mousePos, mouseVec);

SceneGraphPath sceneGraphPath []= bg.pickAllSorted (pickRay);

if (sceneGraphPath != null) {

for (int j=0; j<sceneGraphPath.length; j++) {

if (sceneGraphPath [j] != null) {

Node node= sceneGraphPath [j].getObject ();

if (node instanceof Shape3D) {

System.out.println ("c'est un noeud!");

//try {

//Sphere noeud= (Sphere) node.getUserData ();

//System.out.println ("Je suis le noeud");

//}

//catch (CapabilityNotSetException e) {System.out.println ("de");}

}

}

}

}

Reply via email to