Create exhilarating 3D game
graphics!
Beginning Direct3D® Game Programming
covers all of the elements that are neccessary to create a
Direct3D game for your PC! You will learn the essentials of
Direct3D game programming, including basic algorithms,
texture mapping basics, 3D math, lighting, use of depth
buffers, and much more! This book also covers the
Transformation & Lighting Pipeline and how to use it to
map texture objects with different effects as well as
different file formats and how to integrate them into your
game engines. You'll go from the basic to hardcore Direct3D
game programming in a matter of pages!
What's on the CD:
- Microsoft® DirectX® 8 Software Development Kit
- Truespaces Demo Version
- 30-Day Trial Version of Jasc® Paint Shop Pro® 7
- Games
- Source Code from the Book
Contents
Introduction
Part I: DirectX Graphics: Don't Hurt Me
Chapter 1: History of
Direct3D/DirectX Graphics
Chapter 2: Overview of DirectX
Graphics/HAL/COM
Direct3D HAL
Pluggable Software Devices
Reference Rasterizer
Controlling Devices
COM
Chapter 3: C/C++ and COM Programming Rules for
Direct3D
Code Style
Debugging DirectX
Return Codes
Chapter 4: Geometry/Shading/Texture-Mapping
Basics
Orientation
Faces
Normals
Normals and Gouraud Shading
Texture-Mapping Basics
Chapter 5: The Basics
The DirectX Graphics Common Architecture
Basic Example
OneTimeSceneInit()
InitDeviceObjects()
RestoreDeviceObjects()
FrameMove()
Render()
InvalidateDeviceObjects()
DeleteDeviceObjects()
FinalCleanup()
Basic2 Example
InitDeviceObjects()
RestoreDeviceObjects()
Render()
InvalidateDeviceObjects()
DeleteDeviceObjects()
FinalCleanup()
Basic3 Example
RestoreDeviceObjects()
Render()
InvalidateDeviceObjects()
Chapter 6: First Steps to Animation
The Third Dimension
Transformation Pipeline
Transformation Math
Matrices
The World Matrix
The View Matrix
Camera Rotation about a
Camera Axis
Camera Rotation with Quaternions
The Projection Matrix
Lighting
Material
Lighting Models
Vertex Color (Optional)
Depth Buffering
Down to the Code
OneTimeSceneInit()
InitDeviceObjects()
RestoreDeviceObjects()
FrameMove()
Render()
InvalidateDeviceObjects()
DeleteDeviceObjects()
FinalCleanup()
Next Steps to Animation
RestoreDeviceObjects()
FrameMove()
More Enhancements
Quiz
Additional Resources
Part II: Knee-Deep in DirectX Graphics Programming
Chapter 7: Texture-Mapping Fundamentals
Texture Coordinates
Texture-Addressing Modes
Wrap Texture-Addressing
Mode
Mirror Texture-Addressing Mode
Clamp Texture-Addressing Mode
Border Color Texture-Addressing Mode
MirrorOnce Texture-Addressing Mode
Texture Wrapping
Texture Filtering and Texture Anti-Aliasing
Mipmaps
Nearest-Point Sampling
Linear Texture Filtering
Anisotropic Filtering
Full-Scene Anti-Aliasing
Alpha Blending
Chapter 8: Using Multiple Textures
Color Operations
Dark Mapping
Animating the Dark
Blending a Texture with Material Diffuse Color
Dark Map Blended with Material Diffuse Color
Glow Mapping
Detail Mapping
Alpha Operations
Modulate Alpha
Environment Mapping
Spherical Environment
Mapping
Cubic Environment Mapping
RestoreDeviceObjects()
RenderSceneIntoCube()
RenderScene()
ConfirmDevice()
Bump Mapping
ApplyEnvironmentMap()
InitBumpMap()
Render()
ConfirmDevice()
Dot Product Texture Blending
InitDeviceObjects()
Render()
Multitexturing Support
Texture Management
Quiz
Additional Resources
Anisotropy
Detail Mapping
Cubic Environment Mapping
Stencil Buffers
Bump Mapping
Dot Product Texture Blending
Part III: Hard-Core Direct X Graphics Programming
Chapter 9: Working with Files
Building Worlds with X Files
3-D File Formats
X File Format
Header
Mesh
MeshMaterialList
Normals
Textures
Transformation Matrices
Animation
Using X Files
The Example
InitDeviceObjects()
RestoreDeviceObjects() and InvalidateDeviceObjects()
Render()
Extending X Files
Additional Resources
Chapter 10: Quake III Model Files
Files of the Trade
Animation.cfg
The .skin File
Textures and the Shader File
Custom Sounds
The .md3 Format
Md3.h
Md3.cpp
CreateModel()
CreateTextures()
CreateVB()
Render()
DeleteTextures()
DeleteVB()
DeleteModel()
Md3view.cpp
OneTimeSceneInit()
InitDeviceObjects()
Render()
DeleteDeviceObjects()
FinalCleanup()
MsgProc()
Additional Resources
Chapter 11: Game Physics (written by Amir
Geva)
3-D Math
Newton's Laws
Calculating the Frame Time
Air Resistance
Static Friction
Kinetic Friction
Chapter 12: Collision Detection (written by Amir
Geva)
The Most Basic Optimization
Bounding Volumes
2-D Collision Detection
Brute Force
Bit Arrays
Sprite Bounds
Group Processing
Axis Sort
Grid
Static Objects
Automatic Transparent Static Marking
3-D Collision Detection
Dealing with this Complex
Problem
Portals
Calculating Distance of Cylinder from Wall
BSP (binary space partitioning)
Sliding Off Walls
3-D Mesh Collision Detection
Bounding Volumes
Convexity of Models
Convex Models Intersection
Concave Models Intersection
Axis Aligned Bounding
Boxes
Axis Aligned Bounding Boxes Tree
How to Divide the Box
Oriented Box Intersections
Triangle Intersection
Using ColDet with DirectX 8.0
Collision Reaction
3-D Object Group Processing
Quiz
Additional Resources
Part IV: Appendixes
Appendix A: Windows Game Programming
Foundation
How to Look through a Window
How Windows 95/98/ME/NT/2000
Interacts with Your Game
The Components of a Window
A Window Skeleton
Step 1: Define a Window
Class
Windows Data Types
Step 2: Register the Window Class
Step 3: Creating a Window of that Class
Step 4: Display the Window
Step 5: Create the Message Loop
The Window Procedure
A Window Skeleton Optimized for Games
Windows Resources
Additional Resources
Appendix B: C++ Primer
What's Object-Oriented Programming?
Abstraction
Classes
Encapsulation
Declaring a Class
Constructor
Destructor
This Pointer
Class Hierarchies and Inheritance
Inheriting Code
Inheriting an Interface
Virtual Functions
Polymorphism
Inline Functions
C++ Enhancements to C
Default Function
Arguments
Placement of Variable Declarations
Const Variable
Enumeration
Function Overloading and Operator Overloading
Function Overloading
Operator Overloading
Additional Resources
Appendix C: The Common Files Framework
Create()
Step 1: Create the Direct3D
Object with Direct3DCreate8()
Step 2: Search for the Proper Device Driver with the Help
of BuildDeviceList()
Step 1 in
BuildDeviceList()
Step 2 in BuildDeviceList()
Step 3: Create a Window with CreateWindow()
Step 4: Initialize the Geometry Data of your Game with
OneTimeScene Init()
Step 5: Initialize the 3-D Environment with
Initialize3DEnvironment()
Step 1 in
Initialize3DEnvironment()
Step 2 in Initialize3DEnvironment(): CreateDevice()
Step 3 in Initialize3DEnvironment(): SetWindowPos()
Step 4 in Initialize3DEnvironment(): GetDeviceCaps()
Step 5 in Initialize3DEnvironment(): GetDesc()
Step 6 in Initialize3DEnvironment():
D3DUtil_SetDeviceCursor()
Step 7 in Initialize3DEnvironment(): Initialize the
Application's Device Objects
Step 8 in Initialize3DEnvironment()
Step 6: Starting the Timer with DXUtil_Timer()
Run()
Step 1 in
Render3DEnvironment(): TestCooperativeLevel() and
Resize3DEnvironment()
Step 2 in Render3DEnvironment(): FrameMove()
Step 3 in Render3DEnvironment(): Render()
Step 4 in Render3DEnvironment(): Fill the Frame Count
String
Step 5 in Render3DEnvironment(): Present()
MsgProc()
Appendix D: Mathematics Primer
Points in 3-D
Vectors
Bound Vector
Free Vector
Vector Addition: U + V
Vector Subtraction: U - V>
Vector Multiplication
Scalar Product
Dot Product
Cross Product
Unit Vector
Matrices
Multiplication of a Matrix
with a Vector
Matrix Addition and Subtraction
Matrix Multiplication
Translation Matrix
Scaling Matrix
Rotation Matrices
Rotation about the
y-axis
Rotation about the x-axis
Rotation about the z-axis
Appendix E: Game Programming Resources
General
DirectX Graphics
FAQ