<Window x:Class="PerspectiveCylinders.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    FocusManager.FocusedElement="{Binding ElementName=cameraSelector}"
    Title="PerspectiveCylinders" Height="600" Width="500"
    >
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.Resources>
      <DataTemplate DataType="{x:Type PerspectiveCamera}">
        <StackPanel Orientation="Horizontal">
          <TextBlock Text="Position: " />
          <TextBlock Text="{Binding Position}" />
          <TextBlock Text=", LookDirection: " />
          <TextBlock Text="{Binding LookDirection}" />
          <TextBlock Text=", UpDirection: " />
          <TextBlock Text="{Binding UpDirection}" />
          <TextBlock Text=", FieldOfView: " />
          <TextBlock Text="{Binding FieldOfView}" />
        </StackPanel>
      </DataTemplate>
      <DataTemplate DataType="{x:Type OrthographicCamera}">
        <StackPanel Orientation="Horizontal">
          <TextBlock Text="(Orthographic) Position: " />
          <TextBlock Text="{Binding Position}" />
          <TextBlock Text=", LookDirection: " />
          <TextBlock Text="{Binding LookDirection}" />
          <TextBlock Text=", UpDirection: " />
          <TextBlock Text="{Binding UpDirection}" />
          <TextBlock Text=", Width: " />
          <TextBlock Text="{Binding Width}" />
        </StackPanel>
      </DataTemplate>

      <x:Array x:Key="cameras">
        <!-- Example 17-1. PerspectiveCamera -->

        <PerspectiveCamera Position="0,0,4" LookDirection="0,0,-1"
                           UpDirection="0,1,0" FieldOfView="45" />

        <!-- End of Example 17-1. -->


        <!-- Position -->
        <PerspectiveCamera Position="-1,0,4" LookDirection="0,0,-1"
                           UpDirection="0,1,0" FieldOfView="45" />
        <PerspectiveCamera Position="1,0,4" LookDirection="0,0,-1"
                           UpDirection="0,1,0" FieldOfView="45" />


        <!-- LookDirection -->
        <PerspectiveCamera Position="0,0,4" LookDirection="-0.33,0,-1"
                       UpDirection="0,1,0" FieldOfView="45" />
        <PerspectiveCamera Position="0,0,4" LookDirection="0.33,0,-1"
                       UpDirection="0,1,0" FieldOfView="45" />


        <!-- UpDirection -->
        <PerspectiveCamera Position="0,0,4" LookDirection="0,0,-1"
                     UpDirection="-0.5,1,0" FieldOfView="45" />
        <PerspectiveCamera Position="0,0,4" LookDirection="0,0,-1"
                     UpDirection="0.5,1,0" FieldOfView="45" />


        <!-- FieldOfView -->
        <PerspectiveCamera Position="0,0,4" LookDirection="0,0,-1"
                     UpDirection="0,1,0" FieldOfView="65" />
        <PerspectiveCamera Position="0,0,4" LookDirection="0,0,-1"
                     UpDirection="0,1,0" FieldOfView="25" />


        <!-- Position/FieldOfView -->
        <PerspectiveCamera Position="0,0,2" LookDirection="0,0,-1"
                     UpDirection="0,1,0" FieldOfView="108" />
        <PerspectiveCamera Position="0,0,8" LookDirection="0,0,-1"
                     UpDirection="0,1,0" FieldOfView="20" />

        <!-- Orthographic -->
        <OrthographicCamera Position="0,0,2" LookDirection="0,0,-1"
                     UpDirection="0,1,0" Width="5" />
        <OrthographicCamera Position="0,0,2" LookDirection="0,0,-1"
                     UpDirection="0,1,0" Width="4" />
        <OrthographicCamera Position="0,0,2" LookDirection="0,0,-1"
                     UpDirection="0,1,0" Width="3" />
      </x:Array>
    </Grid.Resources>

    <ListBox SelectedIndex="0" x:Name="cameraSelector" DataContext="{StaticResource cameras}" ItemsSource="{Binding Items}" />
    
    <Viewbox Grid.Row="1" ClipToBounds="True">
      <Border BorderBrush="Black" BorderThickness="1" Margin="2">

        <Viewport3D ClipToBounds="True" Width="300" Height="200"
                    Camera="{Binding ElementName=cameraSelector,Path=SelectedItem}">
          <Viewport3D.Resources>
            <ResourceDictionary>
              <GeometryModel3D x:Key="cylinderModel"
                               Geometry="{StaticResource cylinderMesh}"
                               Material="{StaticResource shinyBlueMaterial}" />

              <GeometryModel3D x:Key="cylinderModel1"
                   Geometry="{StaticResource cylinderMesh}"
                   Material="{StaticResource shinyBlueMaterial}" />
              <GeometryModel3D x:Key="cylinderModel2"
                   Geometry="{StaticResource cylinderMesh}"
                   Material="{StaticResource shinyBlackMaterial}" />
              <GeometryModel3D x:Key="cylinderModel3"
                   Geometry="{StaticResource cylinderMesh}"
                   Material="{StaticResource shinyBlueMaterial}" />
              <GeometryModel3D x:Key="cylinderModel4"
                   Geometry="{StaticResource cylinderMesh}"
                   Material="{StaticResource shinyBlueMaterial}" />
              <GeometryModel3D x:Key="cylinderModel5"
                   Geometry="{StaticResource cylinderMesh}"
                   Material="{StaticResource shinyBlackMaterial}" />
            </ResourceDictionary>
          </Viewport3D.Resources>

          <ModelVisual3D>
            <ModelVisual3D.Content>
              <Model3DGroup>
                <AmbientLight Color="#333333" />
                <DirectionalLight Color="#FFFFFF" Direction="0.0156948,-0.897322,-0.4410982" />
                <DirectionalLight Color="#FFFFFF" Direction="0.795738,0.0155303,-0.605442" />
              </Model3DGroup>
            </ModelVisual3D.Content>

            <!--<ModelVisual3D Content="{StaticResource cylinderModel}">
            <ModelVisual3D.Transform>
              <RotateTransform3D>
                <RotateTransform3D.Rotation>
                  <AxisAngleRotation3D Axis="0,0,1" Angle="45" />
                </RotateTransform3D.Rotation>
              </RotateTransform3D>
            </ModelVisual3D.Transform>
          </ModelVisual3D>-->

            <ModelVisual3D Content="{StaticResource cylinderModel1}">
              <ModelVisual3D.Transform>
                <TranslateTransform3D OffsetX="-1" OffsetZ="1" />
              </ModelVisual3D.Transform>
            </ModelVisual3D>
            <ModelVisual3D Content="{StaticResource cylinderModel2}">
              <ModelVisual3D.Transform>
                <TranslateTransform3D OffsetX="-0.5" OffsetZ="0.5" />
              </ModelVisual3D.Transform>
            </ModelVisual3D>
            <ModelVisual3D Content="{StaticResource cylinderModel3}">
              <ModelVisual3D.Transform>
                <TranslateTransform3D OffsetX="0" OffsetZ="0" />
              </ModelVisual3D.Transform>
            </ModelVisual3D>
            <ModelVisual3D Content="{StaticResource cylinderModel4}">
              <ModelVisual3D.Transform>
                <TranslateTransform3D OffsetX="0.5" OffsetZ="-0.5" />
              </ModelVisual3D.Transform>
            </ModelVisual3D>
            <ModelVisual3D Content="{StaticResource cylinderModel5}">
              <ModelVisual3D.Transform>
                <TranslateTransform3D OffsetX="1" OffsetZ="-1" />
              </ModelVisual3D.Transform>
            </ModelVisual3D>

            <!--<ModelVisual3D Content="{StaticResource cylinderModel}">
            <ModelVisual3D.Transform>
              <ScaleTransform3D ScaleX="0.5" ScaleY="2" ScaleZ="0.5" />
            </ModelVisual3D.Transform>
          </ModelVisual3D>-->

          </ModelVisual3D>
        </Viewport3D>

      </Border>
    </Viewbox>
  </Grid>
</Window>
