use of maspack.render.Renderer in project artisynth_core by artisynth.
the class ConstrainedTranslator3d method updateLocation.
private void updateLocation(MouseRayEvent e) {
if (mesh == null) {
return;
}
Line ray = e.getRay();
Point3d origin = ray.getOrigin();
Vector3d direction = ray.getDirection();
// face = obbt.intersect (origin, direction, duv, intersector);
face = query.nearestFaceAlongRay(null, duv, mesh, origin, direction);
if (face != null) {
myXDraggerToWorld.p.scaledAdd(duv.x, direction, origin);
} else {
Renderer renderer = e.getViewer();
Point3d location = new Point3d(myXDraggerToWorld.p);
RigidTransform3d EyeToWorld = renderer.getViewMatrix();
EyeToWorld.invert();
EyeToWorld.R.getColumn(2, planeNormal);
plane.set(planeNormal, location);
plane.intersectRay(planeLocation, direction, origin);
face = query.nearestFaceToPoint(location, coords, mesh, planeLocation);
duv.x = myXDraggerToWorld.p.distance(EyeToWorld.p);
duv.y = coords.x;
duv.z = coords.y;
myXDraggerToWorld.p.set(location);
}
myIncrementalTransform.p.set(transform.p);
transform.p.sub(myXDraggerToWorld.p, firstLocation);
myIncrementalTransform.p.sub(transform.p, myIncrementalTransform.p);
}
Aggregations