3D Game Engine Architecture

In preparation for my 3D game engine, I have been trying to read all I can on 3D engine design and architecture. Although there are some good books out there, it’s very difficult to find a text that will walk you through everything you need to know. That said, 3D Game Engine Architecture: Engineering Real-Time Applications with Wild Magic by David H. Eberly gives it a good attempt.

The book covers the author’s Wild Magic engine, and discusses certain choices he made when developing the engine. It briefly touches on OpenGL, discusses abstracting away platform-specific details, 3D mathematics (and there is a lot of math in this book), an object system, scene-graphs, level of detail, render states, sorting, terrain, animation, collision detection, physics, and more. A lot of ground is covered in less than 800 pages.

However, I found much of the book difficult to follow and still feel like I could have a better picture of the “architecture” of an engine. When I think of “architecture” I think about a broad 500 foot view of a project. I think of flow charts or UML. I expect discussion on how all these disparate elements come together a form a whole. Sadly, that is mostly missing from this book. What the author provides is a good insight into his particular engine, and certain specific aspects of that engine. While this is still a great example to look at, I feel the text could have been more robust in terms of painting the big picture. Some of the things that I found missing were an event system, which seems crucial to an object-oriented engine, or a component architecture, really any type of  structure that allows communication between classes.

Additionally, I found myself getting lost multiple times while reading the book. The author would frequently put in dense mathematical equations and proofs, sometimes spanning multiple pages, and by the end you would be left to wonder what the purpose of the equation even was. I feel like having proofs of equations was not really relevant to the architecture, and surely there are many books on straight math if the reader needed that. Some math is necessary, of course, for a 3D engine but the space could have been used for more important topics.

Not really a jab at the book so much as it is the author’s coding conventions, I really did not like his style. I realize this is somewhat of a holy-war with programmers, but I guess we all have a style that is comfortable for us. Personally I found the author’s style to be really obtuse, and made reading the code snippets more difficult. For example, for a camera’s forward vector, he would use something like:

m_pkFVec

Where “m_” was a member variable, “p” is a pointer, “k” is of a class type, and “FVec” for forward vector. Personally I would use simply:

forwardVector

Just glancing through the code, which one is more apparent to what it is? This really bothered me to no end, but I guess you can chock it up to personal taste.

All-in-all it may sound like I am putting down on this book, but I actually did find it useful in a lot of ways. Certainly if you are aiming to create a 3D game engine from scratch, you will need any and all the help you can get. So yes, still read this book. However, I had much higher expectations and I feel it was a missed opportunity for the author. While it is still a decent resource, this should not be your first stop in engine development.

Game Coding Complete

Finally, I’ve got around to reading (and finishing) Game Coding Complete, and it’s up there on the list of great game development resources. I’d been meaning to read this book for quite some time, but got distracted with DirectX and Windows hooking for use with my 3D driver. Now that I’m back on the 3D engine kick, it seems like a good time to hit this book. Reading through this, I was thoroughly impressed by the content and the writing style. Don’t be discouraged by the lengthy size, this text is well worth the time to read.

The authors, both seasoned game developers, working on the Ultima series and various Sims games, have a lot of collective knowledge and it comes through in the book. There are a lot of snippets and stories about things the went right (or wrong) on the production of some of the games they worked on. I found these insights to be refreshing, and certainly interesting to read about. It also helps to teach people what professional game development is like, and things to expect if you are looking for a job in the industry.

Aside from the stories, there is a lot of topics covered in the book. They go over game loops, component architecture, process system, an event system, 3D math, DirectX, audio, collision and physics, scripting with Lua, AI, a game editor in C#, debugging, version control, multi-threading, etc. Really almost everything you would need to know. They weren’t joking when they said “Complete.” Although the book is long, it’s really amazing what they managed to cram in there. Granted, most topics only get one chapter, which isn’t really enough to fully cover everything. But it’s a great overview on a ton of stuff.

I found the coverage of the event and process system to be every insightful, and I will probably be using a variation of these in my own engine. The event system basically allows different objects to fire events at key points, and then have other objects respond without tight coupling. The process system allows objects to spawn logic loops, that will be updated along with the rest of the engine. So, for example, the player can hit a key to throw a grenade. That would fire an event, which would spawn a grenade with the proper velocity. The grenade itself would have a process, that would count down a few seconds and then explode. At the time of explosion, this could fire another event, which would then cause the audio system to play a sound and the particle engine to create a visual effect. This is a very clean way of handling events and processes, and this is probably the single more useful thing I found in the text.

If you are looking at creating your own game or engine, or just want to see what goes into a commercial title, Game Coding Complete may be one of the best resources to do so. While there is a good amount of C++ code in the book, it is not so much of a “cookbook”, it is more of an overview of architecture. The writing style is casual and friendly, and I really love all the stories told throughout the book. This is a great resource, and should not be missed. My only regret is that I did not read this book sooner. Highly recommended.

Unity 3x Essentials

I’ve been keeping tabs on Unity since back when it was a Mac only thing, and it sure has come a long way over the years. Even though I have downloaded and toyed with the program before, I hadn’t took the time to read a proper book on the engine. Now that I am having to work with Unity more for the job, I figured it was a good time to brush up on some knowledge. Although there are tons of Unity books out there, Unity 3.x Game Development Essentials seemed to have good reviews, and the price was right (only $16 for the Kindle e-book).

The book basically walks you through creating a dirt simple “game”, that you build up throughout the reading. Only the first chapter has a standalone demo to get your feet wet, the rest of the book is all one project. I found this format to work nicely, as you can concentrate on one aspect of the game design during each chapter but feel more accomplished as you built up the game. It covers creating a terrain, setting up a player controller, importing models, creating a GUI, collision detection, basic scripting to trigger events, and basically everything you would need for a simple demo. Although the game you build will not win any awards, it is functional and teaches some fundamental concepts.

What I will say is that the author did a bang-up job with the source code listings. There are tons of code snippets throughout the book and I found only one, yes one, mistake out of the whole thing. And, even then, it was a minor variable misnaming. Nothing major. This was a refreshing surprise, as many programming books are riddled with errors and non-compiling code. Bravo for that.

In general, though, I found this to be a very approachable book, even for a beginner. Of course, development experience doesn’t hurt, but it’s really not required for this text. The author clearly explains everything that is taught in the book and only at the end is some code glossed over (since it was already covered). I also liked how all the code is shown in both C# and Javascript, so the choice of language is up to the reader. Very nice.

The greatest part, I would say, is how far you can go with Unity itself in little time. I read this book in just one week and feel like I have covered more ground than I have with other engines spending *far* more time learning. So that just goes to show how solid the engine is. It’s not so much about the graphics of the engine, as it doesn’t really look any better than anything else out there. However the editor is very functional and very efficient. Especially nice is how you can create references to objects in the editor, greatly simplifying communication between different components. Overall I found it to be a great learning experience.

If you are just starting out with game development then this book is a great resource for learning the Unity engine. If you are already a developer but not familiar with Unity, this is also a great text. Granted, its not a very advanced book, so if you are already using Unity you can probably pass on it. That said, the book was very affordable and well worth the money in my opinion.