Пример #1
0
        public override uint MouseDown(MouseEventArgs e, I3DControl control)
        {
            if (OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft) &&
                e.Button == MouseButtons.Right &&
                control.PickingDepth != control.ZFar)
            {
                float delta = control.PickingDepth + control.CameraDistance;
                control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
                control.CameraTarget += Vector3.UnitY * (float)Math.Sin(control.CamRotY) * delta;
                control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;

                Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y);

                float factoffX = (float)(-normCoords.X * control.PickingDepth) * control.FactorX;
                float factoffY = (float)(-normCoords.Y * control.PickingDepth) * control.FactorY;

                control.CameraTarget += Vector3.UnitX * (float)Math.Cos(control.CamRotX) * factoffX;
                control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
                control.CameraTarget -= Vector3.UnitY * (float)Math.Cos(control.CamRotY) * factoffY;
                control.CameraTarget += Vector3.UnitZ * (float)Math.Sin(control.CamRotX) * factoffX;
                control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
            }
            base.MouseDown(e, control);
            return(UPDATE_CAMERA);
        }
Пример #2
0
        public override uint MouseWheel(MouseEventArgs e, I3DControl control)
        {
            depth = control.PickingDepth;
            float delta = ((float)e.Delta * Math.Min(0.01f, depth / 500f));

            control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;
            control.CameraTarget += Vector3.UnitY * (float)Math.Sin(control.CamRotY) * delta;
            control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Cos(control.CamRotY) * delta;

            Vector2 normCoords = control.NormMouseCoords(e.Location.X, e.Location.Y);

            float factoffX = (float)(-normCoords.X * delta) * control.FactorX;
            float factoffY = (float)(-normCoords.Y * delta) * control.FactorY;

            control.CameraTarget += Vector3.UnitX * (float)Math.Cos(control.CamRotX) * factoffX;
            control.CameraTarget -= Vector3.UnitX * (float)Math.Sin(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
            control.CameraTarget -= Vector3.UnitY * (float)Math.Cos(control.CamRotY) * factoffY;
            control.CameraTarget += Vector3.UnitZ * (float)Math.Sin(control.CamRotX) * factoffX;
            control.CameraTarget += Vector3.UnitZ * (float)Math.Cos(control.CamRotX) * (float)Math.Sin(control.CamRotY) * factoffY;
            return(UPDATE_CAMERA);
        }