viagra online | Tramadol | levitra
XanaxAdderall onlineLevitraADDERALL onlineadderall without prescriptionPhentermine onlinetramadol onlinevalium online

Archive for September 19th, 2007

Musicala v1.3 – Chipmunk physics!

After discovering Box2D only supports poly-to-poly contacts and finding a bug in the collision pair generation, I decided to try another 2D physics engine that’s more mature and stable:

EDITED: Sept 27, 2007 – added video.

The code is accessible via CVS on SourceForge.

The Lua binding is crap, but everything in Chipmunk appears to work as before. The funny thing is, I’ve never seen any of the demos working because they are all OpenGL + OS X based!

Add comment September 19th, 2007

Musicala v1.2 – Lua-based 2D physics for all

Yesterday, I threw in Lua scripting support in the Musicala framework and also took the time to bind it to Box2D (ugh – 905 complete).

So instead of writing C++ code like this:


// Create left, bottom, right walls
Ogre::Real length = 50.0f;
Ogre::Real thickness = 2.0f;
b2World* world = box2d->getWorld();
{
b2ShapeDescription sd;
sd.type = e_boxShape;
sd.box.m_extents.Set(length, thickness);

b2BodyDescription bd;
bd.position.Set(0.0f, -length);
bd.AddShape(&sd);
ground = world->CreateBody(&bd);
}
{
b2ShapeDescription sd;
sd.type = e_boxShape;
sd.box.m_extents.Set(length, thickness);

b2BodyDescription bd;
bd.position.Set(length, 0.0f);
bd.rotation = b2_pi*0.5f;
bd.AddShape(&sd);
world->CreateBody(&bd);
}
{
b2ShapeDescription sd;
sd.type = e_boxShape;
sd.box.m_extents.Set(length, thickness);

b2BodyDescription bd;
bd.position.Set(-length, 0.0f);
bd.rotation = b2_pi*-0.5f;
bd.AddShape(&sd);
world->CreateBody(&bd);
}

You write it in Lua so you don’t need to re-compile the app if you want a small change.

-- Start
local box2d = Musicala.Box2dManager:getSingletonPtr()
local world = box2d:getWorld(0)
local sd = b2ShapeDescription()
sd.type = e_boxShape
sd.box.m_extents:Set(50, 2)
local bd = b2BodyDescription()
bd.position.x = 0.0
bd.position.y = -50.0
bd:AddShape(sd)
world:CreateBody(bd)

bd.position.x = 50.0
bd.position.y = 0.0
bd.rotation = 3.1415*0.5
bd:AddShape(sd)
world:CreateBody(bd)

bd.position.x = -50.0
bd.position.y = 0.0
bd.rotation = -3.1415*0.5
bd:AddShape(sd)
world:CreateBody(bd)

-- End

Get the demo here which I’ve temporarily named “Lua2D”:

http://sourceforge.net/project/showfiles.php?group_id=197381&package_id=246104

Box2D is quite stable, but a little too stable. The typically jitter of classical 2D physics engine is GONE (say bye-bye penalty methods too), but is now replaced with a “rigid stone block” feel. I guess that’s typical of rigid body physics (no deformations).

TODO

  • Fix passing of arrays of arrays between C++ and Lua
  • Add b2 utils like random to the Lua binding.

Add comment September 19th, 2007


Calendar

September 2007
S M T W T F S
« Aug   Nov »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Posts by Month

Posts by Category