我有一个3D平面,我正在尝试用ImageBrush渲染,因为它是DiffuseMaterial.Brush。如果我使用SolidColorBrush,那么这架飞机看起来很好,但我对ImageBrush或VisualBrush都没有任何帮助。
谁能告诉我为什么?这是代码。
<ModelVisual3D>
<ModelVisual3D.Transform>
<RotateTransform3D CenterX="0" CenterY="0" CenterZ="0">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="0 1 0" Angle="90"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</ModelVisual3D.Transform>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D x:Name="frontmesh" TriangleIndices="
0 1 2
2 3 0">
<MeshGeometry3D.Positions>
<MultiBinding Converter="{StaticResource front}">
<Binding ElementName="UC" Path="CubeHeight" />
<Binding ElementName="UC" Path="CubeWidth" />
<Binding ElementName="UC" Path="CubeDepth" />
</MultiBinding>
</MeshGeometry3D.Positions>
</MeshGeometry3D>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<ImageBrush ImageSource="CF.jpg"
AlignmentX="Center" AlignmentY="Center"
Stretch="Fill"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
答案 0 :(得分:5)
知道了,
我需要为要渲染的画笔提供贴图坐标。 MeshhGeometry3D现在看起来像这样 -
<MeshGeometry3D x:Name="frontmesh" TriangleIndices="
0 1 2
2 3 0"
TextureCoordinates="0 1,1 1,1 0 ,0 0">
<MeshGeometry3D.Positions>
<MultiBinding Converter="{StaticResource front}">
<Binding ElementName="UC" Path="CubeHeight" />
<Binding ElementName="UC" Path="CubeWidth" />
<Binding ElementName="UC" Path="CubeDepth" />
</MultiBinding>
</MeshGeometry3D.Positions>
</MeshGeometry3D>