private void glControl_MouseMove(object sender, MouseEventArgs e)
{
if (dragging)
{
int deltaX = e.X - dragX;
int deltaY = e.Y - dragY;
float pixelToM = 1f / 75f;
if (e.Button == MouseButtons.Left)
{
if (ModifierKeys == Keys.None)
{
//Only touch if we arn't doing anything else
object picked;
int LeftclickedFaceID;
if (TryPick(e.X, e.Y, out picked, out LeftclickedFaceID))
{
if (picked is RenderPrimitive)
TryTouchObject((RenderPrimitive)picked);
}
else
TryEndTouchObject();
}
// Pan
if (ModifierKeys == Keys.Control || ModifierKeys == (Keys.Alt | Keys.Control | Keys.Shift))
{
Camera.Pan(deltaX * pixelToM * 2, deltaY * pixelToM * 2);
}
// Alt-zoom (up down move camera closer to target, left right rotate around target)
if (ModifierKeys == Keys.Alt)
{
Camera.MoveToTarget(deltaY * pixelToM);
Camera.Rotate(-deltaX * pixelToM, true);
}
// Rotate camera in a vertical circle around target on up down mouse movement
if (ModifierKeys == (Keys.Alt | Keys.Control))
{
Camera.Rotate(deltaY * pixelToM, false);
Camera.Rotate(-deltaX * pixelToM, true);
}
}
dragX = e.X;
dragY = e.Y;
}
}