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>
Got it,
I needed to provide mapping coordinates for the brush to render. The MeshhGeometry3D now looks like this –