Ab3d.PowerToys 3D Objects




                        
<Page x:Class="Ab3d.PowerToys.Samples.Objects3D.AllVisualsSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
    xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"  
    xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys">
    <Page.Resources>
        <DiffuseMaterial x:Key="ObjectsMaterial" Brush="#247589"/>
    </Page.Resources>
    <Grid Name="MainGrid">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0 0" EndPoint="0 1">
                <GradientStop Offset="0" Color="#033C62"/>
                <GradientStop Offset="1" Color="#01131F"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Viewport3D Name="MainViewport">
            <visuals:WireGridVisual3D CenterPosition="0 0 0" Size="100 100" WidthCellsCount="10" HeightCellsCount="10" 
                                      LineColor="#555555" LineThickness="2"/>

            <visuals:ConeVisual3D BottomCenterPosition="-30 0 -30" BottomRadius="10" TopRadius="0" Height="20" 
                                  Material="{StaticResource ObjectsMaterial}"/>
            <visuals:ConeVisual3D BottomCenterPosition="0 0 -30" BottomRadius="10" TopRadius="5" Height="20" 
                                  Material="{StaticResource ObjectsMaterial}"/>
            <visuals:ConeVisual3D BottomCenterPosition="30 0 -30" BottomRadius="10" TopRadius="5" Height="20" 
                                  Segments="6" IsSmooth="False" Material="{StaticResource ObjectsMaterial}"/>
            
            <visuals:SphereVisual3D CenterPosition="-30 10 0" Radius="10" Material="{StaticResource ObjectsMaterial}"/>
            <visuals:CylinderVisual3D BottomCenterPosition="0 0 0" Radius="10" Height="20" Material="{StaticResource ObjectsMaterial}"/>
            <visuals:CylinderVisual3D BottomCenterPosition="30 0 0" Radius="10" Height="20" Segments="6" 
                                      IsSmooth="False" Material="{StaticResource ObjectsMaterial}"/>

            <visuals:PlaneVisual3D CenterPosition="-30 1 30" Size="20 20" Normal="0 1 0" HeightDirection="0 0 -1"
                                   Material="{StaticResource ObjectsMaterial}" BackMaterial="{StaticResource ObjectsMaterial}"/>
            <visuals:PyramidVisual3D BottomCenterPosition="0 0 30" Size="20 20 20" Material="{StaticResource ObjectsMaterial}"/>
            <visuals:BoxVisual3D CenterPosition="30 10 30" Size="20 20 20" Material="{StaticResource ObjectsMaterial}"/>

            <visuals:MultiMaterialBoxVisual3D CenterPosition="60 10 30" Size="20 20 20" 
                                              FallbackMaterial="{StaticResource ObjectsMaterial}" 
                                              TopMaterial="Blue" LeftMaterial="Gray"/>

            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup>
                        <AmbientLight Color="#333333"/>
                    </Model3DGroup>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>
        
        <cameras:SceneCamera Name="Camera1" Heading="30" Attitude="-20" Bank="0" Distance="200" ShowCameraLight="Always"/>
        
        <!-- EventsSourceElement is set to MainGrid - this means that the MainGrid's mouse events are subscribed to - 
             this enables camera rotation without the need to be over the rendered 3D element -->
        <ab3d:MouseCameraController Name="MouseCameraController1" UsedMouseButton="Left" 
                                    EventsSourceElement="{Binding ElementName=MainGrid}"/>

        <ab3d:CameraControlPanel VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5" Width="150" Height="75"/>
        
        <TextBlock FontWeight="Bold" FontSize="20" Foreground="Silver" Margin="10" VerticalAlignment="Top" 
                   HorizontalAlignment="Left" Text="3D objects created with Ab3d.Visuals"/>
    </Grid>
</Page>