Chipmunk is a great physics engine for use with openFrameworks because it isn’t weighed down with any graphics support. The documentation is pretty sparse, but I am starting on a little wrapper working and incorporated the ofxDelaunay addon by plong0. There are still a lot of things missing, like springs and joints and stuff. But I wanted to post this in case anyone else is interested in the code. Here is what the wrapper class, ofxCPBody looks like.
#ifndef _OFX_CP_BODY
#define _OFX_CP_BODY
#include "chipmunk.h"
#include "ofxDelaunay.h"
#include "ofxVectorMath.h"
class ofxCpBody {
public:
cpBody *body;
vector<cpShape*> shapes;
cpSpace *space; // Holds our Space object
ofxCpBody(cpSpace* _space, bool inSpace=true, double mass=INFINITY, double inertia=INFINITY);
~ofxCpBody();
void removeFromSpace();
int addCircle(int radius, int xoffset, int yoffset, int collision_type=1, bool isStatic=false, double friction=0.5, double elacticity=0.5);
int addPoly(int nverts, ofPoint* points, int xoffset, int yoffset, int collision_type=1, bool isStatic=false, double friction=0.5, double elacticity=0.5);
int* addTriangulatedPoly(vector<ofPoint> points, int xoffset, int yoffset, int collision_type=1, bool isStatic=false, double friction=0.5, double elacticity=0.5);
double flipy(double y);
int addShape(cpShape* shape);
void setPosition(double x, double y);
ofPoint getPosition();
int getx();
int gety();
float getRotation();
//void cpBodyApplyImpulse(cpBody *body, cpVect j, cpVect r)
void applyImpulse(ofxVec2f j, ofxVec2f r);
//void cpBodyApplyForce(cpBody *body, cpVect f, cpVect r)
void applyForce(ofxVec2f f, ofxVec2f r);
virtual void draw();
};
#endif
Week 151
TV of Tomorrow is finally over. Overall, the experience was okay. We didn’t meet anyone who was interested in our project, and the entire festival (our presentation included) was plagued with technical difficulties leading to extremely poor image quality from the projectors.
The torch video is kind of crashing and burning at the moment. We got a few good contributions from some awesome people out there (post one and post two), but unfortunately it just wasn’t enough. We are thinking about scrapping the whole idea and using clips from famous “running” scenes in movies instead of the crowdsourced videos. Shame.