Torque 2D Development Blog - Box2D Overview
by Michael Perry · 10/30/2009 (4:45 pm) · 74 comments
Welcome to another entry in the Torque 2D Development Blog series. Now that Torque 3D has officially shipped, it's time for Torque 2D to get the spotlight. The last blog about our new 2D engine was posted back in August, discussing integration with Torque 3D's code base. A lot of development has gone on since then, and for this blog really wanted to crank up the "awesome factor."
Torque 3D got a major push with the development of an abstracted physics layer, including an integration with PhysX. Our engine mastermind, Melv May, decided to give Torque 2D similar treatment. This blog is dedicated to his implementation of Box2D in Torque 2D!
What is Box2D?From their Wiki, "Box2D is a feature rich 2D rigid body physics engine, written in C++ by Erin Catto. It has been used in many games, including Crayon Physics Deluxe, winner of the 2008 Independent Game Festival Grand Prize." The system was originally developed on Windows using pure C++, and has since been ported to Linux, OS X, and the iPhone. Because of the API's flexible nature, there are integrations for Flash, Java, Python, C#, and Obj-C.
For Torque 2D, we did not opt for a thin Box2D integration with limited exposure to TorqueScript. Quite the contrary, Box2D is a core layer which is deeply interfaced with the rest of the engine. Thanks to this level of implementation, a Torque 2D game can be completely physically driven.
Even the simplest level can be designed and tested using only Box2D physics. The new 2D Physics Model system is what binds your in game objects to the physics system. This model contains all the physics elements you'll ever need such as Bodies, Collision-Shapes, Joints, Render-Actions etc. A Render Action can render anything including static-images, animated-images, particle-effects, text and much more. Render-Actions, like everything else, inherit the new physics capabilities.
Rejoice, for we are not stopping with mere collision and reaction. We are utilizing the full power of Box2D and its many features:
- Continuous collision detection.
- Convex polygons and circles.
- Multiple shapes per body
- Fast broadphase AABB queries
- Collision filters
- Continuous physics with time of impact island solver.
- Persistent body-joint-contact graph
- Contact, friction, and restitution
- Revolute, prismatic, distance, pulley, gear, and mouse joints
- Joint limits, motors, and friction
- Momentum decoupled position correction
- Fairly accurate reaction forces/impulses
The next few blogs will go into greater detail of how the new systems work together with Torque 2D. For now, here is a little something to salivate over.
This is post #5.