|
|
|
|
|
|
Additional info
|
|
|
|
|
Latest Forum posts
|
|
|
|
|
Ads
|
|
|
|
|
|
|
|
|
|
|
|


XNA 2.0 Game Programming Recipes
Riemer Grootjans

Chapter 2: Setting Up Different Camera Modes in Your 3D World (120 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. 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-12. 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-13. Define an Orthogonal Projection Matrix to Generate a Depth Map of the Scene
Some more advanced 3D effects require you to have 2D height maps of each side of a Model. This recipe shows you how you can create these. You’ll learn how to use a Orthogonal View matrix and some more usages of the global BoundingSphere of a Model.

Recipe 2-9: Partitioning your 3D space into cubes and rendering only the Models inside the cubes which are in sight of the camera.
- Website design & XNA + DirectX code : Riemer Grootjans - ©2003 - 2008 Riemer Grootjans
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007 - 2008 MVP Award DirectX - XNA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Support this site -- any amount is welcome !
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|