/** * Sets the view-independent transform matrix for this handle. * This transform does not include the view-dependent scaling that is * applied to the handle's geometry <em>before</em> the transform. * @param transform the transform. */ public void setTransform(Matrix44 transform) { _transform = new Matrix44(transform); dirtyBoundingSphere(); dirtyDraw(); }
/** * Constructs a handle with specified center coordinates. * @param x the center x coordinate. * @param y the center y coordinate. * @param z the center z coordinate. */ protected Handle(double x, double y, double z) { setLocation(x,y,z); }
/** * Constructs a handle with specified transform matrix. * @param transform the transform matrix. */ protected Handle(Matrix44 transform) { setTransform(transform); }
/** * Pushes the view-dependent transform onto the specified cull context. * @param cc the cull context. */ protected void cullBegin(CullContext cc) { super.cullBegin(cc); Matrix44 transform = computeTransform(cc); cc.pushLocalToWorld(transform); }
/** * Computes the transform matrix for this handle in the specified context. * The context is view-dependent, as is the computed transform matrix. * This matrix includes the view-dependent scaling required for the * handle to have the correct size in pixels. * @param tc the transform context. * @return the transform matrix for this handle. */ private Matrix44 computeTransform(TransformContext tc) { View view = tc.getView(); Tuple3 as = view.getAxesScale(); Matrix44 localToPixel = tc.getLocalToPixel().times(_transform); Matrix44 pixelToLocal = localToPixel.inverse(); Point3 p = new Point3(0.0,0.0,0.0); Point3 q = localToPixel.times(p); q.x += getSize(); q = pixelToLocal.times(q); double dx = (q.x-p.x)*as.x; double dy = (q.y-p.y)*as.y; double dz = (q.z-p.z)*as.z; double d = Math.sqrt(dx*dx+dy*dy+dz*dz); double r = _boundingSphereChildren.getRadius(); double s = d/r; double sx = s/as.x; double sy = s/as.y; double sz = s/as.z; return _transform.times(Matrix44.scale(sx,sy,sz)); } }
/** * Pushes the view-dependent transform onto the specified pick context. * @param pc the pick context. */ protected void pickBegin(PickContext pc) { super.pickBegin(pc); Matrix44 transform = computeTransform(pc); pc.pushLocalToWorld(transform); }
/** * Sets the view-independent location of the center of this handle. * This method conveniently sets the handle transform to a pure * translation to the center point with specified coordinates. * @param x the center x coordinate. * @param y the center y coordinate. * @param z the center z coordinate. */ public void setLocation(double x, double y, double z) { _transform = Matrix44.translate(x,y,z); dirtyBoundingSphere(); dirtyDraw(); }
/** * Sets the view-independent location of the center of this handle. * This method conveniently sets the handle transform to a pure * translation to the specified center point. * @param p the center point. */ public void setLocation(Point3 p) { setLocation(p.x,p.y,p.z); }
/** * Pushes the view-dependent transform onto the specified draw context. * @param dc the draw context. */ protected void drawBegin(DrawContext dc) { super.drawBegin(dc); Matrix44 transform = computeTransform(dc); dc.pushLocalToWorld(transform); glPushMatrix(); glMultMatrixd(transform.m,0); }
/** * Constructs a handle with specified center location. * @param p the center point. */ protected Handle(Point3 p) { setLocation(p.x,p.y,p.z); }