예제 #1
0
        public void DefaultMaterial()
        {
            var s        = new TestShape();
            var expected = new Material();

            Assert.Equal(expected, s.Material);
        }
예제 #2
0
파일: GroupTests.cs 프로젝트: basp/pixie
        public void AddChildToGroup()
        {
            var g = new Group();
            var s = new TestShape();

            g.Add(s);
            Assert.NotEmpty(g);
            Assert.Contains(s, g);
            Assert.Equal(g, s.Parent);
        }
예제 #3
0
        public void AssignTransformation()
        {
            var s = new TestShape()
            {
                Transform = Transform.Translate(2, 3, 4),
            };

            var expected = Transform.Translate(2, 3, 4);

            Assert.Equal(expected, s.Transform);
        }
예제 #4
0
        public void IntersectTranslatedShapeWithRay()
        {
            var r = new Ray(Vector4.CreatePosition(0, 0, -5), Vector4.CreateDirection(0, 0, 1));
            var s = new TestShape();

            s.Transform = Transform.Translate(5, 0, 0);
            var xs       = s.Intersect(r);
            var savedRay = s.SavedRay.Value;

            Assert.Equal(Vector4.CreatePosition(-5, 0, -5), savedRay.Origin);
            Assert.Equal(Vector4.CreateDirection(0, 0, 1), savedRay.Direction);
        }
예제 #5
0
        public void TestShapeHasArbitraryBounds()
        {
            var s   = new TestShape();
            var box = s.GetBounds();

            Assert.Equal(
                Vector4.CreatePosition(-1, -1, -1),
                box.Min);
            Assert.Equal(
                Vector4.CreatePosition(1, 1, 1),
                box.Max);
        }
예제 #6
0
파일: GroupTests.cs 프로젝트: basp/pixie
        public void IntersectGroupTestsChildrenIfBoxHit()
        {
            var child = new TestShape();
            var shape = new Group();

            shape.Add(child);
            var r = new Ray(
                Vector4.CreatePosition(0, 0, -5),
                Vector4.CreateDirection(0, 0, 1));
            var xs = shape.Intersect(r);

            Assert.NotNull(child.SavedRay);
        }
예제 #7
0
파일: CsgTests.cs 프로젝트: basp/pixie
        public void IntersectCsgTestsChildrenIfBoxHit()
        {
            var left  = new TestShape();
            var right = new TestShape();
            var shape = new Csg(Operation.Difference, left, right);
            var r     = new Ray(
                Vector4.CreatePosition(0, 0, -5),
                Vector4.CreateDirection(0, 0, 1));
            var xs = shape.Intersect(r);

            Assert.NotNull(left.SavedRay);
            Assert.NotNull(right.SavedRay);
        }
예제 #8
0
        public void ComputeNormalOnTranslatedShape()
        {
            var s = new TestShape()
            {
                Transform = Transform.Translate(0, 1, 0),
            };

            var          n        = s.GetNormal(Vector4.CreatePosition(0, 1.70711, -0.70711));
            var          expected = Vector4.CreateDirection(0, 0.70711, -0.70711);
            const double eps      = 0.00001;
            var          comparer = Vector4.GetEqualityComparer(eps);

            Assert.Equal(expected, n, comparer);
        }
예제 #9
0
        public void AssigningMaterial()
        {
            var m = new Material
            {
                Ambient = 1,
            };

            var s = new TestShape()
            {
                Material = m,
            };

            Assert.Equal(m, s.Material);
        }
예제 #10
0
        public void ComputeNormalOnTransformedShape()
        {
            var s = new TestShape()
            {
                Transform =
                    Transform.Scale(1, 0.5, 1) *
                    Transform.RotateZ(Math.PI / 5),
            };

            var          n        = s.GetNormal(Vector4.CreatePosition(0, Math.Sqrt(2) / 2, -Math.Sqrt(2) / 2));
            var          expected = Vector4.CreateDirection(0, 0.97014, -0.24254);
            const double eps      = 0.00001;
            var          comparer = Vector4.GetEqualityComparer(eps);

            Assert.Equal(expected, n, comparer);
        }
예제 #11
0
        public void DefaultTransformation()
        {
            var s = new TestShape();

            Assert.Equal(Matrix4x4.Identity, s.Transform);
        }
예제 #12
0
        public void ShapeHasParentAttribute()
        {
            var s = new TestShape();

            Assert.Null(s.Parent);
        }