XNA for C#
DirectX 9 for C#
DirectX 9 for C++
DirectX 9 for VB
My XNA Book
       Go to section on this site

Additional info

Latest Forum posts

 Account settings
  Posted by: Anonymous
  When: 07/05/2014 at 09:48:39

 forced subtitle
  Posted by: Applefly
  When: 07/05/2014 at 06:00:48

 convert DVD into PMS
  Posted by: Applefly
  When: 07/05/2014 at 05:55:25

 DVD to Digital Copy easily
  Posted by: VIKIVannessa
  When: 05/05/2014 at 06:52:29

 DVD on Xbox 360/Xbox One Console
  Posted by: VIKIVannessa
  When: 05/05/2014 at 06:51:47

 Extract .Srt Subtitles
  Posted by: Applefly
  When: 04/05/2014 at 03:54:38

 Encode Movie collection
  Posted by: Applefly
  When: 04/05/2014 at 03:52:41

 Convert DVD to WMV
  Posted by: Applefly
  When: 29/04/2014 at 05:53:50

 rip DVDs into digital files
  Posted by: Applefly
  When: 29/04/2014 at 05:51:20

 iTunes movies/music to Kindle Fire
  Posted by: ciciyu80
  When: 29/04/2014 at 05:10:20


XNA 3.0 Game Programming Recipes

Riemer Grootjans

Chapter 2: Setting Up Different Camera Modes in Your 3D World (144 pages)

In a 3D application, the camera is one of the most elementary components. The camera represents the viewpoint of the user in your 3D world. XNA renders your 3D world to the screen as it is seen by the camera. So before you can ask XNA to render the content of your 3D scene to the screen, you first need to specify the position and viewing direction of your camera.

This chapter starts off with some fundamental topics you need to master before you can create any 3D application.

The second part of this chapter covers some more advanced examples, such as camera flybys, quadtrees, octrees, and post-processing.

2-1. Set Up the Camera: Position, Target, and View Frustum
This beginner recipe introduces to the steps required to set up your own 3D World. The purpose of the camera is discussed, together with the View and Projection matrices. As an extra, the use and necessity of the Z-buffer is explained.

2-2. Specify the Target of Your Camera
To rotate a camera, you should only change its Target point. Although this can be done by diving into trigon maths, itís far easier and more scalable to use simple transformations.

2-3. Create a First-Person Shooter Camera: A Quake-Style Camera
This recipes creates the QuakeCamera class, which is being used in almost all 3D recipes in this book. This camera mode allows you to fly through your 3D world using as seen in most first-person shooting games.

2-4. Create a Freelancer-Style Camera: Full 3D Rotation Using Quaternions
The Quaternion camera is quite different from the Quake Camera, as it allows the camera to rotate in all directions.

2-5. Check Whether an Object Is in Sight of the Camera
This recipe shows how to use the Contains method of the BoundingFrustum class. As an example, you learn how to check whether a single point, single Model or multiple Models are in sight of the camera.

2-6. Detect Camera Collision Against Models, Walls, or Terrains
This recipe uses a BoundingSphere to keep the camera at a certain distance from a Model or terrain grid.

2-7. Create a Camera Fly-by Action
Most 3D games allow for smooth Fly-By camera modes. This allows the game engine to bring some locations of the 3D world to the attention of the player. This recipe shows how to implement such Fly-By using a Bezier curve.

2-8. Remove the Solid Background Color: Skybox
An easy way to remove the solid background color of the screen is to render a cube around the camera and cover the cube with textures. The HLSL part of this recipe explains the texCUBE intrinsic.

2-9. Draw Only the Parts of the Scene That Are in Sight
of the Camera: Octree
Having tens or hundres of Models in your 3D World will severely slow down your application. This recipe shows how you can separate your 3D world in smaller parts, and render only those parts that are in sight of the camera.

2-10. Use a Quadtree to Hide Parts of a Grid That Are Not in Sight
This recipe introduces you to large terrain rendering. A large terrain is split up into multiple smaller grids, of which only those in sight of the camera are actually being rendered to the screen.

2-11. Create a Real-Time Camera-Dependant Optimally Adapting Mesh (ROAM) Terrain
In case the terrain you want to render for your game is so huge it cannot be handled by the previous recipe canít handle, this recipe introduces you to a totally different way of rendering terrain. This is done by selecting for each triangle individually the optimal Level-Of-Detail that is should be rendered in.

2-12. Set Up a Post-Processing Framework
Almost all games come with a complete set of Post-Processing effects. These HLSL effects capture the final image before it is rendered to screen and modify the color content. This recipe shows how you can set up a Post-Processing framework, allowing you to easily add or drop Post-Processing effects.

2-13. Create a Blur/Glow Post-Processing Effect
Two examples of Post-Processing effects. The Glow effect is used to show how to use multiple pass alpha rendering, one of the more complex techniques to master in Post-Processing.

2-14. Write a Custom Content Importer
As a more advanced recipe on the Content Pipeline, this recipe shows you how you can load custom defined objects into the Content Pipeline, and how you can extract and present their contents to a Content Processor.

Recipe 2-11: Real time ROAM terrain engine for rendering huge outdoor environments.


If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !

- Website design & XNA + DirectX code : Riemer Grootjans -
©2003 - 2011 Riemer Grootjans

This site in English
This site in Korean
This site in Czech

Microsoft MVP Award

2007 - 2011 MVP Award
DirectX - XNA


XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
-- Expand all --

Thank you!

Support this site --
any amount is welcome !

Stay up-to-date

I don't have the time to keep a News section, so stay informed about the updates by clicking on this RSS file!