我有我试图用图像刷渲染,因为它是DiffuseMaterial.Brush 3D平面。如果我使用的SolidColorBrush然后飞机似乎不错,但我什么都得不到与任一图像刷或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>
有帮助吗?

解决方案

知道了,

我需要提供贴图坐标为刷进行渲染。所述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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top