WPF 3D - Why is my ImageBrush not showing?

I have a 3D plane that I am trying to do with ImageBrush, as it is DiffuseMaterial.Brush. If I use SolidColorBrush, then the plane seems fine, but I get nothing with either ImageBrush or VisualBrush.

Can someone tell me why? Here is 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>
+3
source share
1 answer

Got it,

I needed to provide display coordinates for brush rendering. Now MeshhGeometry3D looks like this:

<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>
+5
source

Source: https://habr.com/ru/post/1705564/


All Articles