Esempio n. 1
0
        public void TestShapeDefaultMaterial()
        {
            var s = new TestShape();
            var m = s.Material;

            Assert.AreEqual(m, new Material());
        }
Esempio n. 2
0
        public void TestShapeTransformationChanged()
        {
            var s = new TestShape();
            var t = Matrix.Translation(2, 3, 4);

            s.Transform = t;
            Assert.AreEqual(s.Transform, t);
        }
Esempio n. 3
0
        public void TestShapeBounds()
        {
            var shape = new TestShape();
            var box   = shape.BoundsOf;

            Assert.AreEqual(box.Min, new Point(-1, -1, -1));
            Assert.AreEqual(box.Max, new Point(1, 1, 1));
        }
Esempio n. 4
0
        public void TestShapeTranslatedNormal()
        {
            var s = new TestShape();

            s.Transform = Matrix.Translation(0, 1, 0);

            var n = s.NormalAt(new Point(0, 1.70711, -0.70711));

            Assert.AreEqual(n, new Vector(0, 0.70711, -0.70711));
        }
Esempio n. 5
0
        public void TestShapeCustomMaterial()
        {
            var s = new TestShape();
            var m = new Material();

            m.Ambient  = 1;
            s.Material = m;

            Assert.AreEqual(s.Material, m);
        }
Esempio n. 6
0
        public void TestGroupIntersectHit()
        {
            var child = new TestShape();
            var shape = new Group();

            shape.Add(child);
            var r  = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var xs = shape.Intersect(r);

            Assert.IsNotNull(child.SavedRay);
        }
Esempio n. 7
0
        public void TestCsgBBIntersectHit()
        {
            var left  = new TestShape();
            var right = new TestShape();
            var shape = new CSG(CsgOperation.Difference, left, right);
            var r     = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var xs    = shape.Intersect(r);

            Assert.IsNotNull(left.SavedRay);
            Assert.IsNotNull(right.SavedRay);
        }
Esempio n. 8
0
        public void TestShapeScaled()
        {
            var r = new Ray(new Point(0, 0, -5), Vector.VectorZ);
            var s = new TestShape();

            s.Transform = Matrix.Scaling(2, 2, 2);
            var xs = s.Intersect(r);

            Assert.AreEqual(s.SavedRay.Origin, new Point(0, 0, -2.5));
            Assert.AreEqual(s.SavedRay.Direction, new Vector(0, 0, 0.5));
        }
Esempio n. 9
0
        public void TestShapeTransformedNormal()
        {
            var s = new TestShape();
            var m = Matrix.Scaling(1, 0.5, 1) * Matrix.RotationZ(Math.PI / 5);

            s.Transform = m;

            var value = MathHelper.SQRT2 / 2.0;
            var n     = s.NormalAt(new Point(0, value, -value));

            Assert.AreEqual(n, new Vector(0, 0.97014, -0.24254));
        }
Esempio n. 10
0
        public void TestShapeTranslated()
        {
            var r = new Ray(new Point(0, 0, -5), Vector.VectorZ);
            var s = new TestShape();

            s.Transform = Matrix.Translation(5, 0, 0);
            var xs = s.Intersect(r);

            // Bounding box broke this...
            //Assert.AreEqual(s.SavedRay.Origin, new Point(-5, 0, -5));
            //Assert.AreEqual(s.SavedRay.Direction, Vector.VectorZ);
            Assert.IsNull(s.SavedRay);
        }
Esempio n. 11
0
        public void TestShapeDefaultTransformation()
        {
            var s = new TestShape();

            Assert.AreEqual(s.Transform, Matrix.Identity);
        }