Hello,
sometimes I return on picking problem and everytime I can't solve it.
The problem is to select from Shape3d a face. Clicking on the canvas3d I
generate a PickRay with the PickObject utility and I select a shape from
the Virtual Universe:
pick = new PickObject(c,r);
path = pick.pickClosest(evt.getX(),evt.getY(),PickObject.USE_GEOMETRY);
if(path!=null) {
Shape3D shape = (Shape3D) pick.pickNode(path,PickObject.SHAPE3D);
Geometry geom = shape.getGeometry();
All OK. Now I want to select the face on wich I've clicked.
QuadArray geomQuad = (QuadArray) geom;
...
for (int j=0;j<geomQuad.getVertexCount();j=j+4){
boolean intersection =
Intersect.rayAndQuad(pick.getPickRay(),quad,j,distance);
System.out.println( "face :"+j/4+" intersection :"+intersection+" distance
+distance[0]);
if ((intersection) && (distance[0]<nearest)){
nearest = distance[0];
nearestFace = j;
}
}
I've tested this procedure on a simple box, independently from the point
where I click, the result printed are always the same:
face :0 intersection :true distance :2.31697215460254
face :1 intersection :true distance :2.517210562007264
face :2 intersection :false distance :4.41982426390378
face :3 intersection :false distance :-4.41982426390378
face :4 intersection :false distance :4.627593780583001
face :5 intersection :false distance :-4.627593780583001
What's wrong?
In the Java3D 1.1.1 release will there a procedure more intuitive for picking?
Thank you
Visita la Martilla's Home Page:
http://members.tripod.com/~Martilla
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/