Пример #1
0
 public void ImplicitlySettingACoordinateAsVectorShouldReturnSameValuesAsInCoordinate()
 {
     var coordinate = new Coordinate { X = 5f, Y = 6f, Z = 7f };
     Vector vector = coordinate;
     Assert.That(vector.X, Is.EqualTo(coordinate.X));
     Assert.That(vector.Y, Is.EqualTo(coordinate.Y));
     Assert.That(vector.Z, Is.EqualTo(coordinate.Z));
 }
Пример #2
0
 public void ConvertingToVectorShouldReturnSameValuesInVector()
 {
     var coordinate = new Coordinate { X = 5, Y = 6, Z = 7 };
     var vector = coordinate.ToVector();
     Assert.That(vector.X, Is.EqualTo(coordinate.X));
     Assert.That(vector.Y, Is.EqualTo(coordinate.Y));
     Assert.That(vector.Z, Is.EqualTo(coordinate.Z));
 }
Пример #3
0
 public void AddingTwoCoordinatesShouldReturnAVectorWithCorrectResult()
 {
     var c1 = new Coordinate { X = 2f, Y = 4f, Z = 6f };
     var c2 = new Coordinate { X = 1f, Y = 2f, Z = 3f };
     var vector = c1 + c2;
     Assert.That(vector.X, Is.EqualTo(3f));
     Assert.That(vector.Y, Is.EqualTo(6f));
     Assert.That(vector.Z, Is.EqualTo(9f));
 }
Пример #4
0
 public void AddingAVectorToACoordinateShouldReturnAVectorWithCorrectResult()
 {
     var c1 = new Coordinate { X = 2f, Y = 4f, Z = 6f };
     var v2 = new Vector(1f, 2f, 3f);
     var vector = c1 + v2;
     Assert.That(vector.X, Is.EqualTo(3f));
     Assert.That(vector.Y, Is.EqualTo(6f));
     Assert.That(vector.Z, Is.EqualTo(9f));
 }
Пример #5
0
 public void AddingACoordinateToAVectorShouldReturnAVectorWithCorrectResult()
 {
     var v1 = new Vector(2f, 4f, 6f);
     var c2 = new Coordinate { X = 1f, Y = 2f, Z = 3f };
     var vector = v1 + c2;
     Assert.That(vector.X, Is.EqualTo(3f));
     Assert.That(vector.Y, Is.EqualTo(6f));
     Assert.That(vector.Z, Is.EqualTo(9f));
 }
Пример #6
0
        public Camera()
        {
            Position = new Coordinate(0f, 0f, 0f);
            Target = new Coordinate(0f, 0f, -1f);
            Up = Vector.Up;
            Near = DefaultNear;
            Far = DefaultFar;
            FieldOfView = DefaultFieldOfView;
            ProjectionMatrix = null;
            UpdateDepthDivisor();

            _frustum = new Frustum();
        }
Пример #7
0
 public bool IsInView(Coordinate coordinate)
 {
     return _frustum.IsPointInFrustum(coordinate) == FrustumIntersection.Inside;
 }
Пример #8
0
        private void Position(Coordinate position, float yOffset)
        {
            var xTimeline = _positionStoryboard.Children[0] as DoubleAnimation;
            var yTimeline = _positionStoryboard.Children[1] as DoubleAnimation;
            var zTimeline = _positionStoryboard.Children[2] as DoubleAnimation;
            xTimeline.From = Game.Camera.Position.X;
            xTimeline.To = position.X;

            yTimeline.From = Game.Camera.Position.Y;
            yTimeline.To = position.Y+yOffset;

            zTimeline.From = Game.Camera.Position.Z;
            zTimeline.To = position.Z;

            _positionStoryboard.Begin();
        }
Пример #9
0
        private void Target(Coordinate target)
        {
            var xTimeline = _targetStoryboard.Children[0] as DoubleAnimation;
            var yTimeline = _targetStoryboard.Children[1] as DoubleAnimation;
            var zTimeline = _targetStoryboard.Children[2] as DoubleAnimation;
            xTimeline.From = Game.Camera.Target.X;
            xTimeline.To = target.X;

            yTimeline.From = Game.Camera.Target.Y;
            yTimeline.To = target.Y;

            zTimeline.From = Game.Camera.Target.Z;
            zTimeline.To = target.Z;

            _targetStoryboard.Begin();
        }
Пример #10
0
 public void SubtractingAVectorFromACoordinateShouldReturnAVectorWithCorrectResult()
 {
     var c1 = new Coordinate { X = 2f, Y = 4f, Z = 6f };
     var v2 = new Vector(1f, 2f, 3f);
     var vector = c1 - v2;
     Assert.That(vector.X, Is.EqualTo(1f));
     Assert.That(vector.Y, Is.EqualTo(2f));
     Assert.That(vector.Z, Is.EqualTo(3f));
 }
Пример #11
0
 public void SubtractingACoordinateFromAVectorShouldReturnAVectorWithCorrectResult()
 {
     var v1 = new Vector(2f, 4f, 6f);
     var c2 = new Coordinate { X = 1f, Y = 2f, Z = 3f };
     var vector = v1 - c2;
     Assert.That(vector.X, Is.EqualTo(1f));
     Assert.That(vector.Y, Is.EqualTo(2f));
     Assert.That(vector.Z, Is.EqualTo(3f));
 }