コード例 #1
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        public void ZoomIn(float amount)
        {
            Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(Fwd * amount));

            if (CheckNewPosition(newPos))
            {
                Position = newPos;
                Theta    = SetTheta(newPos);
            }
        }
コード例 #2
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        public void PanDown(float amount)
        {
            Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(-Up * amount));

            if (CheckNewPosition(newPos))
            {
                Position = newPos;
                Target   = Vector3.Transform(Target, Matrix.CreateTranslation(-Up * amount));
                Theta    = SetTheta(newPos);
            }
        }
コード例 #3
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        private bool CheckNewPosition(Vector3 newPos)
        {
            AngularRange3 newTheta = SetTheta(newPos);

            return(Math.Abs(newPos.X) <= Math.Abs(Range.Position.Max.X) &&
                   Math.Abs(newPos.X) >= Math.Abs(Range.Position.Min.X) &&
                   Math.Abs(newPos.Y) <= Math.Abs(Range.Position.Max.Y) &&
                   Math.Abs(newPos.Y) >= Math.Abs(Range.Position.Min.Y) &&
                   Math.Abs(newPos.Z) <= Math.Abs(Range.Position.Max.Z) &&
                   Math.Abs(newPos.Z) >= Math.Abs(Range.Position.Min.Z) &&
                   newTheta.Altitude.Max <= Range.Theta.Altitude.Max &&
                   newTheta.Altitude.Max >= Range.Theta.Altitude.Min &&
                   newTheta.Azimuth.Max <= Range.Theta.Azimuth.Max &&
                   newTheta.Azimuth.Max >= Range.Theta.Azimuth.Min);
        }
コード例 #4
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        public void PanRight(float amount)
        {
            Vector3 right = Vector3.Cross(Up, Fwd) * -1;

            right.Normalize();

            Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(right * amount));

            if (CheckNewPosition(newPos))
            {
                Position = newPos;
                Target   = Vector3.Transform(Target, Matrix.CreateTranslation(right * amount));
                Theta    = SetTheta(newPos);
            }
        }
コード例 #5
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        public void OrbitVertically(float amount)
        {
            Vector3 left = Vector3.Cross(Up, Position);

            left.Normalize();
            Vector3 newPos = Vector3.Transform(Position, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));

            if (CheckNewPosition(newPos))
            {
                Position = newPos;
                Up       = Vector3.Transform(Up, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));
                Fwd      = Vector3.Transform(Fwd, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));
                Theta    = SetTheta(newPos);
            }
        }
コード例 #6
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        private AngularRange3 SetTheta(Vector3 position)
        {
            Vector3 norm = position;

            norm.Normalize();

            float azimuth = 0f;

            if (norm.Z > 0)
            {
                if (norm.X <= 0)
                {
                    azimuth = MathHelper.Pi + (float)Math.Abs(Math.Asin(norm.X)); // quad 3
                }
                else
                {
                    azimuth = MathHelper.Pi - (float)Math.Abs(Math.Asin(norm.X)); // quad 2
                }
            }
            else if (norm.X < 0 && norm.Z < 0)
            {
                azimuth = MathHelper.TwoPi - (float)Math.Abs(Math.Asin(norm.X)); // quad 4
            }
            else
            {
                azimuth = (float)Math.Abs(Math.Asin(norm.X)); // quad 1
            }
            var theta = new AngularRange3()
            {
                Azimuth = new AngularRange()
                {
                    Min = 0f, Max = azimuth
                },
                Altitude = new AngularRange()
                {
                    Min = 0f, Max = (float)Math.Asin(Vector3.Dot(norm, Vector3.Up))
                }
            };

            return(theta);
        }
コード例 #7
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
 public void OrbitVertically(float amount)
 {
     Vector3 left = Vector3.Cross(Up, Position);
     left.Normalize();
     Vector3 newPos = Vector3.Transform(Position, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));
     if (CheckNewPosition(newPos))
     {
         Position = newPos;
         Up = Vector3.Transform(Up, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));
         Fwd = Vector3.Transform(Fwd, Matrix.CreateFromAxisAngle(left, MathHelper.ToRadians(amount)));
         Theta = SetTheta(newPos);
     }
 }
コード例 #8
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        private AngularRange3 SetTheta(Vector3 position)
        {
            Vector3 norm = position;
            norm.Normalize();

            float azimuth = 0f;

            if (norm.Z > 0)
            {
                if (norm.X <= 0)
                    azimuth = MathHelper.Pi + (float)Math.Abs(Math.Asin(norm.X)); // quad 3
                else
                    azimuth = MathHelper.Pi - (float)Math.Abs(Math.Asin(norm.X)); // quad 2
            }
            else if (norm.X < 0 && norm.Z < 0)
                azimuth = MathHelper.TwoPi - (float)Math.Abs(Math.Asin(norm.X)); // quad 4
            else
                azimuth = (float)Math.Abs(Math.Asin(norm.X)); // quad 1

            var theta = new AngularRange3()
            {
                Azimuth = new AngularRange() { Min = 0f, Max = azimuth },
                Altitude = new AngularRange() { Min = 0f, Max = (float)Math.Asin(Vector3.Dot(norm, Vector3.Up)) }
            };
            return theta;
        }
コード例 #9
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
 public void PanDown(float amount)
 {
     Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(-Up * amount));
     if (CheckNewPosition(newPos))
     {
         Position = newPos;
         Target = Vector3.Transform(Target, Matrix.CreateTranslation(-Up * amount));
         Theta = SetTheta(newPos);
     }
 }
コード例 #10
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
        public void PanRight(float amount)
        {
            Vector3 right = Vector3.Cross(Up, Fwd) * -1;
            right.Normalize();

            Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(right * amount));
            if (CheckNewPosition(newPos))
            {
                Position = newPos;
                Target = Vector3.Transform(Target, Matrix.CreateTranslation(right * amount));
                Theta = SetTheta(newPos);
            }
        }
コード例 #11
0
ファイル: Camera.cs プロジェクト: odinhaus/Genesis
 public void ZoomIn(float amount)
 {
     Vector3 newPos = Vector3.Transform(Position, Matrix.CreateTranslation(Fwd * amount));
     if (CheckNewPosition(newPos))
     {
         Position = newPos;
         Theta = SetTheta(newPos);
     }
 }