/** * Constructs a pick context for the specified mouse event. * @param event the mouse event. */ public PickContext(MouseEvent event) { super((ViewCanvas)event.getSource()); _event = event; int xp = event.getX(); int yp = event.getY(); // The near endpoint. Point3 near = new Point3(xp,yp,0.0); // The far endpoint. Point3 far = new Point3(xp,yp,1.0); // The pick segment, transformed to world coordinates. _pickSegment = new Segment(near,far); _pickSegment.transform(getPixelToWorld()); _nearPoint = _pickSegment.getA(); _farPoint = _pickSegment.getB(); }
/** * Saves the local-to-world transform before appending a transform. * The specified transform matrix is post-multiplied with the current * local-to-world transform, such that the specified transform is applied * first when transforming local coordinates to world coordinates. * @param transform the transform to append. */ public void pushLocalToWorld(Matrix44 transform) { super.pushLocalToWorld(transform); _pickSegmentStack.push(new Segment(_pickSegment)); _pickSegment.transform(transform.inverse()); _nearPoint = _pickSegment.getA(); _farPoint = _pickSegment.getB(); }