本文整理汇总了C#中MeshData.SetData方法的典型用法代码示例。如果您正苦于以下问题:C# MeshData.SetData方法的具体用法?C# MeshData.SetData怎么用?C# MeshData.SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData.SetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseMeshData
//.........这里部分代码省略.........
case "TriIndex":
faces = ParseMeshFaces(xml);
break;
case "TexVertex":
texVtx = ParseVector2Array(xml);
break;
case "TexIndex":
texIdx = new TexIndex[faces.Length];
ParseTexIndex(xml, texIdx);
break;
}
}
}
Dictionary<string, int> table = new Dictionary<string, int>(faces.Length * 3);
FastList<VertexPNT1> vertices = new FastList<VertexPNT1>(faces.Length * 3);
for (int i = 0; i < faces.Length; i++)
{
int index;
VertexPNT1 vtx;
vtx.pos = positions[faces[i].IndexA];
vtx.n = normals[faces[i].IndexA];
vtx.u = texVtx[texIdx[i].a].X;
vtx.v = texVtx[texIdx[i].a].Y;
string desc = vtx.ToString();
if (!table.TryGetValue(desc, out index))
{
table.Add(desc, vertices.Count);
faces[i].IndexA = vertices.Count;
vertices.Add(ref vtx);
}
else
{
faces[i].IndexA = index;
}
// =========================================
vtx.pos = positions[faces[i].IndexB];
vtx.n = normals[faces[i].IndexB];
vtx.u = texVtx[texIdx[i].b].X;
vtx.v = texVtx[texIdx[i].b].Y;
desc = vtx.ToString();
if (!table.TryGetValue(desc, out index))
{
table.Add(desc, vertices.Count);
faces[i].IndexB = vertices.Count;
vertices.Add(ref vtx);
}
else
{
faces[i].IndexB = index;
}
// =========================================
vtx.pos = positions[faces[i].IndexC];
vtx.n = normals[faces[i].IndexC];
vtx.u = texVtx[texIdx[i].c].X;
vtx.v = texVtx[texIdx[i].c].Y;
desc = vtx.ToString();
if (!table.TryGetValue(desc, out index))
{
table.Add(desc, vertices.Count);
faces[i].IndexC = vertices.Count;
vertices.Add(ref vtx);
}
else
{
faces[i].IndexC = index;
}
}
MeshData data = new MeshData((RenderSystem)null);
data.Faces = faces;
data.VertexElements = VertexPNT1.Elements;
data.VertexSize = VertexPNT1.Size;
data.VertexCount = vertices.Count;
fixed (VertexPNT1* src = &vertices.Elements[0])
{
data.SetData(src, VertexPNT1.Size * vertices.Count);
}
result.Mesh = data;
return result;
}