【WPF】MeshGeometry3D中的Normals和TextureCoordinates属性

 

MeshGeometry3DNormals属性和TextureCoordinates属性用于指定纹理如何贴到3D模型的表面去。


<MeshGeometry3D Positions="1,1,0 -1,1,0 -1,-1,0 1,-1,0"  

                                 Normals="0 0 1, 0 0 1, 0 0 1, 0 0 1"

                                 TextureCoordinates="1 0, 0 0, 0 1, 1 1"

                                 TriangleIndices="0,1,3 3,1,2"/>

上面的代码建立了一个简单的平面模型。

 

MSDN:Normal vectors are vectors perpendicular to the face of each triangle that defines a mesh. Normals determine whether a given triangle face is lit.Normals决定了一个给定的三角面是否被照亮)

MSDN:Texture coordinates determine how a Material is mapped to the vertices of the triangles that make up a mesh. TextureCoordinates决定了材质如何被映射到构成网格的三角形的顶点)


对于一个材质来说,它的顶点定义如下:

 

上面的代码: TextureCoordinates="1 0, 0 0, 0 1, 1 1"也就是说,将M1映射到P0M0映射到P1M3映射到P2M2映射到P3,即:



顺便放自己做的一个简单的3D程序

原文地址:https://www.cnblogs.com/RMay/p/1232287.html