WPF 3D - 为什么我的ImageBrush没有渲染?

3
我有一个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>
1个回答

5

明白了,

我需要提供刷子渲染的映射坐标。现在MeshGeometry3D看起来是这样的 -

<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>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接