Пример #1
0
        public void CorrectRayOnCircle()
        {
            var testPartPath = TestContext.CurrentContext.ResolveProjectPath(new string[] { "..", "..", "..", "examples", "RayTracerTest" });

            var  testPart      = Path.Combine(testPartPath, "circle_100x100_centered.stl");
            Mesh simpleMesh    = StlProcessing.Load(testPart, CancellationToken.None);
            var  bvhCollection = MeshToBVH.Convert(simpleMesh);

            var scene = new Scene();

            scene.shapes.Add(bvhCollection);

            RayTracer raytracer = new RayTracer()
            {
                AntiAliasing  = AntiAliasing.None,
                MultiThreaded = false,
            };

            int samples = 40;
            var advance = MathHelper.Tau / samples;

            TestSingleAngle(scene, raytracer, advance, 15);

            for (int i = 0; i < samples; i++)
            {
                TestSingleAngle(scene, raytracer, advance, i);
            }
        }
Пример #2
0
        private static void TestSingleAngle(Scene scene, RayTracer raytracer, double advance, int i)
        {
            var sampleXY = new Vector2(48, 0);

            sampleXY.Rotate(advance * i);
            Vector3 rayOrigin = new Vector3(sampleXY, 10);

            Ray           ray         = new Ray(rayOrigin, -Vector3.UnitZ);
            IntersectInfo primaryInfo = raytracer.TracePrimaryRay(ray, scene);

            Assert.IsTrue(primaryInfo.HitType == IntersectionType.FrontFace, "always have a hit");
        }