I am implementing ‘Pan’ routine. I convert mouse point location to world coordinates and I update camera location based on the previous and next point using world coordinates However, in order to make it work properly it looks like I need to rotate camara or the viewport to keep proper angle based on the camera movement (target should stay perpendicular to the projection surface).Otherwise when panning object it will be viewed from a different angle if I only move the camera. It is hard to notice when the object is away from the camera but if I am close, object is loosing its orientation. Here is the framgment of my code:
double factor = -1.0 ;
double x = factor * (current.X - previous.X) + Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.CameraLocation.X;
double y = factor * (current.Y - previous.Y) + Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.CameraLocation.Y;
double z = factor * (current.Z - previous.Z) + Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.CameraLocation.Z;
Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.SetCameraLocation(new Rhino.Geometry.Point3d(x, y, z), true);
Rhino.RhinoDoc.ActiveDoc.Views.RedrawEnabled = true;
I am trying to figure out if I can apply rotation using Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.MainViewport.Rotate() (what angle, what vector and rotation point) to keep the target at the same angle towards the camera when camera is moving, so it works exactly like in the Rhino application.
Did anyone implemented panning functionality programatically? Please let me know if anybody has some suggestions.
Thanks,
Jacek