public void DefaultMaterial() { var s = new TestShape(); var expected = new Material(); Assert.Equal(expected, s.Material); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void AssigningMaterial() { var m = new Material { Ambient = 1, }; var s = new TestShape() { Material = m, }; Assert.Equal(m, s.Material); }
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); }
public void DefaultTransformation() { var s = new TestShape(); Assert.Equal(Matrix4x4.Identity, s.Transform); }
public void ShapeHasParentAttribute() { var s = new TestShape(); Assert.Null(s.Parent); }