Tango.Tango3DReconstruction.ExtractMeshSegment C# (CSharp) Method

ExtractMeshSegment() private method

Extract a mesh for a single grid index, into a suitable format for Unity Mesh.
private ExtractMeshSegment ( GridIndex gridIndex, Vector3 vertices, Vector3 normals, Color32 colors, int triangles, int &numVertices, int &numTriangles ) : Status
gridIndex GridIndex Grid index to extract.
vertices Vector3 On successful extraction this will get filled out with the vertex positions.
normals Vector3 On successful extraction this will get filled out whith vertex normals.
colors UnityEngine.Color32 On successful extraction this will get filled out with vertex colors.
triangles int On succesful extraction this will get filled out with vertex indexes.
numVertices int Number of vertexes filled out.
numTriangles int Number of triangles filled out.
return Status
        internal Status ExtractMeshSegment(
            GridIndex gridIndex, Vector3[] vertices, Vector3[] normals, Color32[] colors, int[] triangles,
            out int numVertices, out int numTriangles)
        {
            numVertices = 0;
            numTriangles = 0;
            int result = API.Tango3DR_extractPreallocatedMeshSegment(
                m_context, ref gridIndex, vertices.Length, triangles.Length / 3, vertices, triangles, normals, colors,
                out numVertices, out numTriangles);

            // NOTE: The 3D Reconstruction library does not handle left handed matrices correctly.  For now, transform
            // into the Unity world space after extraction and account for winding order changes.
            for (int it = 0; it < numVertices; ++it)
            {
                vertices[it] = m_unityWorld_T_startService.MultiplyPoint(vertices[it]);
            }

            for (int it = 0; it < numTriangles; ++it)
            {
                int temp = triangles[(it * 3) + 0];
                triangles[(it * 3) + 0] = triangles[(it * 3) + 1];
                triangles[(it * 3) + 1] = temp;
            }

            return (Status)result;
        }