本文整理汇总了C#中System.Windows.Media.PointCollection.ElementAtOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# PointCollection.ElementAtOrDefault方法的具体用法?C# PointCollection.ElementAtOrDefault怎么用?C# PointCollection.ElementAtOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PointCollection
的用法示例。
在下文中一共展示了PointCollection.ElementAtOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMeshes
private void BuildMeshes(OptFile opt)
{
this.meshes = null;
if (opt == null)
{
return;
}
this.meshes = new MeshGeometry3D[opt.Meshes.Count][][][];
for (int meshIndex = 0; meshIndex < opt.Meshes.Count; meshIndex++)
{
var mesh = opt.Meshes[meshIndex];
var positions = new Point3DCollection(
mesh.Vertices
.Select(t => new Point3D(-t.Y, -t.X, t.Z)));
var normals = new Vector3DCollection(
mesh.VertexNormals
.Select(t => new Vector3D(-t.Y, -t.X, t.Z)));
var textureCoordinates = new PointCollection(
mesh.TextureCoordinates
.Select(t => new Point(t.U, t.V)));
this.meshes[meshIndex] = new MeshGeometry3D[mesh.Lods.Count][][];
for (int lodIndex = 0; lodIndex < mesh.Lods.Count; lodIndex++)
{
var lod = mesh.Lods[lodIndex];
this.meshes[meshIndex][lodIndex] = new MeshGeometry3D[lod.FaceGroups.Count][];
for (int faceGroupIndex = 0; faceGroupIndex < lod.FaceGroups.Count; faceGroupIndex++)
{
var faceGroup = lod.FaceGroups[faceGroupIndex];
MeshGeometry3D[] geometries = new MeshGeometry3D[faceGroup.Faces.Count + 1];
for (int faceIndex = 0; faceIndex < faceGroup.Faces.Count; faceIndex++)
{
var face = faceGroup.Faces[faceIndex];
MeshGeometry3D geometry = new MeshGeometry3D();
int index = 0;
Index positionsIndex = face.VerticesIndex;
Index normalsIndex = face.VertexNormalsIndex;
Index textureCoordinatesIndex = face.TextureCoordinatesIndex;
geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.A));
geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.A));
geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.A));
geometry.TriangleIndices.Add(index);
index++;
geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.B));
geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.B));
geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.B));
geometry.TriangleIndices.Add(index);
index++;
geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.C));
geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.C));
geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.C));
geometry.TriangleIndices.Add(index);
index++;
if (positionsIndex.D >= 0)
{
geometry.TriangleIndices.Add(index - 3);
geometry.TriangleIndices.Add(index - 1);
geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.D));
geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.D));
geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.D));
geometry.TriangleIndices.Add(index);
index++;
}
geometry.Freeze();
geometries[1 + faceIndex] = geometry;
}
MeshGeometry3D geometryGroup = new MeshGeometry3D();
for (int i = 1; i < geometries.Length; i++)
{
MergeGeometry(geometryGroup, geometries[i]);
}
geometryGroup.Freeze();
geometries[0] = geometryGroup;
this.meshes[meshIndex][lodIndex][faceGroupIndex] = geometries;
}
}
}
//.........这里部分代码省略.........