When I got my first game console in 1979—a way-cool Intellivision system by Mattel—the term “game engine” did not exist. Back then, video and arcade games were considered by most adults to be nothing more than toys, and the software that made them tick was highly specialized to both the game in question and the hardware on which it ran. Today, games are a multi-billion-dollar mainstream industry rivaling Hollywood in size and popularity. And the software that drives these now-ubiquitous three-dimensional worlds—game engines like id Software’s Quake and Doom engines, Epic Games’ Unreal Engine 4, Valve’s Source engine and the Unity game engine— have become fully featured reusable software development kits that can be licensed and used to build almost any game imaginable. While game engines vary widely in the details of their architecture and implementation, recognizable coarse-grained patterns are emerging across both publicly licensed game engines and their proprietary in-house counterparts. Virtually all game engines contain a familiar set of core components, including the rendering engine, the collision and physics engine, the animation system, the audio system, the game world object model, the artificial intelligence system and so on. Within each of these components, a relatively small number of semi-standard design alternatives are also beginning to emerge. There are a great many books that cover individual game engine subsystems, such as three-dimensional graphics, in exhaustive detail. Other books 3 4 1. Introduction cobble together valuable tips and tricks across a wide variety of game technology areas. However, I have been unable to find a book that provides its reader with a reasonably complete picture of the entire gamut of components that make up a modern game engine. The goal of this book, then, is to take the reader on a guided hands-on tour of the vast and complex landscape of game engine architecture. In this book you will learn: • how real industrial-strength production game engines are architected; • how game development teams are organized and work in the real world; • which major subsystems and design patterns appear again and again in virtually every game engine; • the typical requirements for each major subsystem; • which subsystems are genre- or game-agnostic, and which ones are typically designed explicitly for a specific genre or game; and • where the engine normally ends and the game begins. We’ll also get a first-hand glimpse into the inner workings of some popular game engines, such as Quake and Unreal, and some well-known middleware packages, such as the Havok Physics library, the OGRE rendering engine and Rad Game Tools’ Granny 3D animation and geometry management toolkit. Before we get started, we’ll review some techniques and tools for largescale software engineering in a game engine context, including: • the difference between logical and physical software architecture; • configuration management, revision control and build systems; and • some tips and tricks for dealing with one of the common development environments for C and C++, Microsoft Visual Studio. In this book I assume that you have a solid understanding of C++ (the language of choice among most modern game developers) and that you understand basic software engineering principles. I also assume you have some exposure to linear algebra, three-dimensional vector and matrix math and trigonometry (although we’ll review the core concepts in Chapter 4). Ideally, you should have some prior exposure to the basic concepts of real time and event-driven programming. But never fear—I will review these topics briefly, and I’ll also point you in the right direction if you feel you need to hone your skills further before we embark.