So, I've looked over the 08_Physics tutorial. Two things I found odd:
1) No mention of a gravity vector for the physics simulation, yet objects still fall. Is this a feature of the standard executable?
2) Acceleration seems to be higher than expected. When I use a gravity vector with a value of 9.8, gravitic acceleration is very low. I have to set gravity to about 150 to approach anything seen in the tutorial.
Comments
~
~
- You can also set a per-body gravity anytime during runtime as it's a feature that has been added to our version of Box2D.
- The units used are consistent with those used by the rest of the engine, ie. SI except for distances which are in pixels. There's an additional config property, Physics.DimensionRatio, that allow the user to customize the physics system based on his/her needs.
By default, DimensionRatio is 0.01, which means 1 pixel equates to 0.01 meter, hence the big numbers you've noticed for physics values.
It matters as Box2D behaves the best for objects ranging from 0.1 meters to 100 meters and gets either unstable or loses accuracy with values out of this range.
Follow up question. I know ORX uses Box2D under the hood. There doesn't seem to be any support for Box2D chain shapes.
I don't know enough about Box2D to know if chain shapes are good/bad/ugly. For static environment shapes, it seems only polygons (mesh) and circles (is the "sphere" name a misnomer? Or is it the 2.5d nature of ORX?) are supported in ORX.
I'll probably integrate a new version of Box2D early next year. It's not a straightforward operation, unfortunately, as I've made some changes in Box2D internals to support some features I needed in orx (like sticky sliding bodies and per-body gravity).
I believe Lydesik is also working on implementing a physics plugin based on Bullet in his own repository clone of orx.
You currently have access to 3 different shapes for defining bodies: box (in 2D, a rectangle), sphere (in 2D, a circle) and mesh (in 2D a polygon). The names are not 2D specific as they'll be the same properties in 3D too (orx's world is in 3D, it's only visual-related data and the render/display plugins that can only handle 2D, but it's only a first step).
I'm surprised Box2D doesn't have this out of the ... uh ... box.
There's quite some literature on the net on that topic, actually.
Most of the time people solve that issue by applying their own "graivty" force.
In Box2D 2.2 they added a per-object... gravity scale! Which is useless if you want to change the direction of the gravity.
Not sure why they won't add it as it took me probably ~10 mins to implement in Box2D, it's not exactly a tough task.