public static SubMesh[] GenerateSubMeshes(IExportContainer container, Mesh instanceMesh, ref LOD origin) { int offset = 0; SubMesh[] instances = new SubMesh[origin.MeshData.Length]; for (int i = 0; i < origin.MeshData.Length; i++) { MeshData meshData = origin.MeshData[i]; SubMesh instance = new SubMesh(); instance.FirstByte = offset; #warning TODO: stripping int indexCount = meshData.Faces.Length * 3; instance.IndexCount = indexCount; instance.Topology = MeshTopology.Triangles; if (SubMesh.HasTriangleCount(container.ExportVersion)) { instance.TriangleCount = meshData.Faces.Length; } if (SubMesh.HasVertex(container.ExportVersion)) { SubMeshConverter.CalculateSubMeshVertexRangeAndBounds(container.ExportVersion, instanceMesh, ref instance); } instances[i] = instance; offset += indexCount * sizeof(ushort); } return(instances); }
private static SubMesh Convert(IExportContainer container, Mesh instanceMesh, ref SubMesh origin) { SubMesh instance = new SubMesh(); instance.FirstByte = origin.FirstByte; instance.IndexCount = origin.IndexCount; instance.Topology = origin.GetTopology(container.Version); if (SubMesh.HasTriangleCount(container.ExportVersion)) { instance.TriangleCount = origin.TriangleCount; } if (SubMesh.HasBaseVertex(container.ExportVersion)) { instance.BaseVertex = GetBaseVertex(container, ref origin); } if (SubMesh.HasVertex(container.ExportVersion)) { SetVertex(container, instanceMesh, ref origin, ref instance); } return(instance); }