added SSCLI 1.0
[windows-sources.git] / sdk / samples / WPFSamples / Basic3D / csharp / window1.xaml.cs
blob62bbc335998cbb473d016e5716851e7c17145cc1
1 //This is a list of commonly used namespaces for a window.
2 using System;
3 using System.Windows;
4 using System.Windows.Controls;
5 using System.Windows.Documents;
6 using System.Windows.Navigation;
7 using System.Windows.Shapes;
8 using System.Windows.Data;
9 using System.Windows.Media;
10 using System.Windows.Media.Media3D;
12 namespace Blank3DSample
14 /// <summary>
15 /// Interaction logic for Window1.xaml
16 /// </summary>
18 public partial class Window1 : Window
20 public Window1()
22 InitializeComponent();
25 //declare scene objects
26 Model3DGroup modelGroup = new Model3DGroup();
27 PerspectiveCamera myPCamera = new PerspectiveCamera();
28 DirectionalLight myDirLight = new DirectionalLight();
29 GeometryModel3D teapotModel = new GeometryModel3D();
30 Transform3DCollection myTransforms = new Transform3DCollection();
31 Viewport3D myViewport = new Viewport3D();
33 private void WindowLoaded(object sender, EventArgs e)
36 //Set camera viewpoint and properties.
37 myPCamera.FarPlaneDistance = 20;
38 myPCamera.NearPlaneDistance = 1;
39 myPCamera.FieldOfView = 45;
40 myPCamera.Position = new Point3D(-5, 2, 3);
41 myPCamera.LookDirection = new Vector3D(5, -2, -3);
42 myPCamera.UpDirection = new Vector3D(0, 1, 0);
44 //Add light sources to the scene.
45 myDirLight.Color = Colors.White;
46 myDirLight.Direction = new Vector3D(-3, -4, -5);
48 teapotModel.Geometry = (MeshGeometry3D)Application.Current.Resources["myTeapot"];
50 //Define material and apply to the mesh geometries.
51 DiffuseMaterial teapotMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Blue));
53 teapotModel.Material = teapotMaterial;
55 //Add 3D model and lights to the collection; add the collection to the visual.
57 modelGroup.Children.Add(teapotModel);
58 modelGroup.Children.Add(myDirLight);
60 ModelVisual3D modelsVisual = new ModelVisual3D();
61 modelsVisual.Content = modelGroup;
63 //Add the visual and camera to the Viewport3D.
64 myViewport.Camera = myPCamera;
65 myViewport.Children.Add(modelsVisual);
67 mainWindow.Content = myViewport;