public void TestShapeDefaultMaterial() { var s = new TestShape(); var m = s.Material; Assert.AreEqual(m, new Material()); }
public void TestShapeTransformationChanged() { var s = new TestShape(); var t = Matrix.Translation(2, 3, 4); s.Transform = t; Assert.AreEqual(s.Transform, t); }
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)); }
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)); }
public void TestShapeCustomMaterial() { var s = new TestShape(); var m = new Material(); m.Ambient = 1; s.Material = m; Assert.AreEqual(s.Material, m); }
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); }
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); }
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)); }
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)); }
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); }
public void TestShapeDefaultTransformation() { var s = new TestShape(); Assert.AreEqual(s.Transform, Matrix.Identity); }