Пример #1
0
        public void A_ray_misses_a_CSG_object()
        {
            var csg           = new CsgShape(CsgOperation.Union, new Sphere(), new Cube());
            var ray           = new Ray(new Point(0, 2, -5), new Vector(0, 0, 1));
            var intersections = csg.LocalIntersect(ray);

            intersections.Should().BeEmpty();
        }
Пример #2
0
        public void A_ray_hits_a_CSG_object()
        {
            var left          = new Sphere();
            var right         = new Sphere(transform: Matrix4x4.CreateTranslation(0, 0, 0.5));
            var csg           = new CsgShape(CsgOperation.Union, left, right);
            var ray           = new Ray(new Point(0, 0, -5), new Vector(0, 0, 1));
            var intersections = csg.LocalIntersect(ray);

            intersections.Should().HaveCount(2);
            intersections.Ts.Should().ContainInOrder(4, 6.5);
            intersections.Shapes.Should().ContainInOrder(left, right);
        }