示例#1
0
        public virtual void ComputeViewMatrix()
        {
            double lat1 = _latitude.Degrees;
            double lon1 = _longitude.Degrees;


            EyeDiff.X = SMath.DegreesToRadians(_latitude.Degrees - lat1);
            EyeDiff.Y = SMath.DegreesToRadians(_longitude.Degrees - lon1);

            ReferenceCenter = SMath.SphericalToCartesianV3D(
                _latitude.Degrees,
                _longitude.Degrees,
                WorldRadius);


            if (World.Settings.Project == Projection.OrthoGraghics)
            {
                //lat1 = 0;
                //lon1 = 0;

                EyeDiff.X = 0;
                EyeDiff.Y = 0;
            }

            Vector3d defaultPosition = SMath.SphericalToCartesianV3D(lat1, lon1, _worldRadius);


            m_ViewMatrix = Matrix4d.LookAtRH(
                defaultPosition,
                Vector3d.Empty,
                cameraUpVector);
            //TODO JHJ 这是干什么的  有什么用
            m_ViewMatrix *= Matrix4d.Translation(0, 0, _worldRadius);
            m_ViewMatrix *= Matrix4d.RotationYawPitchRoll(-EyeDiff.Y, EyeDiff.X, 0);
            m_ViewMatrix *= Matrix4d.Translation(0, 0, -_worldRadius);

            m_ViewMatrix *= Matrix4d.RotationYawPitchRoll(
                0,
                -_tilt.Radians,
                this._heading.Radians);
            m_ViewMatrix *= Matrix4d.Translation(0, 0, (-this._distance));
            if (World.Settings.Project == Projection.Perspective)
            {
                m_ViewMatrix *= Matrix4d.RotationZ(this._bank.Radians);
            }
            else
            {
                m_ViewMatrix *= Matrix4d.RotationZ(this._bank.Radians);
            }

            // Extract camera position
            Matrix4d cam = Matrix4d.Invert(m_ViewMatrix);

            _position = new Vector3d(cam[3, 0], cam[3, 1], cam[3, 2]);
        }
示例#2
0
        public static Matrix4d RotationYawPitchRoll(double yaw, double pitch, double roll)
        {
            //Matrix4d test = ConvertDX.ToMatrix4d(Microsoft.DirectX.Matrix.RotationYawPitchRoll((float)yaw, (float)pitch, (float)roll));

            // This can be simplified to a single matrix constructor by hand if it becomes a performance issue

            Matrix4d rollMat  = Matrix4d.RotationZ(roll);
            Matrix4d pitchMat = Matrix4d.RotationX(pitch);
            Matrix4d yawMat   = Matrix4d.RotationY(yaw);

            Matrix4d solution = rollMat * pitchMat * yawMat;

            return(solution);
        }