public void Update(double dt)
        {
            if (m_player == null)
            {
                return;
            }

            var layoutC = m_player.FindComponent <LayoutComponent>();

            Debug.Assert(layoutC != null, "");

            Matrix headRotTrans = Matrix.Identity;

            if (m_isEnableHeadRotation)
            {
                var gameSys = GameSystem.GetInstance();
                switch (gameSys.Config.InputDevice)
                {
                case GameConfig.UserInputDevices.MouseKeyboard:
                    break;

                case GameConfig.UserInputDevices.Pad:
                {
                    IPadInputSource src       = InputSystem.GetInstance().Pad;
                    var             thumbDir  = src.RightThumbInput.Direction;
                    float           magnitude = src.RightThumbInput.NormalizedMagnitude;
                    if (magnitude >= MinimumPadMagnitude)
                    {
                        float maxAngle = 0.9f;
                        m_headRotAngle.X = Math.Min(Math.Max(m_headRotAngle.X + thumbDir.Y * (float)dt, -maxAngle), maxAngle);
                        m_headRotAngle.Y = Math.Min(Math.Max(m_headRotAngle.Y + thumbDir.X * (float)dt, -maxAngle), maxAngle);
                        m_headRotAngle.Z = 0;
                    }
                    else
                    {
                        m_headRotAngle *= 0.9f;
                    }
                }
                break;
                }

                headRotTrans = Matrix.RotationYawPitchRoll(m_headRotAngle.Y, m_headRotAngle.X, m_headRotAngle.Z);
            }



            //var markerC = m_player.FindComponent<ModelMarkerComponent>();
            //Debug.Assert(markerC != null, "");
            //var mtx = markerC.FindMarkerMatrix(10) * layoutC.Transform;

            var mtx = headRotTrans * layoutC.Transform * Matrix.Translation(0, 1, 0);

            Vector3 eye, lookAt, up;

            eye      = mtx.TranslationVector + Vector3.UnitY;
            lookAt   = eye + mtx.Forward * Zoom;
            up       = Vector3.UnitY;
            m_camera = new DrawSystem.CameraData(eye, lookAt, up);
        }
Exemple #2
0
        public FixedCamera()
        {
            Vector3 eye, lookAt, up;

            eye      = new Vector3(0, 2.5f, -10);
            lookAt   = new Vector3(0, 2.5f, 0);
            up       = Vector3.UnitY;
            m_camera = new DrawSystem.CameraData(eye, lookAt, up);
        }
Exemple #3
0
        public DrawSystem.CameraData GetCameraData()
        {
            DrawSystem.CameraData result = new DrawSystem.CameraData();
            if (m_camera != null)
            {
                result = m_camera.GetCameraData();
            }

            return(result);
        }
Exemple #4
0
        public DrawSystem.CameraData[] GetEyePoses()
        {
            var result = new DrawSystem.CameraData[2];

            for (int eyeIndex = 0; eyeIndex < 2; ++eyeIndex)
            {
                LibOVR.ovrPosef eyePose = m_tmpEyePoses[eyeIndex];

                // Posef is a right-hand system, so we convert to left-hand system
                var q = new Quaternion(-eyePose.Orientation.x, -eyePose.Orientation.y, eyePose.Orientation.z, eyePose.Orientation.w);
                var v = new Vector3(eyePose.Position.x, eyePose.Position.y, -eyePose.Position.z);

                var forward = Vector3.Transform(Vector3.ForwardLH, q);
                var up      = Vector3.Transform(Vector3.Up, q);

                result[eyeIndex] = new DrawSystem.CameraData(v, v + forward, up);
            }

            return(result);
        }