Chipmunk2D Pro API Reference
7.0.0
|
Chipmunk's rigid body type. More...
Typedefs | |
typedef void(* | cpBodyVelocityFunc )(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) |
Rigid body velocity update function type. | |
typedef void(* | cpBodyPositionFunc )(cpBody *body, cpFloat dt) |
Rigid body position update function type. | |
typedef void(* | cpBodyShapeIteratorFunc )(cpBody *body, cpShape *shape, void *data) |
Body/shape iterator callback function type. | |
typedef void(* | cpBodyConstraintIteratorFunc )(cpBody *body, cpConstraint *constraint, void *data) |
Body/constraint iterator callback function type. | |
typedef void(* | cpBodyArbiterIteratorFunc )(cpBody *body, cpArbiter *arbiter, void *data) |
Body/arbiter iterator callback function type. | |
Enumerations | |
enum | cpBodyType { CP_BODY_TYPE_DYNAMIC, CP_BODY_TYPE_KINEMATIC, CP_BODY_TYPE_STATIC } |
Functions | |
cpBody * | cpBodyAlloc (void) |
Allocate a cpBody. | |
cpBody * | cpBodyInit (cpBody *body, cpFloat mass, cpFloat moment) |
Initialize a cpBody. | |
cpBody * | cpBodyNew (cpFloat mass, cpFloat moment) |
Allocate and initialize a cpBody. | |
cpBody * | cpBodyNewKinematic (void) |
Allocate and initialize a cpBody, and set it as a kinematic body. | |
cpBody * | cpBodyNewStatic (void) |
Allocate and initialize a cpBody, and set it as a static body. | |
void | cpBodyDestroy (cpBody *body) |
Destroy a cpBody. | |
void | cpBodyFree (cpBody *body) |
Destroy and free a cpBody. | |
void | cpBodyActivate (cpBody *body) |
Wake up a sleeping or idle body. | |
void | cpBodyActivateStatic (cpBody *body, cpShape *filter) |
Wake up any sleeping or idle bodies touching a static body. | |
void | cpBodySleep (cpBody *body) |
Force a body to fall asleep immediately. | |
void | cpBodySleepWithGroup (cpBody *body, cpBody *group) |
Force a body to fall asleep immediately along with other bodies in a group. | |
cpBool | cpBodyIsSleeping (const cpBody *body) |
Returns true if the body is sleeping. | |
cpBodyType | cpBodyGetType (cpBody *body) |
Get the type of the body. | |
void | cpBodySetType (cpBody *body, cpBodyType type) |
Set the type of the body. | |
cpSpace * | cpBodyGetSpace (const cpBody *body) |
Get the space this body is added to. | |
cpFloat | cpBodyGetMass (const cpBody *body) |
Get the mass of the body. | |
void | cpBodySetMass (cpBody *body, cpFloat m) |
Set the mass of the body. | |
cpFloat | cpBodyGetMoment (const cpBody *body) |
Get the moment of inertia of the body. | |
void | cpBodySetMoment (cpBody *body, cpFloat i) |
Set the moment of inertia of the body. | |
cpVect | cpBodyGetPosition (const cpBody *body) |
Set the position of a body. | |
void | cpBodySetPosition (cpBody *body, cpVect pos) |
Set the position of the body. | |
cpVect | cpBodyGetCenterOfGravity (const cpBody *body) |
Get the offset of the center of gravity in body local coordinates. | |
void | cpBodySetCenterOfGravity (cpBody *body, cpVect cog) |
Set the offset of the center of gravity in body local coordinates. | |
cpVect | cpBodyGetVelocity (const cpBody *body) |
Get the velocity of the body. | |
void | cpBodySetVelocity (cpBody *body, cpVect velocity) |
Set the velocity of the body. | |
cpVect | cpBodyGetForce (const cpBody *body) |
Get the force applied to the body for the next time step. | |
void | cpBodySetForce (cpBody *body, cpVect force) |
Set the force applied to the body for the next time step. | |
cpFloat | cpBodyGetAngle (const cpBody *body) |
Get the angle of the body. | |
void | cpBodySetAngle (cpBody *body, cpFloat a) |
Set the angle of a body. | |
cpFloat | cpBodyGetAngularVelocity (const cpBody *body) |
Get the angular velocity of the body. | |
void | cpBodySetAngularVelocity (cpBody *body, cpFloat angularVelocity) |
Set the angular velocity of the body. | |
cpFloat | cpBodyGetTorque (const cpBody *body) |
Get the torque applied to the body for the next time step. | |
void | cpBodySetTorque (cpBody *body, cpFloat torque) |
Set the torque applied to the body for the next time step. | |
cpVect | cpBodyGetRotation (const cpBody *body) |
Get the rotation vector of the body. (The x basis vector of it's transform.) | |
cpDataPointer | cpBodyGetUserData (const cpBody *body) |
Get the user data pointer assigned to the body. | |
void | cpBodySetUserData (cpBody *body, cpDataPointer userData) |
Set the user data pointer assigned to the body. | |
void | cpBodySetVelocityUpdateFunc (cpBody *body, cpBodyVelocityFunc velocityFunc) |
Set the callback used to update a body's velocity. | |
void | cpBodySetPositionUpdateFunc (cpBody *body, cpBodyPositionFunc positionFunc) |
Set the callback used to update a body's position. More... | |
void | cpBodyUpdateVelocity (cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) |
Default velocity integration function.. | |
void | cpBodyUpdatePosition (cpBody *body, cpFloat dt) |
Default position integration function. | |
cpVect | cpBodyLocalToWorld (const cpBody *body, const cpVect point) |
Convert body relative/local coordinates to absolute/world coordinates. | |
cpVect | cpBodyWorldToLocal (const cpBody *body, const cpVect point) |
Convert body absolute/world coordinates to relative/local coordinates. | |
void | cpBodyApplyForceAtWorldPoint (cpBody *body, cpVect force, cpVect point) |
Apply a force to a body. Both the force and point are expressed in world coordinates. | |
void | cpBodyApplyForceAtLocalPoint (cpBody *body, cpVect force, cpVect point) |
Apply a force to a body. Both the force and point are expressed in body local coordinates. | |
void | cpBodyApplyImpulseAtWorldPoint (cpBody *body, cpVect impulse, cpVect point) |
Apply an impulse to a body. Both the impulse and point are expressed in world coordinates. | |
void | cpBodyApplyImpulseAtLocalPoint (cpBody *body, cpVect impulse, cpVect point) |
Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates. | |
cpVect | cpBodyGetVelocityAtWorldPoint (const cpBody *body, cpVect point) |
Get the velocity on a body (in world units) at a point on the body in world coordinates. | |
cpVect | cpBodyGetVelocityAtLocalPoint (const cpBody *body, cpVect point) |
Get the velocity on a body (in world units) at a point on the body in local coordinates. | |
cpFloat | cpBodyKineticEnergy (const cpBody *body) |
Get the amount of kinetic energy contained by the body. | |
void | cpBodyEachShape (cpBody *body, cpBodyShapeIteratorFunc func, void *data) |
Call func once for each shape attached to body and added to the space. | |
void | cpBodyEachConstraint (cpBody *body, cpBodyConstraintIteratorFunc func, void *data) |
Call func once for each constraint attached to body and added to the space. | |
void | cpBodyEachArbiter (cpBody *body, cpBodyArbiterIteratorFunc func, void *data) |
Call func once for each arbiter that is currently active on the body. | |
Chipmunk's rigid body type.
Rigid bodies hold the physical properties of an object like it's mass, and position and velocity of it's center of gravity. They don't have an shape on their own. They are given a shape by creating collision shapes (cpShape) that point to the body.
enum cpBodyType |
void cpBodySetPositionUpdateFunc | ( | cpBody * | body, |
cpBodyPositionFunc | positionFunc | ||
) |
Set the callback used to update a body's position.
NOTE: It's not generally recommended to override this unless you call the default position update function.