We are trying to figure out which face box was picked: the code that
intend this is the following text :
//init()
../..
canvas.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
canvas_mouseClicked(e);
}
});
../..
void canvas_mouseClicked(MouseEvent e) {
TransformGroup tg = null;
Shape3D sh = null;
Box box = null;
int x = e.getX();
int y = e.getY();
System.out.println("Position: "+x+", "+y);
PickCanvas pickCanvas = new PickCanvas(canvas, scene);
pickCanvas.setShapeLocation(x, y);
PickResult pr = pickCanvas.pickClosest();
if ((pr != null)&&
((sh = (Shape3D) pr.getNode(PickResult.SHAPE3D)) != null)&&
((box = (Box) pr.getNode(PickResult.PRIMITIVE)) != null)){
String message;
message += "\n";
if (sh.equals(box.getShape(box.FRONT))) message += "FRONT
was picked";
if (sh.equals(box.getShape(box.BACK))) message += "BACK was
picked";
if (sh.equals(box.getShape(box.BOTTOM))) message += "BOTTOM
was picked";
if (sh.equals(box.getShape(box.LEFT))) message += "LEFT was
picked";
if (sh.equals(box.getShape(box.RIGHT))) message += "RIGHT
was picked";
if (sh.equals(box.getShape(box.TOP))) message += "TOP was
picked";
System.out.println(message);
}
}
Usually it returns the face in the back of the box. Except when the
back face is LEFT, it seems it doesn't exists, never is returned. It
seems like the ray goes through the box and returns the back face.
Can't anybody help?
PRISMAKER TEAM
===========================================================================
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".