Adding a Camera to Your Scene

If you run the application, you notice that nothing looks different. You still see a black screen and nothing else. You have all the code in to load and render your sky box mesh, so why isn't it rendering? Direct3D doesn't know exactly what it can render yet. In a 3D scene, you need to include a camera so Direct3D knows which areas of the world it should render. Add the code in Listing 4.9 to the OnDeviceReset method now.

Listing 4.9. Setting Up a Camera
 // Set the transformation matrices localDevice.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI / 4, (float)this.Width / (float)this.Height, 1.0f, 1000000.0f); localDevice.Transform.View = Matrix.LookAtLH(new Vector3(0,0,-54), new Vector3(), new Vector3(0,1,0)); ...

Get Beginning 3D Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.