WPF 3D - 为什么我的 ImageBrush 不渲染?
我有一个 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>
I have a 3D plane which I'm trying to render with an ImageBrush as it's DiffuseMaterial.Brush. If i use a SolidColorBrush then the plane appears fine but I get nothing at all with either an ImageBrush or a VisualBrush.
Can anyone tell me why? Here's the code.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
明白了,
我需要为画笔渲染提供映射坐标。 MeshhGeometry3D 现在看起来像这样 -
Got it,
I needed to provide mapping coordinates for the brush to render. The MeshhGeometry3D now looks like this -