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.
Torque 2D development blogs:
- Post #1 - Real-Time Networking
- Post #2 - Expectations
- Post #3 - Integrating with Torque 3D
- Post #4 - Editor Design
- Post #5 - Box2D Overview
- Post #6 - Coming Soon!
#42
10/31/2009 (7:22 pm)
I was pumped when I saw this in my emails, but then no TX2D = sad panda.
#43
11/01/2009 (3:37 am)
well now i gotta have T2D too!
#44
11/01/2009 (9:37 am)
Looks great, I hope the upgrade from TGB is still in the "hobby" range and not like the T3D upgrade...
#45
11/02/2009 (9:52 pm)
Looks AWESOME!!! one question, will it have web deployment out of the box, like T3D?, if that is so, it will be ULTIMATE!!!!
#46
It should still be affordable as "Low Cost" is one of T2D's qualities towards a perfect engine according to the "Perfect Engine Dev Factors vs Torque Game Builder" chart in part 2 of this blog series.
However I'm still nervous about the upgrade cost as well.
11/03/2009 (2:42 am)
@Max KiellandIt should still be affordable as "Low Cost" is one of T2D's qualities towards a perfect engine according to the "Perfect Engine Dev Factors vs Torque Game Builder" chart in part 2 of this blog series.
However I'm still nervous about the upgrade cost as well.
#47
Memory problems, vista crashes, windows7 crashes, that would be more important than Box2D :P
11/03/2009 (1:22 pm)
I hope the memory usage problems in this new T2D is adressed too.Memory problems, vista crashes, windows7 crashes, that would be more important than Box2D :P
#48
TGB didn't have any problems with the OS because it didn't interact directly with the OS, the underlying TGE v1.5 did however and that was/is the problem. Any fixes apply to the TGE core. In this respect, T2D doesn't interact with the OS but the underlying T3D core does. If T3D works then T2D will just like if TGE works then TGB will too.
What I'm saying is that both TGB and T2D did not develop any code to touch those areas, it's all in the core.
If it helps, I've developed T2D using both Vista Ultimate x64 and over the last several months using Windows 7 Ultimate x64 and I've not had a single problem. This is to be expected as the TGE core and the T3D core are almost incomparable! 8)
Melv.
11/03/2009 (1:32 pm)
I'm not sure what "memory problems" you're talking about to be honest. If you're talking about the image-map stuff then you won't have to worry about those. Even so, a fix for that has been out for a long time (if you have source). Also, it's hard to control what Microsoft do so expecting TGB to run fine under Windows 7 isn't really fair.TGB didn't have any problems with the OS because it didn't interact directly with the OS, the underlying TGE v1.5 did however and that was/is the problem. Any fixes apply to the TGE core. In this respect, T2D doesn't interact with the OS but the underlying T3D core does. If T3D works then T2D will just like if TGE works then TGB will too.
What I'm saying is that both TGB and T2D did not develop any code to touch those areas, it's all in the core.
If it helps, I've developed T2D using both Vista Ultimate x64 and over the last several months using Windows 7 Ultimate x64 and I've not had a single problem. This is to be expected as the TGE core and the T3D core are almost incomparable! 8)
Melv.
#49
I have that fix (you mailed it to me, thanks :) ), but it didn't change much.
As i understand currently TGB loads the same texture twice ? Am i correct ?
TGB runs fine under Windows 7 with the fixes found in the forum to fix Vista crashes problems, crashes that have been reported for years.
It's not your fault i know, i'm just venting here, from all the problems i had in the past with publishers turning down my games for OS crashes, etc, it's quite frustrating to have you game done, and then refused for stuff like this.
But it's great to know that it doens't have any problems now , can't wait to try it out :)
I will be waiting, are older TGB projects automatically upgradable into the new T2D ?
11/03/2009 (2:10 pm)
By "memory problems", i mean the image-maps yes.I have that fix (you mailed it to me, thanks :) ), but it didn't change much.
As i understand currently TGB loads the same texture twice ? Am i correct ?
TGB runs fine under Windows 7 with the fixes found in the forum to fix Vista crashes problems, crashes that have been reported for years.
It's not your fault i know, i'm just venting here, from all the problems i had in the past with publishers turning down my games for OS crashes, etc, it's quite frustrating to have you game done, and then refused for stuff like this.
But it's great to know that it doens't have any problems now , can't wait to try it out :)
I will be waiting, are older TGB projects automatically upgradable into the new T2D ?
#50
11/03/2009 (2:33 pm)
Quote:I have that fix (you mailed it to me, thanks :) ), but it didn't change much.No, it doesn't load it twice it's that the original bitmap is still in memory. Again, this was done because TGE lacked the ability to deal with notifications for procedural textures which is what an image-map is. If you did use the code I sent you then you'll see a reduction of around 40% guaranteed. If your consumption didn't change then it's not the image-maps and you've got another problem.
As i understand currently TGB loads the same texture twice ? Am i correct ?
Quote:I will be waiting, are older TGB projects automatically upgradable into the new T2D ?No. T2D is so different than TGB that it's not easy to do. I'm not talking about file-formats, I'm talking about the way you control T2D so all your scripts would have to change. With that said, backwards compatibility is important so we'd like to take a number of steps to help folks migrate from one to the other where possible.
#51
11/03/2009 (2:42 pm)
will it have web deployment????
#52
11/03/2009 (2:47 pm)
@Gonzalo: Still working on it. We don't like to announce features unless we are 95% certain it will make it into final candidate. But it is something we are heavily considering.
#53
11/03/2009 (3:12 pm)
AWESOME!!!
#54
That will definitely be one huge factor in my choice to buy / use T2D.
11/04/2009 (7:02 am)
I think web deployment should be in the top of the list of features, what with flash and the like and the current web / facebook generation, should be vital.That will definitely be one huge factor in my choice to buy / use T2D.
#55
11/04/2009 (8:09 am)
Web plugins for a game plugin aren't all that useful unless everybody is happy with the included set of features. The power of the Torque engines comes in part from the fact you can add middleware as needed (FMOD for sound, SQLite for storage are both common). We'll also need some "vital" games for popularity to spread, and vector graphics to keep sizes down. Flash is in part popular because SVG-based graphics make the games fairly small.
#56
11/04/2009 (7:13 pm)
Awesome! physics makes any game fun!
#57
11/05/2009 (10:12 am)
Looks really interesting. As some others, I'm a little bit worried about the update cost (I know I couldn't afford something in t3d price range for example), but it does look really exciting...
#58
Size is becoming less and less of an issue, I think trust and a seemless integration is the key, something that would allow T2D users to create an experience like the guys at flashbang studios have done excellently with Blurst.com and the unity plugin would be a major win.
11/05/2009 (10:23 am)
@Ronny: True, but I'm not a source editor (yet) so plugin in stuff isn't a doddle for me. As far as features are concerned, a similar implementation to flash or unity / shiva is fine.Size is becoming less and less of an issue, I think trust and a seemless integration is the key, something that would allow T2D users to create an experience like the guys at flashbang studios have done excellently with Blurst.com and the unity plugin would be a major win.
#59
I hope T2D is going to be filled with enough features then to really compete with Flash, because at nearly 100% it's a really darn popular plugin ;)
I'd wish for the community to work together on maintaining a definite official plugin - GG just need to ensure the core tech works (installable as plugin on both platforms, has asset downloading functions from the get-go), and a semi-official plugin could be maintained with the most popular add-ons.
Anything we can do in script eases compatibility, of course.
@Seb:
I'm also slightly worried. Still not making a ton of money, so I hope the upgrade cost from TGB to T2D won't be as huge as TGEA to T3D. I also wonder if the iTorque engines will count towards these upgrades, with them unifying the four engines a bit.
11/05/2009 (11:20 am)
@Leroy:I hope T2D is going to be filled with enough features then to really compete with Flash, because at nearly 100% it's a really darn popular plugin ;)
I'd wish for the community to work together on maintaining a definite official plugin - GG just need to ensure the core tech works (installable as plugin on both platforms, has asset downloading functions from the get-go), and a semi-official plugin could be maintained with the most popular add-ons.
Anything we can do in script eases compatibility, of course.
@Seb:
I'm also slightly worried. Still not making a ton of money, so I hope the upgrade cost from TGB to T2D won't be as huge as TGEA to T3D. I also wonder if the iTorque engines will count towards these upgrades, with them unifying the four engines a bit.

Torque Owner David Robert Pemberton
www.deadlyassets.com