Book Image

Game Physics Cookbook

By : Gabor Szauer
Book Image

Game Physics Cookbook

By: Gabor Szauer

Overview of this book

Physics is really important for game programmers who want to add realism and functionality to their games. Collision detection in particular is a problem that affects all game developers, regardless of the platform, engine, or toolkit they use. This book will teach you the concepts and formulas behind collision detection. You will also be taught how to build a simple physics engine, where Rigid Body physics is the main focus, and learn about intersection algorithms for primitive shapes. You’ll begin by building a strong foundation in mathematics that will be used throughout the book. We’ll guide you through implementing 2D and 3D primitives and show you how to perform effective collision tests for them. We then pivot to one of the harder areas of game development—collision detection and resolution. Further on, you will learn what a Physics engine is, how to set up a game window, and how to implement rendering. We’ll explore advanced physics topics such as constraint solving. You’ll also find out how to implement a rudimentary physics engine, which you can use to build an Angry Birds type of game or a more advanced game. By the end of the book, you will have implemented all primitive and some advanced collision tests, and you will be able to read on geometry and linear Algebra formulas to take forward to your own games!
Table of Contents (27 chapters)
Game Physics Cookbook
Credits
About the Author
Acknowledgements
About the Reviewer
Acknowledgements
www.PacktPub.com
Customer Feedback
Preface
Index

Open source physics engines


One of the best ways to learn is to examine the existing technology. There are a large number of open source physics engines that we can study. I'm only listing open source engines, which means that closed source SDKs, such as Havok or PhysX, are left out of this list. Out of all the physics engines listed, you really need to go through the Box2D Lite source code.

Box2D Lite

This is, by far, the must-read physics engine! The project is small and easy to nagivate. The entire project consists of six .cpp and six .h files. Even though this is a 2D engine, it can easily be extended for 3D support. To download and have a look at Box2D Lite visit http://box2d.org/files/GDC2006/Box2D_Lite.zip

The most important thing about this engine is the arbiter implementation. Box2D Lite provides a full arbiter implementation. The engine uses a similar impulse solver to the one that we covered in this book; this makes the arbiter provided with Box2D Lite easy to use with our engine. There is a GDC presentation about the project available at http://box2d.org/files/GDC2006/GDC2006_Catto_Erin_PhysicsTutorial.ppt

Box2D

Box2D is a 2D physics engine written in C++ that is developed by Erin Catto. Box2D powers some of the most popular 2D mobile games. This engine has been ported to many other languages, such as C#, Java, Java script, and Action script. It's worth reading through the source of Box2D Lite before getting into the advanced features of Box2D.

https://github.com/erincatto/Box2D

Dyn4j

The dyn4j is a 2D collision detection and physics engine written in Java. The engine is robust and provides a feature set comparable to Box2D. What really sets this engine apart is the accompanying website. The dyn4j blog (http://www.dyn4j.org) provides clear and concise examples and tutorials for many advanced physics topics.

Bullet

The Bullet physics engine is probably the most popular open source 3D physics engine out there. The engine implements many cutting-edge algorithms and techniques. Some of the more advanced features of the engine are hard to find documentation on; they are only described in academic papers. Bullet is large and feature rich, it is used in everything from games to robotics. http://bulletphysics.org/wordpress

ODE

The Open Dynamics Engine (ODE) is a high-performance physics library written in C++. ODE is an older engine, which receives infrequent updates. The source code for the engine is well written and easy to understand. ODE has been used to ship several AAA commercial games as well as robotics. http://www.ode.org

JigLib

JigLib is an experimental physics engine that has a very clean, well-organized, and easy-to-follow source code. The engine has been ported to C#, Java, Java script, Action script, and other languages. The engine is stable; it runs well even on older hardware.

http://www.rowlhouse.co.uk/jiglib

React 3D

React3D is a C++ physics engine being developed by Daniel Chappuis. The source code of the engine is well organized, easy to follow and extremely well commented. The comments in the source code of this engine are better than some of the online tutorials. The engine is feature rich and runs very fast. http://www.reactphysics3d.com

Qu3e

The qu3e is a simple C++ physics engine being developed by Randy Gaul. The engine aims to strip a modern physics engine down to its minimal code. Only the cube primitive is supported, but many advanced features are implemented. The engine is a great example of the minimum code needed for modern physics simulation.https://github.com/RandyGaul/qu3e

Cyclone Physics

Cyclone Physics is a 3D physics engine developed by Ian Millington for his book, Game Physics Engine Development. More information about the book is provided later in this chapter. https://github.com/idmillington/cyclone-physics