/** * Restores the most recently saved (pushed) local-to-world transform. * Discards the current local-to-world transform. */ public void popLocalToWorld() { super.popLocalToWorld(); _pickSegment = _pickSegmentStack.pop(); _nearPoint = _pickSegment.getA(); _farPoint = _pickSegment.getB(); }
/** * 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(); }
Point3 p1 = segment.getA(); Vector3 v1 = segment.getB().minus(p1);
Point3 a = segment.getA(); Point3 b = segment.getB(); Vector3 d = b.minus(a);
Point3 mouseNear = mouseSegment.getA(); Point3 mouseFar = mouseSegment.getB(); Vector3 mouseVector = mouseFar.minus(mouseNear).normalize();