sorry – I just tried it and there is a problem because testApp is compiled as .mm and not .cpp, so there’s some funkiness if you are including the .h file of a .mm in a .cpp. I can see a ton of errors relating to objective-c in a cpp world, etc. Converting blob.cpp to blob.mm didn’t help – so it will require some further research. For normal times when you are doing non iphone stuff, that trick should work fine.
for now, can you do:
a) in Blob.h, make a variable:
ofxBox2d * testAppsBox2d;
b) in testApp.mm, do:
box2d.init();
box2d.setGravity(0.0f, 0.0f);
box2d.setIterations(2, 2);
box2d.createBounds(0.0f, 0.0f, ofGetWidth(), ofGetHeight());
blob.init();
blob.testAppsBox2d = &box2d;
then you should be able to replace the code you’ve written, as:
void Blob::init() {
float radius = 10.0f;
// the joints
for(int i = 0; i < TOTAL_POINTS; i++) {
float x = (ofGetWidth() * 0.5f) + cos(i) * 50;
float y = 50 + sin(i) * 50;
ballJoints[i].setPhysics(3.0f, 0.53f, 0.1f);
ballJoints[i].setup(testAppsBox2d->getWorld(), x, y, 10);
}
// connect all the ball joints
for(int i = 1; i < TOTAL_POINTS; i++) {
joints[i].setWorld(testAppsBox2d->getWorld());
joints[i].addJoint(ballJoints[i].body, ballJoints[i - 1].body, 3.0, 0.5);
// set the first and last joint
if(i == TOTAL_POINTS - 1) {
joints[0].setWorld(testAppsBox2d->getWorld());
joints[0].addJoint(ballJoints[TOTAL_POINTS - 1].body, ballJoints[0].body, 3.0, 0.5);
}
}
}
also, make sure you are using the latest box2d:
http://code.google.com/p/vanderlin/down-…-d-v2.1.zip
which compiles fine for iphone.
hope that helps!
zach