Last active
November 14, 2016 06:41
Star
You must be signed in to star a gist
Wpf3DSample / DiceXamlWpf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="DiceXamlWpf.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="clr-namespace:DiceXamlWpf" | |
Title="Dice (XAML)" Height="600" Width="600"> | |
<Window.Resources> | |
<Style x:Key="FaceStyle" TargetType="{x:Type TextBlock}"> | |
<Setter Property="Foreground" Value="White"/> | |
<Setter Property="Width" Value="30"/> | |
<Setter Property="Height" Value="30"/> | |
<Setter Property="TextAlignment" Value="Center"/> | |
<Setter Property="FontSize" Value="20"/> | |
</Style> | |
</Window.Resources> | |
<Grid Background="#FF333333"> | |
<Grid Visibility="Hidden"> | |
<TextBlock x:Name="Face1" Style="{DynamicResource FaceStyle}" Text="1" Background="#FF222222"/> | |
<TextBlock x:Name="Face2" Style="{DynamicResource FaceStyle}" Text="2" Background="#FFDF2C2C"/> | |
<TextBlock x:Name="Face3" Style="{DynamicResource FaceStyle}" Text="3" Background="#FFEE9319"/> | |
<TextBlock x:Name="Face4" Style="{DynamicResource FaceStyle}" Text="4" Background="#FFE3E60A"/> | |
<TextBlock x:Name="Face5" Style="{DynamicResource FaceStyle}" Text="5" Background="#FF29D214"/> | |
<TextBlock x:Name="Face6" Style="{DynamicResource FaceStyle}" Text="6" Background="#FF4444BB"/> | |
</Grid> | |
<Viewport3D> | |
<Viewport3D.Camera> | |
<PerspectiveCamera Position="0,0,10"/> | |
</Viewport3D.Camera> | |
<ModelVisual3D> | |
<ModelVisual3D.Content> | |
<AmbientLight/> | |
</ModelVisual3D.Content> | |
</ModelVisual3D> | |
<ModelVisual3D> | |
<ModelVisual3D.Transform> | |
<Transform3DGroup> | |
<TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="0"/> | |
<ScaleTransform3D ScaleZ="1" ScaleY="1" ScaleX="1"/> | |
<RotateTransform3D> | |
<RotateTransform3D.Rotation> | |
<AxisAngleRotation3D Axis="0.6,0.3,0.7" Angle="-70"/> | |
</RotateTransform3D.Rotation> | |
</RotateTransform3D> | |
<TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="0"/> | |
<TranslateTransform3D OffsetZ="-2" OffsetX="2" OffsetY="1"/> | |
</Transform3DGroup> | |
</ModelVisual3D.Transform> | |
<ModelVisual3D.Content> | |
<Model3DGroup> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face1}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="-1,-1,1 1,-1,1 1,1,1 -1,1,1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face2}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="-1,-1,-1 1,-1,-1 1,-1,1 -1,-1,1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face3}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="1,-1,-1 1,1,-1 1,1,1 1,-1,1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face4}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="-1,1,-1 -1,-1,-1 -1,-1,1 -1,1,1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face5}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="1,1,-1 -1,1,-1 -1,1,1 1,1,1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
<GeometryModel3D> | |
<GeometryModel3D.Material> | |
<DiffuseMaterial> | |
<DiffuseMaterial.Brush> | |
<VisualBrush Visual="{Binding ElementName=Face6}"/> | |
</DiffuseMaterial.Brush> | |
</DiffuseMaterial> | |
</GeometryModel3D.Material> | |
<GeometryModel3D.Geometry> | |
<MeshGeometry3D Positions="1,-1,-1 -1,-1,-1 -1,1,-1 1,1,-1" TriangleIndices="0,1,2 0,2,3" TextureCoordinates="0,1 1,1 1,0 0,0"/> | |
</GeometryModel3D.Geometry> | |
</GeometryModel3D> | |
</Model3DGroup> | |
</ModelVisual3D.Content> | |
</ModelVisual3D> | |
</Viewport3D> | |
</Grid> | |
</Window> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment