Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 292 trang
THÔNG TIN TÀI LIỆU
Cấu trúc
Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Table of Contents
Preface
Chapter 1: Getting Started with 3D
Setting up a new project
The 3D coordinate system
Matrices
Loading a model
Drawing a model
Creating a Custom Model class
Creating a Camera class
Creating a target camera
Upgrading the camera to a free camera
Calculating bounding spheres for models
View frustum culling
Additional camera types: Arc-Ball
Additional camera types: chase camera
Example—spaceship simulator
XNA Graphics Profiles
Summary
Chapter 2: Introduction to HLSL
Getting started
Assigning a shader to a model
Creating a simple effect
Texture mapping
Texture sampling
Diffuse colors
Ambient lighting
Lambertian directional lighting
Phong specular highlights
Creating a Material class to store effect parameters
Summary
Chapter 3: Advanced Lighting
Implementing a point light with HLSL
Implementing a spot light with HLSL
Drawing multiple lights
Prelighting
Storing depth and normal values
Creating the light map
Drawing models with the light map
Creating the prelighting renderer
Using the prelighting renderer
Summary
Chapter 4: Projection and Shadowing Effects
Projective texturing
Shadow mapping — drawing the depth map
Shadow mapping — projecting the depth texture onto the scene
Shadow mapping — performing the depth comparison
Variance shadow mapping — soft shadows
Variance shadow mapping — blurring the depth texture
Variance shadow mapping — generating shadows
Summary
Chapter 5: Shader Effects
Fog
Normal mapping
Generating normal maps with Photoshop
Cube mapping—making a sky sphere
Cube mapping: Reflections
Rendering sky boxes with Terragen
Creating a reflective water effect
Summary
Chapter 6: Billboard and Particle Effects
Creating the BillboardSystem class
Drawing Billboards
Creating clouds with spherical billboarding
Non-rotating billboards
Particle effects
Particle fire
Particle smoke
Summary
Chapter 7: Environmental Effects
Building a terrain from a heightmap
Multitexturing
Adding a detail texture to the terrain
Placing plants on the terrain
Adding the finishing touches
Summary
Chapter 8: Advanced Materials and Post Processing
Advanced Materials
Post processing
Black and white post processor
Gaussian blur post processor
Depth of field
Glow post processor
Summary
Chapter 9: Animation
Object animation
Keyframed animation
Curve interpolation
Building a Race Track from a Curve
Moving a car along the track
Hierarchical animation
Skinned animation
Loading a skinned model
Playing a skinned animation
Changing an animation's play speed
Model attachments
Summary
Index
Nội dung
[...]... Called when the game should update itself protected override void Update(GameTime gameTime) { base.Update(gameTime); } // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); } } [] Download from Wow! eBook Getting Started with3D The 3D coordinate system One thing that all 3D systems... 267 268 Preface XNA is a very powerful API using which it's easy to make great games, especially when you have dazzling 3D effects This book will show you how to implement the same 3Dgraphics used in professional games to make your games shine, and get those gamers addicted! This book will show you, step-by-step, how to implement the effects used in professional 3D games in your XNA games Upon reaching... code for the Game1 class is now as follows: public class Game1 : Microsoft .Xna. Framework .Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Model model; Matrix[] modelTransforms; public Game1 () { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics. PreferredBackBufferWidth = 1280; graphics. PreferredBackBufferHeight = 800; } // Called when the game should... generated Game1 class contains a lot of excess comments and code, so once you have familiarized yourself with the class and its functions, simplify it to the following: public class Game1 : Microsoft .Xna. Framework .Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public Game1 () { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } // Called when the game should... may encounter while building games Next, we will look at a way to improve performance with a "view frustum culling" system, and finally, we'll build a small game that allows the player to fly a spaceship using keyboard controls Setting up a new project The first step in any game is to set up the XNA game project in Visual Studio 1 To begin with, ensure that XNA and Visual Studio are installed by following... version was XNA 3.1 From the box on the right, specify that you want to create a Windows Game, and give it a name: 3 Click on OK, and you will be taken to the main file of the game project called Game1 .cs XNA will have created this file and added it to your project automatically The Game1 class is the main class in an XNA game By default, this class is automatically instantiated when the game is loaded,... SpriteBatch(GraphicsDevice); model = Content.Load("ship"); modelTransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(modelTransforms); [ 16 ] Chapter 1 } // Called when the game should update itself protected override void Update(GameTime gameTime) { base.Update(gameTime); } // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue);... Vector3.Zero, GraphicsDevice); We need to update the camera in the Update() method: // Called when the game should update itself protected override void Update(GameTime gameTime) { camera.Update(); base.Update(gameTime); } Finally, we can use the View and Projection properties of camera in the Draw() method: // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue);... best to address it [] Getting Started with3D This chapter will provide you with a brief overview of the fundamentals of 3Dgraphics We will create a number of useful classes and systems that will make work easier later on and provide us with a flexible framework for building games This chapter will focus mainly on models, how they work, and how to view them with cameras We will build a number of... guide available at creators .xna. com and launch Visual Studio Once it has loaded, create a new project: Getting Started with3D 2 From the left-hand side, choose the version of XNA you want to work with Generally, you should pick the most recent version available, unless you are specifically targeting an older version If you've just installed XNA, there will be only one version of XNA to choose from At the .