GeometryModel3D Class
Updated: January 2010
Renders a Geometry3D with the specified Material.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
If you need to create a Model3D that uses multiple materials, you must use the Model3DGroup class to combine multiple GeometryModel3D objects.
The front and back sides of the GeometryModel3D are determined by the winding order of the triangles in the MeshGeometry3D. The front side winds counter clockwise.
The Material and BackMaterial properties may be Transparent or Nothing. When the material is transparent, you cannot see that side of the triangle, but hit testing works as usual. When the material is Nothing, you cannot see it, and hit testing does not work.
The following code excerpt creates a GeometryModel3D in the shape of a cube.
<GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0" Normals="0 0 1 0 0 1 0 0 1 0 0 1" TextureCoordinates="0 1 1 1 0 0 1 0 " TriangleIndices="0 1 2 1 3 2" /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial> <DiffuseMaterial.Brush> <SolidColorBrush Color="Cyan" Opacity="0.3"/> </DiffuseMaterial.Brush> </DiffuseMaterial> </GeometryModel3D.Material> <!-- Translate the plane. --> <GeometryModel3D.Transform> <TranslateTransform3D OffsetX="2" OffsetY="0" OffsetZ="-1" > </TranslateTransform3D> </GeometryModel3D.Transform> </GeometryModel3D>
The following code excerpt uses a GeometryModel3D whose Geometry is defined as a static resource.
<ModelVisual3D> <ModelVisual3D.Content> <GeometryModel3D Geometry="{StaticResource myTeapot}"> <GeometryModel3D.Material> <DiffuseMaterial> <DiffuseMaterial.Brush> <SolidColorBrush Color="Blue" Opacity="1.0" /> </DiffuseMaterial.Brush> </DiffuseMaterial> </GeometryModel3D.Material> <GeometryModel3D.Transform> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,3,0" Angle="1" /> </RotateTransform3D.Rotation> </RotateTransform3D> </GeometryModel3D.Transform> </GeometryModel3D> </ModelVisual3D.Content> </ModelVisual3D>
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
System.Windows.Media.Media3D.Model3D
System.Windows.Media.Media3D.GeometryModel3D
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.