For an object in freefall, the center of gravity is the point it rotates around. If you want it to rotate around a different point, you need to cause it to do so using a pivot joint for example.
If the joint you are using is not causing any rotation, then the joint is probably aligned vertically with the center of gravity of the two bodies involved.
I'm not exactly certain what you are trying to do in the code snippet:
Here you are using coordinate conversions to set the position of body2 based on it's previous (presumably initialized) position/rotation.
Code: Select all
v = cpv(12.0, 12.0);
v = cpBodyLocal2World(body2, v);
v = cpBodyWorld2Local(body1, v);
cpBodySetPos(body2, v);
cpBodySetAngle(body2, -30.0 * M_PI / 180.0f);
Here you are attaching the pin joint to the center of gravity of body2. This will cause no rotation of body2. You are also creating a 0 length pin joint which should be avoided. If you want a zero length pin joint, you really want a pivot joint instead which does the same thing only it does it in a much more stable way. What exactly to body1 and body2 represent?
Code: Select all
v2 = cpv(0.0, 0.0);
v1 = cpBodyLocal2World(body2, v2);
v1 = cpBodyWorld2Local(body1, v1);
cpSpaceAddConstraint(space, cpPinJointNew(body2, body1, v2, v1));
Did you mean to do something with these variables? They were never used again.
Code: Select all
cpFloat mass = 0.5f;
cpFloat moment = cpMomentForPoly(mass, 4, verts, cpvzero);
riderLowerArm = cpBodyNew(riderLowerArmMass, riderLowerArmMoment);
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/