Вопрос

У меня есть 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>
Это было полезно?

Решение

Понятно,

Мне нужно было предоставить координаты отображения для кисти для рендеринга.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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top