Ejemplo n.º 1
0
        private void my3DxMouse_MotionEvent(object sender, _3DxMouse._3DxMouse.MotionEventArgs e)
        {
            int tx = 0, ty = 0, tz = 0, rx = 0, ry = 0, rz = 0;

            // Translation Vector?
            if (e.TranslationVector != null)
            {
                tx = e.TranslationVector.X;
                ty = e.TranslationVector.Y;
                tz = e.TranslationVector.Z;
            }

            // Rotation Vector?
            if (e.RotationVector != null)
            {
                rx = e.RotationVector.X;
                ry = e.RotationVector.Y;
                rz = e.RotationVector.Z;
            }

            float scale = 1f;

            if (manager.FastMove)
            {
                scale = 100f;
            }

            float f_tx = tx * MOUSE_SPEED_FACTOR * scale;
            float f_ty = -tz * MOUSE_SPEED_FACTOR * scale;  // Note y,z swapped and z negative
            float f_tz = ty * MOUSE_SPEED_FACTOR * scale;
            float f_rx = rx * ROLL_SPEED_FACTOR;
            float f_ry = ry * ROLL_SPEED_FACTOR;
            float f_rz = rz * ROLL_SPEED_FACTOR;

            Vector3 vec = new Vector3(f_tx, f_ty, f_tz);

            cam.MoveRelative(vec);

            cam.Pitch(f_rx);
            cam.Roll(f_ry);
            cam.Yaw(-f_rz);   // Note negative
        }
Ejemplo n.º 2
0
        //
        // 3D Mouse
        //
        private void MotionEvent(object sender, _3DxMouse._3DxMouse.MotionEventArgs e)
        {
            if (e.RotationVector != null)
            {
                DateTime currentTime = DateTime.Now;
                TimeSpan delta       = currentTime - m_lastUpdate;

                // Let's use the z rotation to control the volume
                int volume = e.RotationVector.Z;
                Debug.WriteLine("Volume: " + volume.ToString());
                if (delta.Milliseconds > 200 && Math.Abs(volume) > 300)
                {
                    if (volume > 0)
                    {
                        VolumeUp();
                    }
                    else if (volume < 0)
                    {
                        VolumeDown();
                    }
                    m_lastUpdate = currentTime;
                }
            }
        }