/** * 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(); }
void pickOnFrame(PickContext pc) { Segment ps = pc.getPickSegment(); Point3 pa = ps.intersectWithTriangle( _p[0].x,_p[0].y,_p[0].z, _p[1].x,_p[1].y,_p[1].z, _p[3].x,_p[3].y,_p[3].z); Point3 pb = ps.intersectWithTriangle( _p[0].x,_p[0].y,_p[0].z, _p[3].x,_p[3].y,_p[3].z, _p[2].x,_p[2].y,_p[2].z); pc.addResult(pa); pc.addResult(pb); }
/** * 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); }
public void pick(PickContext pc) { Segment ps = pc.getPickSegment(); for (int it=0,jt=0; it<_nt; ++it) { double xi = _vb.get(jt++); double yi = _vb.get(jt++); double zi = _vb.get(jt++); double xj = _vb.get(jt++); double yj = _vb.get(jt++); double zj = _vb.get(jt++); double xk = _vb.get(jt++); double yk = _vb.get(jt++); double zk = _vb.get(jt++); Point3 p = ps.intersectWithTriangle(xi,yi,zi,xj,yj,zj,xk,yk,zk); if (p!=null) pc.addResult(p); } }
/** * 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(); }
public void pick(PickContext pc) { Segment ps = pc.getPickSegment(); for (int iq=0,j=0; iq<_nq; ++iq) { double xi = _vb.get(j++); double yi = _vb.get(j++); double zi = _vb.get(j++); double xj = _vb.get(j++); double yj = _vb.get(j++); double zj = _vb.get(j++); double xk = _vb.get(j++); double yk = _vb.get(j++); double zk = _vb.get(j++); double xl = _vb.get(j++); double yl = _vb.get(j++); double zl = _vb.get(j++); Point3 p = ps.intersectWithTriangle(xi,yi,zi,xj,yj,zj,xk,yk,zk); if (p==null) p = ps.intersectWithTriangle(xk,yk,zk,xl,yl,zl,xi,yi,zi); if (p!=null) pc.addResult(p); } }
public void pick(PickContext pc) { Segment ps = pc.getPickSegment(); for (int iside=0; iside<6; ++iside) { double xa = _va[12*iside+ 0]; double ya = _va[12*iside+ 1]; double za = _va[12*iside+ 2]; double xb = _va[12*iside+ 3]; double yb = _va[12*iside+ 4]; double zb = _va[12*iside+ 5]; double xc = _va[12*iside+ 6]; double yc = _va[12*iside+ 7]; double zc = _va[12*iside+ 8]; double xd = _va[12*iside+ 9]; double yd = _va[12*iside+10]; double zd = _va[12*iside+11]; Point3 p = ps.intersectWithTriangle(xa,ya,za,xb,yb,zb,xc,yc,zc); Point3 q = ps.intersectWithTriangle(xa,ya,za,xc,yc,zc,xd,yd,zd); if (p!=null) pc.addResult(p); if (q!=null) pc.addResult(q); } }
public void pick(PickContext pc) { Segment ps = pc.getPickSegment(); for (int iside=0,index=0; iside<6; ++iside,index+=12) { double xa = _va[index+ 0]; double ya = _va[index+ 1]; double za = _va[index+ 2]; double xb = _va[index+ 3]; double yb = _va[index+ 4]; double zb = _va[index+ 5]; double xc = _va[index+ 6]; double yc = _va[index+ 7]; double zc = _va[index+ 8]; double xd = _va[index+ 9]; double yd = _va[index+10]; double zd = _va[index+11]; Point3 p = ps.intersectWithTriangle(xa,ya,za,xb,yb,zb,xc,yc,zc); Point3 q = ps.intersectWithTriangle(xa,ya,za,xc,yc,zc,xd,yd,zd); if (p!=null) pc.addResult(p); if (q!=null) pc.addResult(q); } } protected BoundingSphere computeBoundingSphere(boolean finite) {