O'Reilly logo

Beginning 3D Game Programming by Tom Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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)); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required