void Init() { device = new Device(this.panel2.Width, this.panel2.Height); mesh = new Mesh("Cube", 8,12); mesh.Vertices[0] = new SharpDX.Vector3(-1, 1, 1); mesh.Vertices[1] = new SharpDX.Vector3(1, 1, 1); mesh.Vertices[2] = new SharpDX.Vector3(-1, -1, 1); mesh.Vertices[3] = new SharpDX.Vector3(1, -1, 1); mesh.Vertices[4] = new SharpDX.Vector3(-1, 1, -1); mesh.Vertices[5] = new SharpDX.Vector3(1, 1, -1); mesh.Vertices[6] = new SharpDX.Vector3(1, -1, -1); mesh.Vertices[7] = new SharpDX.Vector3(-1, -1, -1); mesh.Faces[0] = new Face { A = 0, B = 1, C = 2 }; mesh.Faces[1] = new Face { A = 1, B = 2, C = 3 }; mesh.Faces[2] = new Face { A = 1, B = 3, C = 6 }; mesh.Faces[3] = new Face { A = 1, B = 5, C = 6 }; mesh.Faces[4] = new Face { A = 0, B = 1, C = 4 }; mesh.Faces[5] = new Face { A = 1, B = 4, C = 5 }; mesh.Faces[6] = new Face { A = 2, B = 3, C = 7 }; mesh.Faces[7] = new Face { A = 3, B = 6, C = 7 }; mesh.Faces[8] = new Face { A = 0, B = 2, C = 7 }; mesh.Faces[9] = new Face { A = 0, B = 4, C = 7 }; mesh.Faces[10] = new Face { A = 4, B = 5, C = 6 }; mesh.Faces[11] = new Face { A = 4, B = 6, C = 7 }; camera = new Camera(); camera.Postion = new SharpDX.Vector3(0, 0, 10f); camera.Target = SharpDX.Vector3.Zero; }
private async void Page_Loaded(object sender, RoutedEventArgs e) { // Choose the back buffer resolution here WriteableBitmap bmp = new WriteableBitmap(640, 480); // Our Image XAML control frontBuffer.Source = bmp; device = new Device(bmp); meshes = await device.LoadJSONFileAsync("monkey.babylon"); mera.Position = new Vector3(0, 0, 10.0f); mera.Target = Vector3.Zero; // Registering to the XAML rendering loop CompositionTarget.Rendering += CompositionTarget_Rendering; }