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;
}