Game Development Community

dev|Pro Game Development Curriculum

Torque 2D Development Blog - Box2D Overview

by Michael Perry · 10/30/2009 (4:45 pm) · 74 comments

static.garagegames.com/static/pg/blogs/jason-hetu/Torque-2D_Development-Blog-Header.png

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!


/static/pg/blogs/michael-perry/b2d_icon.png

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.

Torque 2D development blogs:


#21
10/30/2009 (8:52 pm)
Box2D is already ported and being used in iPhone games, so this is one subsystem that ports right over for the future T2Di.

Now we're all wishing for the scripting system to get an equivalent replacement ;)
#22
10/30/2009 (8:53 pm)
Awesome! Please let the next blog be about switching to Python ;)
#23
10/30/2009 (9:08 pm)
Ruby! haha jk.. good luck with that on the iphone
#24
10/30/2009 (9:49 pm)
LUA FTW :)

This is truly awesome work! The TGB physics system isn't horrible but it had it's issues. I've heard only good things about Box2D. I'm looking forward to more blogs like this, yeah T2D in the spotlight!
#25
10/30/2009 (10:16 pm)
does this also pertain to Torque X 2D?
#26
10/30/2009 (10:32 pm)
Finally! :D
Too bad, i've just finish my engine ^^

Does it support ChainEdges and the new version of Box2d with fixtures ?
#27
10/30/2009 (10:33 pm)
Sadly Scott TX2D is a different product.

I am pretty happy to see this will also be on the iPhone!
#28
10/31/2009 (12:26 am)
Well crap, I don't *want* to want to upgrade and spend more money when T2D comes out. I want to be satisfied with TGB.

You guys have screwed that up for me.

Pffft!

Jay Jennings
#29
10/31/2009 (12:37 am)
That's the most exciting news about TGB for the last several years. Any rumors about release date? :)
#30
10/31/2009 (1:16 am)
I Cant Wait For This! :D
#31
10/31/2009 (3:15 am)
Lots of cool ideas coming out for a new T2D game now :)

Great Work !
#32
10/31/2009 (3:41 am)
That's impressive, very nice!

Quote:Any rumors about release date? :)

[rumor]Christmas 2008[/rumor] ;)
#33
10/31/2009 (4:46 am)
Thanks for all the support everyone. Big props go to Melv for this amazing system. It's been a blast to play around with, and so simple to use. The team is very happy to be able to share the excitement with you, since we have been sitting on this announcement for a while.

If you think this is amazing, stay tuned. This is the tip of the iceberg =)
#34
10/31/2009 (5:09 am)
Wow, I don´t care much about physics, but finally working collisions? This will make TGB useful engine. Even for games better than some "zuma type".
Collisions and no Vista bug and we will have real 2D engine for sure.
#35
10/31/2009 (5:40 am)
Thanks everyone!

@Patrick: This kind of physics is far from networking friendly! We'll do what we can though to ensure it works well with the realtime stuff. :)

@Anthony: Because this T2D is a brand new codebase, I've had the opportunity to design something that can be configured to perform well on lower-performance devices. In the low-levels you'll find configurable caching-factories to balance memory/creation overheads and other features. Also, the physics model is completely separated from the Sim. For instance, the demo shown requires no SimObjects to run, they're only used as configuration interfaces. You can create a complete physics set-up in C++ if you chose to do so without creating a single SimObject!

@Ed: Sorry for the wait Ed!

@Rivage: This is using the latest Box2D trunk. If you look hard you'll see a certain "MelvMay" user posting on the Box2D forums! Not sure if you knew or not but chain-edges were dropped a while ago by Erin as they were just a helper construct anyway. Edges are supported though via polygons with two points. Also, one-way collisions with edges are supported natively in T2D which is great news for platformers.

@Stefan: Last year? ;) Seriously though, we're at ASAP right now burning the midnight oil. Not long after we've got a solid date, we'll announce.


I work in the UK so I'm not in the garage each day so I wanted to add my gushy thanks here to the others I work with, namely Phillip O'Shea who's working on the new builder doing a great job, Deborah M. Fike who's been a great manager for me (and a very happy personality), Michael Perry for producing such a great demo and learning this stuff impressively quickly and the rest of the GG Tech&Tools team for producing an awesome core engine to work with. One last one, thanks to Brett Seyler for giving me this ace job!

Message Ends.

Melv.
#36
10/31/2009 (6:18 am)
This is great news. Box2D is probably the best choice for 2D physics right now. As always, great work, Melv!

Quote:Now we're all wishing for the scripting system to get an equivalent replacement ;)
Absolutely! :)
#37
10/31/2009 (8:04 am)
Excellent choice, I use Box2d (with QuickBox2d) in flash and it's a joy to use and a fast / solid physics system. Really looking forward to seeing more about T2D and eventually getting my hands on the thing! :)
#38
10/31/2009 (10:06 am)
This is great and impressive!
#39
10/31/2009 (2:12 pm)
Fascinating stuff. If it can be integrated into C#, does that mean it's possible for Box2D to work with TorqueX?
#40
10/31/2009 (2:16 pm)
I am so excited to start playing with this. It made my morning to read this post. Did someone mention something about a perfect engine? ;)