Exemplo n.º 1
0
        public GpuSmitsBVHNode[] BuildData(TriangleMeshInfo mi)
        {
            var nrm = mi.StartVertice == 0 ? -1 : mi.StartVertice - 1;
            var triData = new DLLx.TriangleData(
                scene.Triangles.ToList().GetRange(mi.StartTriangle, mi.EndTriangle - mi.StartTriangle - 1).Select(tri => new DLLx.TriInfo()
                {
                    id = 0,
                    v1 = (int)tri.v0.VertexIndex - nrm,
                    v2 = (int)tri.v1.VertexIndex - nrm,
                    v3 = (int)tri.v2.VertexIndex - nrm
                }).ToArray(),
                scene.Vertices.ToList().GetRange(mi.StartVertice, mi.EndVertice - mi.StartVertice).Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray());
            Tracer.TraceLine("Start building");
            using (bvhHandle = new BVHHandle(triData, 2u, 4, 60, 20, 0.5f))
            {
                var data = bvhHandle.GetData();
                Tracer.TraceLine("Complete!");
                return data.
                    //Except(new[]{data.First()}).
               Select(item => new GpuSmitsBVHNode()
               {
                   bbox = new AABBInfo(new Point(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Point(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)),
                   primitive = item.primitive,
                   skipIndex = item.skipIndex
               }).ToArray();
            }

        }
Exemplo n.º 2
0
        private GpuSmitsBVHNode[] BuildHandle_CPP()
        {
            var triData = new DLLx.TriangleData(
                scene.Triangles.Select(tri => new DLLx.TriInfo() { id = 0, v1 = (int)tri.v0.VertexIndex, v2 = (int)tri.v1.VertexIndex, v3 = (int)tri.v2.VertexIndex }).ToArray(),
                scene.Vertices.Select(v => new DLLx.VertInfo(v.x, v.y, v.z)).ToArray());
            Tracer.TraceLine("Start building");
            using (bvhHandle = new BVHHandle(triData, 2u, 1, 60, 20, 1f))
            {
                var data = bvhHandle.GetData();
                Tracer.TraceLine("Complete!");
                return data.
                    //Except(new[]{data.First()}).
               Select(item => new GpuSmitsBVHNode()
               {
                   bbox = new AABBInfo(new Point(item.bbox.pMin.x, item.bbox.pMin.y, item.bbox.pMin.z), new Point(item.bbox.pMax.x, item.bbox.pMax.y, item.bbox.pMax.z)),
                   primitive = item.primitive,
                   skipIndex = item.skipIndex
               }).ToArray();
            }

        }