Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从MeshGeometry3D获取所有三角形?_C#_Wpf_3d_Mesh - Fatal编程技术网

C# 如何从MeshGeometry3D获取所有三角形?

C# 如何从MeshGeometry3D获取所有三角形?,c#,wpf,3d,mesh,C#,Wpf,3d,Mesh,我有一个System.Windows.Media.Media3D.MeshGeometry3D对象,我需要从该对象获取所有三角形,如下所示 System.Windows.Media.Media3D.MeshGeometry3D m; // // code to generate mesh and assign to 'm' // foreach (var t in m.Triangles) //there is no Triangles property, only TriangleIndic

我有一个System.Windows.Media.Media3D.MeshGeometry3D对象,我需要从该对象获取所有三角形,如下所示

System.Windows.Media.Media3D.MeshGeometry3D m;
//
// code to generate mesh and assign to 'm'
//
foreach (var t in m.Triangles)  //there is no Triangles property, only TriangleIndices
{
    //t.p1, t.p2, t.p2  --> need all three points of a triangle
}

如何从网格“m”获取所有三角形?

可以从“位置”属性获取三角形。此列表中连续三个Point3D点表示三角形。例外:如果设置了TriangleIndices属性,则必须从此列表中获取三元组。此三元组中的每个条目都是位置列表中的索引

所以当位置列表是P0,P1,P2,P3,P4,P5时,你们会得到三角形(P1,P2,P3),(P4,P5,P6)

若另外的三角形索引列表是3,4,5,1,0,2,你们会得到三角形(P3,P4,P5),(P1,P0,P2)。(Px是Point3D结构)