/** * Gets the pick segment for this context. Endpoint A of the segment lies * on the near clipping plane; endpoint B lies on the far clipping plane. * @return the pick segment. */ public Segment getPickSegment() { return new Segment(_pickSegment); }
/** * Gets a line segment in local coordinates for the specified event. * The endpoints A and B of the line segment lie on the near and far * clipping planes, respectively. * @param event the mouse event. * @return the line segment. */ protected Segment getMouseSegment(MouseEvent event) { int x = event.getX(); int y = event.getY(); Point3 near = new Point3(x,y,0); Point3 far = new Point3(x,y,1); near = _pixelToLocal.times(near); far = _pixelToLocal.times(far); return new Segment(near,far); }
/** * 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(); }