The correct definition of the original WPF 3d:meshgeometry3d texture coordinates
To make 2D-based textures appear in 3D objects, we must define the texture mapping coordinates of the 3D mesh objects. In WPF, this feature is passed through the Meshgeometry3d.texturecoordinates property.
The corresponding coordinates of the LinearGradientBrush texture are the same as those of WPF's StartPoint and endpoint.
Notes from MSDN about LinearGradientBrush's startpoint:
(0,0) represents the upper-left corner of the entire graph, which represents the lower-right corner. (0,1) represents the lower left corner ... Of course units are relative, can use a decimal between 0 to 1 to represent the relative position of the middle.
For the simplest mesh definition without shared vertices (the meshgeometry3d.positions attribute has no share points), texturecoordinates corresponds to the coordinates of each triangle in the mesh, and of course this and meshgeometry3d.triangle The Indices property definition is related.
For example, define a simple 3D planar rectangle, first defining the Meshgeometry shell based on the triangle distribution. At this point, the texture coordinates to define the texture coordinates according to the location of the triangle, such as the first point is 0, 0, 0, obviously corresponds to the lower left corner of the rectangle in 3D space, then the first corresponding texturecoordinates is 0 1, and so on, so define the entire plane.
<meshgeometry3d positions= "0 0 0, 5 5 0, 0 5 0, 0 0 0, 5 0 0, 5 5 0"
triangleindices= "0 1 2 3 4 5"
texturecoordinates= "0 1, 1 0, 0 0,
0 1, 1 1, 1 0 "/>
The final texture is displayed correctly:
WPF 3d:meshgeometry3d The correct definition of texture coordinates