示例#1
0
        private void UpdateView()
        {
            mForward = mTarget - Position;
            mForward.Normalize();
            mViewNoTranspose = LeftHanded == false?Matrix.LookAtRH(Position, mTarget, mUp) : Matrix.LookAtLH(Position, mTarget, mUp);

            Matrix.Invert(ref mViewNoTranspose, out mViewInverted);
            Matrix.Transpose(ref mViewNoTranspose, out mMatView);
            if (ViewChanged != null)
            {
                ViewChanged(this, mMatView);
            }

            mFrustum.Update(mViewNoTranspose, mProjNoTranspose);
        }
示例#2
0
        /// <summary>
        /// 更新照相机
        /// </summary>
        /// <param name="device"></param>
        public virtual void Update(Device device)
        {
            viewPort = device.Viewport;

            Point3d p = Quaternion4d.QuaternionToEuler(m_Orientation);

            if (!double.IsNaN(p.Y))
            {
                this._latitude.Radians = p.Y;
            }
            if (!double.IsNaN(p.X))
            {
                this._longitude.Radians = p.X;
            }
            if (!double.IsNaN(p.Z))
            {
                this._heading.Radians = p.Z;
            }

            ComputeProjectionMatrix(viewPort);
            ComputeViewMatrix();
            device.Transform.Projection = m_ProjectionMatrix;
            device.Transform.View       = m_ViewMatrix;
            device.Transform.World      = m_WorldMatrix;

            ViewFrustum.Update(
                Matrix.Multiply(m_absoluteWorldMatrix,
                                Matrix.Multiply(m_absoluteViewMatrix, m_absoluteProjectionMatrix)));

            // Old view range (used in quadtile logic)
            double factor = (this._altitude) / this._worldRadius;

            if (factor > 1)
            {
                viewRange = Angle.FromRadians(Math.PI);
            }
            else
            {
                viewRange = Angle.FromRadians(Math.Abs(Math.Asin((this._altitude) / this._worldRadius)) * 2);
            }

            // True view range
            if (factor < 1)
            {
                trueViewRange = Angle.FromRadians(Math.Abs(Math.Asin((this._distance) / this._worldRadius)) * 2);
            }
            else
            {
                trueViewRange = Angle.FromRadians(Math.PI);
            }

            World.Settings.cameraAltitudeMeters = Altitude;
            World.Settings.cameraLatitude       = _latitude;
            World.Settings.cameraLongitude      = _longitude;
            World.Settings.cameraHeading        = _heading;
            World.Settings.cameraTilt           = _tilt;
        }
示例#3
0
        private void UpdateView()
        {
            mForward = mTarget - Position;
            mForward.Normalize();

            mView = (LeftHanded == false)
                ? Matrix.LookAtRH(Position, mTarget, mUp)
                : Matrix.LookAtLH(Position, mTarget, mUp);
            Matrix.Invert(ref mView, out mViewInverse);

            mFrustum.Update(mView, mProj);
            mViewProj = mView * mProj;

            if (ViewChanged != null)
            {
                ViewChanged(this, mView);
            }
        }
示例#4
0
 public void CopyFrom(Camera fromOther)
 {
     AspectRatio          = fromOther.AspectRatio;
     WindowSize           = fromOther.WindowSize;
     Location             = fromOther.Location;
     Pitch                = fromOther.Pitch;
     Yaw                  = fromOther.Yaw;
     ProjectionMatrix     = fromOther.ProjectionMatrix;
     CameraViewMatrix     = fromOther.CameraViewMatrix;
     ViewProjectionMatrix = fromOther.ViewProjectionMatrix;
     ViewFrustum.Update(ViewProjectionMatrix);
 }
示例#5
0
 private void RecalculateMatrices()
 {
     CameraViewMatrix     = Matrix4x4.CreateScale(Scale) * Matrix4x4.CreateLookAt(Location, Location + GetForwardVector(), Vector3.UnitZ);
     ViewProjectionMatrix = CameraViewMatrix * ProjectionMatrix;
     ViewFrustum.Update(ViewProjectionMatrix);
 }