Beispiel #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);
            }
        }
Beispiel #2
0
        private void AddTestStl()
        {
            Stopwatch loadTime = new Stopwatch();

            loadTime.Start();

            PolygonMesh.Mesh simpleMesh = StlProcessing.Load("Simple.stl");
            //PolygonMesh.Mesh simpleMesh = StlProcessing.Load("Complex.stl");
            //PolygonMesh.Mesh simpleMesh = StlProcessing.Load("bunny.stl");
            //PolygonMesh.Mesh simpleMesh = StlProcessing.Load("bunny_binary.stl");

            loadTime.Stop();

            timingStrings.Add("Time to load STL {0:0.0}s".FormatWith(loadTime.Elapsed.TotalSeconds));

            Stopwatch bvhTime = new Stopwatch();

            bvhTime.Start();
            IPrimitive bvhCollection = MeshToBVH.Convert(simpleMesh);

            bvhTime.Stop();

            timingStrings.Add("Time to create BVH {0:0.0}s".FormatWith(bvhTime.Elapsed.TotalSeconds));

            renderCollection.Add(bvhCollection);
        }
Beispiel #3
0
        private void AddTestMesh(List <MeshGroup> meshGroups)
        {
            if (meshGroups != null)
            {
                AxisAlignedBoundingBox totalMeshBounds = GetAxisAlignedBoundingBox(meshGroups);
                loadedMeshGroups = meshGroups;
                Vector3 meshCenter = totalMeshBounds.Center;
                foreach (MeshGroup meshGroup in meshGroups)
                {
                    meshGroup.Translate(-meshCenter);
                }

                ScaleMeshToView(loadedMeshGroups);

                RGBA_Bytes partColor = new RGBA_Bytes(0, 130, 153);
                partColor = RGBA_Bytes.White;
                IPrimitive bvhCollection = MeshToBVH.Convert(loadedMeshGroups, new SolidMaterial(partColor.GetAsRGBA_Floats(), .01, 0.0, 2.0));

                renderCollection.Add(bvhCollection);
            }
        }