Wednesday, March 7, 2018

The Physics Cookbook

Yes that’s right I used a cookbook for my physics engine. I am not a big fan of programming cookbooks, but for a physics engine it is one of the best ways to learn. Before I found the Game Physics Cookbook I tried two other well known books that left me wondering if I would ever finish my physics engine. Both of the other books have been out for awhile and both had incomplete code in their books.
The Game Physics Cookbook is in C++ but for various reasons I wanted to convert it to C. I am a big fan of reading and writing the code from the book and this book delivered. Since the author used complete programming recipes it made it a lot easier to convert to C. Also, I would think it would be easy to convert to other languages as long as you know the basics of C and C++. Below are my reviews for all three physics books.

If you want a really advanced physics engine I recommend the open source physics engine named Bullet. It has several books and a long list of software companies that use it.

Game Physics Cookbook
Pros:
1) The author was very friendly when I emailed him and helped me fix some code in my physics engine.
2) The code in the book is complete except for some typos.
3) The complete code (and more) is on Github.
4) Has complete formulas.

Cons:
1) There are some typos in the book but if you look at the Github code it is an easy fix.
2) The book starts creating demos in the last three chapters.

Notes:
On the back of the book it says that you can create an Angry Birds game. I would have to say that this is the only book that lives up to the statements on the back of the book. If you have never written a physics engine I highly recommend this book.

Game Physics Engine Development
Pros:
1) The source code on Github is in C++ and works on Mac but is very hard to convert to other languages.
2) The Github code has collisions with planes, spheres and boxes.

Cons:
1) I was not able to convert the C++ code to C.
2) Does not have complete code in the book.

Notes:
The book has very little finished code, although, the complete code is on Github. I also found that the section titles in the table of contents to be very misleading. For instance, there are sections that have titles for the different types of 3D collisions but the sections have one paragraph with no code. If you know game physics then the abstract sections and source code may be good enough for you.

Physics For Game Developers (Second Edition)
Pros:
1) The source code is mostly written in C so it is fairly easy to convert.

Cons:
1) The code is not complete in the book.
2) I was not able to convert the source code to C for Mac.
2) The source code on the website is only from the first edition and I had the second edition which was completely different.
3) It only explained how to create sphere to sphere collisions.

Notes:
This was the first game physics book I read. Unfortunately it only explains sphere to sphere collisions which is usually not enough for a physics engine. I have found box collisions are usually needed before spheres. From what I heard the first edition uses box to box collisions so that might be better.

No comments:

Post a Comment