Showing posts with label physics. Show all posts
Showing posts with label physics. Show all posts

Sunday, November 22, 2009

Entry #07 : Testing Box2D physics engine








For a few projects that I have in mind I've been looking at physics engine which are programming libraries that let you simulate some laws of physics and are usually used in games to give a more realistic feelings to thing. Some games are even only based on the physics simulation, like Perfect Balance.

After ruling out the possibility of writing my own engine - it is VERY complicated when you start to go beyond Newton's law of motion and try to implement collision detection and response - I found Box2D, a free open source engine initially written in C++ but also available for Java (JBox2D).

The library let's you define and position bodies and define how they work with each other using joints.

In this experiment I created a landscape using solid static bodies and moving ones that react to other bodies. I created a bridge by linking bodies with joints and a rotating thingy with a joint that act as a motor.

Unfortunately I'm not able to record the animation so dowload the Processing sketch and try out yourself. You will also need to download JBox2D here and copy it to you Processing libraries folder.