What is mesh geometry in WPF?
<MeshGeometry3D Positions="0,0,0 10,0,0 10,10,0 0,10,0 0,0,10 开发者_运维知识库10,0,10 10,10,10 0,10,10"
TriangleIndices="0 1 3 1 2 3 0 4 3 4 7 3 4 6 7 4 5 6 0 4 1 1 4 5 1 2 6 6 5 1 2 3 7 7 6 2" />
This is the code I have, and what is the meaning of the numbers in Positions
and TriangleIndices
?
MeshGeometry3D allows the developer to specify position, normal, and texture coordinate information. The Positions property is required.
Normals are assumed to be associated with the front faces of a mesh primitive. The winding order (the order in which the Positions that make up each triangle of the mesh are specified) determines whether a given face is front-facing or back-facing. Front-facing triangles are wound in counter-clockwise order; back-facing triangles are wound in clockwise order.
MSDN
Positions:
The points specifed by this property represent the vertices of the triangles that make up a 3-D mesh.
The winding order (the order in which the Positions that make up each triangle of the mesh are specified) determines whether a given face is front-facing or back-facing. Front-facing triangles are wound in counter-clockwise order; back-facing triangles are wound in clockwise order.
TriangleIndices:
For a triangle in a given 3-D mesh, the order in which the triangle's vertex positions are specified determines whether the triangle face is a front or back face.
The Windows Presentation Foundation 3-D implementation uses a counter-clockwise winding order; that is, the points that determine a front-facing mesh triangle's positions should be specified in counterclockwise order, as viewed from the front of the mesh.
Setting the TriangleIndices property is optional. If the indices are not specified, triangles are drawn in a non-indexed fashion. Every set of three positions becomes a triangle.
Positions :
Each three consecutive sets of numbers present in the value of "Positions" attribute declares a 3DPoint with a particular index, that is first three numbers in the positions (0,0,0) defines a 3DPoint with index 0, and the next set of three numbers (10,0,0) defines a 3DPoint with index 1.
TriangleIndices :
This attribute's value holds all the triangles that make up the mesh. Any 3D Model present as MeshGeometry3D is made up of triangles, which are made up of Positions.
A single point ( which here is Position) can be reference in multiple triangles which is why Positions are separately defined in tag Positions and Triangles contain the indices of the Positions.
With positions define the location on axes and each of them labeled (like v0(vertex 0) , v1 , ...) So we can indicate what Triangle be on face, back ,... In following, represent the index of mesh, vertex and TriangleIndices of cube. see this
So TriangleIndices for cube like this(note every face of the cube is on a single line)
0, 1, 2, 0, 2, 3, //front
4, 5, 6, 4, 6, 7, //right
8, 9, 10, 8, 10, 11, //back
12, 13, 14, 12, 14, 15, //left
16, 17, 18, 16, 18, 19, //upper
20, 21, 22, 20, 22, 23}; //bottom
for more information see this http://in2gpu.com/2015/07/09/drawing-cube-with-indices/
精彩评论