Physics body.
typedef struct Body { uint sig; byte wobj[320]; } Body;
Body type.
typedef enum BodyType
Fixed object. Does not react to collisions.
BODY_TYPE_STATIC,
Movable object. Does not react to collisions.
BODY_TYPE_KINEMATIC,
Movable object. Reacts to collisions.
BODY_TYPE_DYNAMIC,
Does not participate in the physics simulation.
BODY_TYPE_NONE
End block 'Body type'
} BodyType;
Contact state of intersected objects.
typedef enum BodyContactState
Contact is new.
BODY_CONTACTSTATE_NEW,
Contact is continued.
BODY_CONTACTSTATE_CONT,
Contact is ending.
BODY_CONTACTSTATE_ENDING
End block 'Body contact state'
} BodyContactState;
Physics body contact.
typedef struct BodyContact
Contact state.
BodyContactState state;
Object reference.
void *ref;
Normal of contact on other body.
S3f norm;
Point of contact on this body.
S3f selfPt;
Point of contact on other body.
S3f otherPt;
End block 'Body contact'
} BodyContact;
Get world space position.
API M4f BodyGetPos(Body *body);
body: Body.
returns: Position.
Get angular velocity.
API S3f BodyGetAngVel(Body *body);
body: Body.
returns: Vector.
Get linear velocity.
API S3f BodyGetLinVel(Body *body);
body: Body.
returns: Vector.
Get contacts array.
API uint BodyGetContacts(Body *body, BArray *contacts);
body: Body.
contacts: Contacts array.
returns: Contact count.
Get body caller-defined reference.
API void *BodyGetRef(Body *body);
body: Body.
returns: List key.
Add cone joint between bodies.
API uint BodyAddConeJoint(Body *body1, Body *body2, float angle);
body1: First body.
body2: Second body.
angle: Cone angle limit, or zero for no limit.
returns: Joint ID
Add revolute (hinge) joint between bodies.
API uint BodyAddRevoluteJoint(Body *body1, Body *body2, M4f a, M4f b, float lowerAngle, float upperAngle, float speed, float maxTorque);
body1: First body.
body2: Second body.
a: Self world space joint position.
b: Other body world space joint position.
lowerAngle: Low angle limit, or zero for no limit.
upperAngle: High angle limit, or zero for no limit.
speed: Motor speed, or zero for no motor.
maxTorque: Maximum motor torque, or zero if no motor.
returns: Joint ID.
Add sphere joint between bodies.
API uint BodyAddSphereJoint(Body *body1, Body *body2, S3f a, S3f b);
body1: First body.
body2: Second body.
a: Self world space joint position.
b: Other body world space joint position.
returns: Joint ID.
Add weld (fixed) joint between bodies.
API uint BodyAddWeldJoint(Body *body1, Body *body2);
body1: First body.
body2: Second body.
returns: Joint ID.
Add spring joint between bodies.
API uint BodyAddSpringJoint(Body *body1, Body *body2, S3f a, S3f b, float length, float freq, float damp, bool collideConnected);
body1: First body.
body2: Second body.
a: Self world space joint position.
b: Other body world space joint position.
length: Spring length.
freq: Spring frequency.
damp: Spring damping.
collideConnected: True if connected body collides with self.
returns: Joint ID.
Remove joint.
API void BodyRemoveJoint(Body *body, uint id);
body: Body.
id: Joint ID.
Apply force to body.
API void BodyApplyForce(Body *body, S3f force, bool wake);
body: Body.
force: Force vector in world space.
wake: True if force should wake body.
Apply force at body position.
API void BodyApplyForceAtPt(Body *body, S3f force, S3f p, bool wake);
body: Body.
force: Force vector in world space.
p: Force position in world space.
wake: True if force should wake body.
Apply body torque.
API void BodyApplyTorque(Body *body, S3f torque, bool wake);
body: Body.
torque: Torque vector in world space.
wake: True if force should wake body.
Apply angular body impulse.
API void BodyApplyAngImp(Body *body, S3f imp, bool wake);
body: Body.
imp: Impulse vector in world space.
wake: True if force should wake body.
Apply linear body impulse.
API void BodyApplyLinImp(Body *body, S3f imp, bool wake);
body: Body.
imp: Impulse vector in world space.
wake: True if force should wake body.
Apply linear body impulse at position.
API void BodyApplyLinImpAtPt(Body *body, S3f imp, S3f p, bool wake);
body: Body.
imp: Impulse vector in world space.
p: Impulse position in world space.
wake: True if force should wake body.
Set body angular damping.
API void BodySetAngDamp(Body *body, S3f damp);
body: Body.
damp: Damping vector.
Set body linear damping.
API void BodySetLinDamp(Body *body, S3f damp);
body: Body.
damp: Damping vector.
Set body angular velocity.
API void BodySetAngVel(Body *body, S3f vel);
body: Body.
vel: Velocity vector.
Set body linear velocity.
API void BodySetLinVel(Body *body, S3f vel);
body: Body.
vel: Velocity vector.
Wake/Sleep body.
API void BodySetAwake(Body *body, bool awake);
body: Body.
awake: True to wake body, false to sleep body.
Set body gravity scale.
API void BodySetGravityScale(Body *body, S3f scale);
body: Body.
scale: Gravity scale.
Set body world space position.
API void BodySetPos(Body *body, M4f pos);
body: Body.
pos: Position matrix.
Add collision shape to body.
API void BodyAddCollShape(Body *body, CollShape *shape);
body: Body.
shape: Collision shape.
Set physics body mass and inertia properties.
API void BodySetMassAndTensor(Body *body, S3f center, float mass, S3f inertiaX, S3f inertiaY, S3f inertiaZ);
body: Body.
center: Center of mass.
mass: Mass value.
inertiaX: X inertia.
inertiaY: Y inertia.
inertiaZ: Z inertia.
Set physics body mass properties.
API void BodySetMass(Body *body, S3f center, float mass);
body: Body.
center: Center of mass.
mass: Mass value.
Initialize physics body.
API void BodyInit(Body *body, World *world, BodyType type, M4f pos, uint collMask, bool wantContacts, void *ref);
body: Body.
world: World.
type: Body type.
pos: Initial body position.
collMask: Collision bit mask. Only bodies with same bits collide. 0=collide all.
wantContacts: True if collision contacts are wanted.
ref: ref
Release physics body.
API void BodyRel(Body *body);
body: Body.