3d Game Programming with C++ Gold Book with CD-ROMby John De Goes, Andre LaMothe (Foreword by)
Perfect sequel to Coriolis' bestselling Cutting-Edge 3D Game Programming with C++ because it shows developers how to create games for today's state-of-the-art PC platforms and graphics accelerators. All of the examples and source code presented are designed to harness the power of Microsoft's latest version of DirectXa graphics programming API that greatly enhances the development of high performance PC graphics. Currently the only detailed book in print that explains and uses techniques of accurate physics modeling to create highly realistic 3D games. Explains in detail all of the undocumented mathematical models for programming flat-shaded polygons, 3D transformations, light-sourced polygons, and texture mapping. Foreword by Andre LaMothe, bestselling author of Black Art of 3D Game Programming (Waite Group Press) and Game Programming for Dummies (IDG). Includes a full source code game engine written in C++a great value add to the book, since typically these engines are expensive.
Provides full source code and a detailed blueprint for building a professional-quality 3D game engine that exploits DirectX high-performance features. Covers the hot new topic of creating artificial characters in 3D using AI techniques and realistic simulations. Presents advanced techniques on collision detection and rigid-body dynamicskey technologies for all "cutting-edge" 3D games.
Includes a suite of professional-quality game development tools either written or hand picked by the authorfor everything from realistic 3D characters to game backgrounds to awesome sound effects. Provides full C++ source code for sample games, which can be used as a modelto develop new and exciting fast-action 3D games.
- Coriolis Group
- Publication date:
- Edition description:
- Product dimensions:
- 7.28(w) x 9.12(h) x 1.70(d)
Read an Excerpt
Chapter 1: What Are 3D Games?Shadows
Today's games increasingly make use of shadows, which Direct3D supports. Game designers usually decide that not all objects should have shadows-only select objects (like characters and moving vehicles, for example), because using shadows for all objects within a 3D world is computationally expensive.
Many objects, because they do not move, can be given textures with predrawn shadows, eliminating the computational cost at the expense of memory. Another technique involves modifying the intensities of the polygon's vertices (similar to Gouraud shading), making those that lie within shadow regions darker and those that do not, lighter. This technique crudely approximates real shadows, but is fast and universally supported by hardware.
Another feature of Direct3D games is support for hardware acceleration. Every hardware device that includes solid DirectX drivers-and most such devices do-is instantly compat, ible with all existing DirectX games. This reduces user headaches and allows you, as a developer, to concentrate on game issues rather than hardware issues.
DirectX allows hardware acceleration for 3D graphics, 2D graphics, sound output, and input devices (some of which have miniature computers built inside to reduce strain on the CPU). As far as this book is concerned, the most important of these accelerated areas is 3D graphics.
3D Hardware Acceleration
Years ago, not even the fastest computer could produce a quality three-dimensional environment running at playable speeds by using an elegant C++ solution. Programmers who wanted to write 3D games were thus forced to use low,level andpainstakingly optimized assembly language. Even the fastest assembly code was not fast enough; however, programmers had to go beyond this by using clever tricks that often restricted features. The computer game Doom, for example, didn't allow arbitrary polygonal shapes or even slanted walls to inhabit its worlds. It also restricted players to strictly two-dimensional maps-no two floors could exist at any one location. Players weren't even free to look in arbitrary directions (the looking up and down that did exist was noticeably faked)
Descent, the popular 3D space action game, went beyond Doom by allowing a truly three, dimensional world, but even it had its limitations: It ran in low resolution, with some constraints on the manner in which worlds were formed, and the texture mapping quality was crude.
Manufacturers of graphics cards were aware of the PCs lack of built-in 3D hardware and seized the opportunity to incorporate 3D hardware on their products. Though 3D graphics cards were standard equipment in the high-end workstations used by computer artists, such cards were new to the PC world. As the first few cards were released, gamers were disappointed when they discovered a Pentium could easily outperform the best of the pricey accelerators (with some degradation in image quality). Their outlook changed, however, around the time 3DFX released the Voodoo, an amazing chip capable of outperforming in both speed and quality the fastest Pentium. Other companies, such as nVidia, also released high-performance chips. Computer companies and gamers rushed to buy these secondgeneration accelerators, inducing other companies to make 3D cards. Thus was born a competitive, performance-driven market that continues today.
The Features Of HardwareToday's average 3D card includes the following features, all of which can be relied on in Direct3D games:
- 16MB or more of video memory
- Texture mapping
- Transparency, shading, and bump mapping
- Geometry acceleration
Graphics cards use video memory to store geometric and graphical information. Direct3D, in particular, uses video memory for the following purposes:
- For the video mode they run in-Games usually run in full-screen mode, meaning the game chooses and sets its resolution and color depth, rather than using the one that Windows is using. Higher resolutions and color depths require more memory.
- For storing the geometry of their objects-Before cards can perform mathematical operations on geometry (such as polygons), the geometric information must be moved to video memory.
- For the depth buffer-The depth buffer is a piece of memory that stores one depth value for each pixel. It is used to allow close objects to obscure objects behind them, and it is implemented in most hardware. Depth buffers typically consume as much or more memory than that used by the video mode.
- For graphical information-Textures, bump maps, light maps, and other kinds of graphical information can be stored in video memory.
- For alpha information-Transparency data, such as stencils and alpha channels, can be stored in video memory.
Graphics cards can texture polygons in many different ways. The most common methods are referred to as nearest point, bilinear filtering, and trilinear filtering (bilinear and trilinear will be discussed later in this book). Each of these methods first calculates which pixel in the texture map should be mapped onto a given pixel on the polygon. Because this point is not whole (that is, it is a point containing fractions), the hardware must choose which pixel should be used. The nearest-point method rounds the fractional point to the nearest point. The other methods use parts of several surrounding pixels. Thus, the nearest-point method produces the lowest quality output, whereas the others produce much higher-quality polygons. The nearest-point method is no longer considered an acceptable texture-mapping method, because all new graphics cards support at bilinear and trilinear filtering. Many graphics cards also support hardware texture compression and decompression, allowing many more textures to fit into video memory.
Direct3D allows graphics cards to handle more than just graphical output. They can also accelerate the processing of geometry, which must occur before such data can be displayed. Few graphics cards fully accelerate geometry processing (but CPU extensions, such as AMDs 3DNow!, help with this); most, however, do at least triangle set up, which is the mathematical set up that must be performed immediately before a triangle can be displayed. (All polygons are broken down into triangles before being displayed.)
Transparency, Shading, And Bump Mapping
All of today's 3D graphics cards support alpha,channel transparency. Many also support stenciling, the faster method of transparency mentioned earlier. As a programmer, these methods allow you to use pixel-precise transparency in your games.
Another universal feature of graphics cards is their support for shading. They can display polygons shaded by-lights, as well as perform Gouraud shading and fog effects.
Lastly, most graphics cards support hardware bump mapping, allowing an unprecedented level of realism for polygons.
The first step in becoming a three-dimensional game programmer is to understand what elements contribute to the graphics of three-dimensional games. For Windows programmers, those elements are usually the features supplied by Microsofts DirectX, a high-performance COM SDK aimed specifically at the game-developer community. DirectX gives developers direct control over graphics accelerators, input devices, sound cards, and more.
Credit goes to the manufacturers of graphics accelerators for the radical new advances in the quality and performance of three-dimensional games. These graphics accelerators natively support a growing list of 3D features, enabling developers to produce games that are richly detailed and run at high speeds.
The next chapter takes you through the architecture of 3D games, covering some of the mathematics you will use when writing for Direct3D...
Most Helpful Customer Reviews
See all customer reviews
This book would've been great if I had needed some sleep. The problem with this book is that it said something in 5 pages that could've been said in 1. I also believe that this book was aimed more at complete beginners, such as 1st graders. For a 500 page book I thought it gave a pretty lousy idea of how to program with C++. I was quit disappointed.
This book explains a lot of stuff with great organization. The problem with any book from de Goes is that he doesn't know how to explain any of the code. He will give you one little paragraph for two pages of code. He probably just found code off the internet, and threw it into the book. He also caries his tradition of putting in unworking code just like in the Cutting Edge book. I would recommend this book to readers interrested in fiction and delusions but not interrested programmers.
With the 500 pages of basic MSDN information I was pretty upset with this book. The author literally flew through the IM section of the book. Don't bother buying this book, or any book that 'claims' to cover D3D IM. Go check out some user boards, web pages, or the MSDN, you'll have a better experience there.
I wanted to follow up on my earlier posting and make a point or two. My initial reaction to the book was based on expectations that I had rather than being an objective critique. I have had time to reflect and reread the material and I must say that there actually is alot of good stuff there. This book is a good reference at the high level. It is not a 'build from the ground up' type of book. It makes assumptions about your level of expertise (it is for intermediate to advanced technologists and says so right on the back cover) that I failed to take into consideration in my last review. Anyway, while not perfect, it does provide a wealth of useful mathematics, optimization and even good overall coverage of DX. It may not hold your hand every step of the way, but the truth is, there really are no shortcuts when it comes to building these types of games. It is difficult and as programmers, we must be prepared for the challenge. I recommend the book to anyone who has the guts to build their own 3d game engine. It gets 5 stars because, while I still wish it had more info, I nevertheless find myself referring back to it over and over again. Great reference for advanced developers!
I posted a review earlier that was based on my initial expetactions of what this book should have been. It was unfair. In fact, using this book as a guide, I have been able to actually get a halfway decent 3d game engine together in a relatively short time. Note that I said that I used it as a guide. This book does not hold your hand, but rather helps the programmer to push forward using the material provided. It is an excellent resource. It is for intermediate to advanced programmers (says so right on the back cover) and gives you some excellent suggestions for building and optimizing your 3d world. The DX tutorials are brief yet complete and give you what you need to get going. The mathematics and physics sections are certainly top-notch. When I see how far I have come, thanks to John's material, I am truly amazed. Sure it is difficult and sometimes frustrating to build a 3d game world, but that challenge is what makes it exciting and satisfying when we succeed. This book will help you do it. It won't do the work for you, and for that I am glad. If you are an experienced programmer and want to tackle this complex challenge, this book is the perfect tool to help you get there. Highly recommended.