在尝试理解 WPF 3D 中的纹理坐标时,我从一个非常简单的示例开始:单个三角形、线性渐变画笔和纹理坐标,如下所示:
<Viewport3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<GeometryModel3D>
<!-- Geometry -->
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="10 10 0,
20 10 0,
15 15 0"
TriangleIndices="0 1 2"
TextureCoordinates="0.5 0.0,
0.5 0.0,
0.5 0.0" />
</GeometryModel3D.Geometry>
<!-- Foreground and background brushes -->
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Red" Offset="0.0"/>
<GradientStop Color="Yellow" Offset="0.50"/>
<GradientStop Color="Green" Offset="1.0"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Blue" />
</GeometryModel3D.BackMaterial>
</GeometryModel3D>
<!-- Lighting -->
<AmbientLight Color="White" />
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<!-- Camera -->
<Viewport3D.Camera>
<PerspectiveCamera Position="15 12 10"
LookDirection="0 0 -1"
UpDirection="0 1 0"
FieldOfView="90">
</PerspectiveCamera>
</Viewport3D.Camera>
</Viewport3D>
我期待的是一个红色三角形,因为纹理的所有 y 坐标都是 0.0,但我得到的是一个绿色的!有人可以解释一下这种行为,以便我纠正我的理解,并转向更大的模型吗?谢谢!