Back to main page

Rigid body

int RigidBody_Create_Static(int CollisionShape,float Pos_X,float Pos_Y,float Pos_Z,float XAxis_X,float XAxis_Y,float XAxis_Z,float YAxis_X,float YAxis_Y,float YAxis_Z);

Static bodies should not be moved during simulation because moving them does not activate sleeping bodies. Use a kinematic body instead if you want to move it.

They are useful for most things in a large world since they don't take much performance. You can delete a static body and replace it with dynamic fragments when an item is destroyed.

The new rigid body must be deleted before you can delete the collision shape that it use.

The X and Y axis is used exactly as in RigidBody_SetTransformation for setting the initial axis system.

CollisionShape is a valid collision shape.

Returns the ID to a new static rigid body using CollisionShape at (Pos_X,Pos_Y,Pos_Z) with an axis system orthogonalized from (XAxis_X,XAxis_Y,XAxis_Z) and (YAxis_X,YAxis_Y,YAxis_Z).

int RigidBody_Create_Kinematic(int CollisionShape,float Pos_X,float Pos_Y,float Pos_Z,float XAxis_X,float XAxis_Y,float XAxis_Z,float YAxis_X,float YAxis_Y,float YAxis_Z);

Kinematic bodies are used for things that move but is not affected by forces from the simulation.

Try to use dynamic bodies instead since kinematic bodies can't collide with each other and may cause dynamic bodies to shake when pressed by an infinite force.

They are useful for extremely heavy things like trains and blast doors.

The new rigid body must be deleted before you can delete the collision shape that it use.

The X and Y axis is used exactly as in RigidBody_SetTransformation for setting the initial axis system.

CollisionShape is a valid collision shape.

Returns the ID to a new kinematic rigid body using CollisionShape at (Pos_X,Pos_Y,Pos_Z) with an axis system orthogonalized from (XAxis_X,XAxis_Y,XAxis_Z) and (YAxis_X,YAxis_Y,YAxis_Z).

int RigidBody_Create_Dynamic(int CollisionShape,float Mass,float Pos_X,float Pos_Y,float Pos_Z,float XAxis_X,float XAxis_Y,float XAxis_Z,float YAxis_X,float YAxis_Y,float YAxis_Z);

Dynamic bodies move during simulation and are affected by forces. To save preformance, they can be deactivated automatically when nothing nearby has moved for a while.

Do not try to set it's location every step of the simulation since that will create artifacts. Apply forces and impulses and let the physics engine handle the movement for you.

The new rigid body must be deleted before you can delete the collision shape that it use.

The X and Y axis is used exactly as in RigidBody_SetTransformation for setting the initial axis system.

The body's linear mass is set to Mass.

The body's local inertia is set to CollisionShape's local inertia per mass multiplied with Mass.

CollisionShape is a non static collision shape and Mass ≥ 0.00001.

Returns the ID to a new dynamic rigid body using CollisionShape at (Pos_X,Pos_Y,Pos_Z) with an axis system orthogonalized from (XAxis_X,XAxis_Y,XAxis_Z) and (YAxis_X,YAxis_Y,YAxis_Z).

void RigidBody_Delete(int RigidBody);

RigidBody is a valid rigid body.

Removes RigidBody

void RigidBody_SetPosition(int RigidBody, float X, float Y, float Z);

This is used to only set the location of a rigid body.

RigidBody is a valid rigid body.

RigidBody's position is set to (X,Y,Z).

void RigidBody_GetPosition_OutV3(int RigidBody);

This does the same as calling RigidBody_GetTransformation_OutM4 and taking (X4,Y4,Z4) from the matrix buffer but is faster and easier to use.

RigidBody is a valid rigid body.

RigidBody's position is written to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_SetTransformation(int RigidBody,float Pos_X,float Pos_Y,float Pos_Z,float XAxis_X,float XAxis_Y,float XAxis_Z,float YAxis_X,float YAxis_Y,float YAxis_Z);

This is used to set the location and axis system of a rigid body. During simulation, you should only use it with kinematic bodies.

Unlike visual instances, this axis system must be normalized and orthogonal. Use local scaling in the collision shape of you want to change the size.

The orthogonalization is normalizing the X and Y axis before generating the axis system. The X axis is only normalized while the Y axis is used to generate the Z axis together with the X axis. The Y axis is later replaced by a new Y axis generated from the Z and X axis.

RigidBody is a valid rigid body.

RigidBody's position is set to (Pos_X,Pos_Y,Pos_Z) and RigidBody's axis system is orthogonalized from (XAxis_X,XAxis_Y,XAxis_Z) and (YAxis_X,YAxis_Y,YAxis_Z).

void RigidBody_GetTransformation_OutM4(int RigidBody);

RigidBody is a valid rigid body.

RigidBody's transformation after the last physical step is written to the matrix buffer.

void RigidBody_GetTransformation_Interpolated_OutM4(int RigidBody,float TimeOffset);

This interpolation is only meant to be used to fill the gaps between fixed simulation steps and is not good for time offsets greater than one tenth of a second.

RigidBody is a valid rigid body.

RigidBody's interpolated transformation as it is approximated to be after TimeOffset seconds is written to the matrix buffer.

void RigidBody_SetLinearSleepingThreshold(int RigidBody,float LinearTreshold);

RigidBody is a valid rigid body and LinearTreshold > 0.

RigidBody's linear sleeping treshold is set to LinearTreshold.

float RigidBody_GetLinearSleepingThreshold(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's linear sleeping treshold.

void RigidBody_SetAngularSleepingThreshold(int RigidBody,float AngularTreshold);

RigidBody is a valid rigid body and AngularTreshold > 0.

RigidBody's angular sleeping treshold is set to AngularTreshold.

float RigidBody_GetAngularSleepingThreshold(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's angular sleeping treshold.

void RigidBody_SetActivationState(int RigidBody,int ActivationState);

Use this with ACTIVE_TAG as ActivationState before applying forces to RigidBody.

Activation states:

1 = ACTIVE_TAG

The dynamic rigid body can move and respond to forces and impulses.

2 = ISLAND_SLEEPING

The rigid body is sleeping, static or kinematic.

3 = WANTS_DEACTIVATION

The rigid body is below it's deactivation tresholds but something in it's island of overlapping world space bounding boxes is still active.

4 = DISABLE_DEACTIVATION

The rigid body can not be deactivated from inactivity.

5 = DISABLE_SIMULATION

The rigid body is not being simulated. This is used by the physics engine when the world space bounding box fail an assertion.

RigidBody is a valid rigid body and ActivationState is a valid activation state.

RigidBody's activation state is set to ActivationState if possible. Static and kinematic bodies can not be set to ACTIVE_TAG.

int RigidBody_GetActivationState(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's activation state as documented in RigidBody_SetActivationState.

void RigidBody_SetRestitution(int RigidBody, float Restitution);

When two bodies collide, the "bounciness" is the product of their restitutions.

0 is the default value that rigid bodies have after creation.

If Restitution is clamped to the valid range if it goes outside of 0 to 1.

RigidBody is a valid rigid body and 0 <= Restitution <= 1.

RigidBody's restitution is set to Restitution.

float RigidBody_GetRestitution(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's restitution.

void RigidBody_GetBoundingBoxMinimum_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's world space bounding box minimum to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_GetBoundingBoxMaximum_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's world space bounding box maximum to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_Dynamic_ApplyForce_Linear(int RigidBody,float Acc_X,float Acc_Y,float Acc_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

RigidBody is a dynamic rigid body.

RigidBody's linear velocity in world space will be increased by (Acc_X,Acc_Y,Acc_Z) multiplied with the timestep in the next physical simulation step.

void RigidBody_Dynamic_ApplyForce_Angular(int RigidBody,float Acc_X,float Acc_Y,float Acc_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

RigidBody is a dynamic rigid body.

RigidBody's angular velocity in world space will be increased by (Acc_X,Acc_Y,Acc_Z) multiplied with the timestep in the next physical simulation step.

void RigidBody_Dynamic_ApplyForce_Point(int RigidBody,float Acc_X,float Acc_Y,float Acc_Z,float Pos_X,float Pos_Y,float Pos_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

(Pos_X,Pos_Y,Pos_Z) is represented in relative space that follow the rigid body's position but not orientation. See Spaces for information about relative space

(Acc_X,Acc_Y,Acc_Z) is not representing a position and is therefor both world space and relative space at the same time.

RigidBody is a dynamic rigid body.

The force (Acc_X,Acc_Y,Acc_Z) from (Pos_X,Pos_Y,Pos_Z) in RigidBody's relative space is applied to RigidBody.

void RigidBody_Dynamic_ApplyImpulse_Linear(int RigidBody,float Vel_X,float Vel_Y,float Vel_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

RigidBody is a dynamic rigid body.

RigidBody's linear velocity in world space will be increased by (Vel_X,Vel_Y,Vel_Z) in the next physical simulation step.

void RigidBody_Dynamic_ApplyImpulse_Angular(int RigidBody,float Vel_X,float Vel_Y,float Vel_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

RigidBody is a dynamic rigid body.

RigidBody's angular velocity in world space will be increased by (Vel_X,Vel_Y,Vel_Z) in the next physical simulation step.

void RigidBody_Dynamic_ApplyImpulse_Point(int RigidBody,float Vel_X,float Vel_Y,float Vel_Z,float Pos_X,float Pos_Y,float Pos_Z);

Don't forget to call RigidBody_SetActivationState with ACTIVE_TAG if you have not disabled deactivation for RigidBody.

(Pos_X,Pos_Y,Pos_Z) is represented in relative space that follow the rigid body's position but not orientation. See Spaces for information about relative space

(Vel_X,Vel_Y,Vel_Z) is not representing a position and is therefor both world space and relative space at the same time.

RigidBody is a dynamic rigid body.

The impulse (Vel_X,Vel_Y,Vel_Z) from (Pos_X,Pos_Y,Pos_Z) in RigidBody's relative space is applied to RigidBody.

void RigidBody_SetLinearDamping(int RigidBody,float LinearDamping);

Linear damping causes RigidBody's linear velocity to decrease as a simplified air resistance.

RigidBody is a valid rigid body and 0 ≤ LinearDamping ≤ 1.

RigidBody's linear damping is set to LinearDamping.

float RigidBody_GetLinearDamping(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's linear damping.

void RigidBody_SetAngularDamping(int RigidBody,float AngularDamping);

Angular damping causes RigidBody's angular velocity to decrease as a simplified air resistance.

This is useless for static and kinematic bodies but there is no reason to make a precondition for it.

RigidBody is a valid rigid body and 0 ≤ AngularDamping ≤ 1.

RigidBody's angular damping is set to LinearDamping.

float RigidBody_GetAngularDamping(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's angular damping.

void RigidBody_SetLinearVelocity(int RigidBody,float Vel_X,float Vel_Y,float Vel_Z);

RigidBody's linear velocity multiplied with the timestep is added to the world space position during simulation.

RigidBody's linear velocity is used for getting the interpolated transformation.

RigidBody is a valid rigid body.

RigidBody's linear velocity is set to (Vel_X,Vel_Y,Vel_Z).

void RigidBody_GetLinearVelocity_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's linear velocity to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_SetAngularVelocity(int RigidBody,float Vel_X,float Vel_Y,float Vel_Z);

RigidBody's angular velocity multiplied with the timestep is rotating the body's axis system during simulation.

RigidBody's angular velocity is used for getting the interpolated transformation.

RigidBody is a valid rigid body.

RigidBody's angular velocity is set to (Vel_X,Vel_Y,Vel_Z).

void RigidBody_GetAngularVelocity_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's angular velocity to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_SetFriction(int RigidBody,float Friction);

RigidBody is a valid rigid body and Friction ≥ 0.

RigidBody's friction is set to Friction.

float RigidBody_GetFriction(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's friction.

void RigidBody_SetAnisotropicFriction(int RigidBody,float Friction_X,float Friction_Y,float Friction_Z);

The friction is multiplied with the anisotropic friction when used.

RigidBody is a valid rigid body, Friction_X ≥ 0, Friction_Y ≥ 0 and Friction_Z ≥ 0.

RigidBody's anisotropic friction is set to (Friction_X,Friction_Y,Friction_Z).

void RigidBody_GetAnisotropicFriction_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's anisotropic friction to (X1,Y1,Z1) in the matrix buffer.

void RigidBody_SetContinuousCollisionDetectionMotionTreshold(int RigidBody,float Treshold);

This treshold decide how fast the rigid body can move before continuous collision detection is used.

RigidBody is a valid rigid body and Treshold > 0.

RigidBody's continuous collision detection motion treshold is set to Treshold:

float RigidBody_GetContinuousCollisionDetectionMotionTreshold(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's continuous collision detection motion treshold.

void RigidBody_Dynamic_SetLinearMass(int RigidBody,float LinearMass);

If you want to change the mass, you must also set the local inertia.

RigidBody is a dynamic rigid body and LinearMass ≥ 0.00001.

RigidBody's linear mass is set to LinearMass.

float RigidBody_GetLinearMass(int RigidBody);

RigidBody is a valid rigid body.

Returns RigidBody's linear mass. 0 is returned for static bodies instead of using a precondition.

void RigidBody_Dynamic_SetLocalInertia(int RigidBody,float LocalInertia_X,float LocalInertia_Y,float LocalInertia_Z);

The local inertia is the "angular mass" around each local axis.

RigidBody is a dynamic rigid body, LocalInertia_X ≥ 0, LocalInertia_Y ≥ 0 and LocalInertia_Z ≥ 0.

RigidBody's local inertia is set to (LocalInertia_X,LocalInertia_Y,LocalInertia_Z).

void RigidBody_GetLocalInertia_OutV3(int RigidBody);

RigidBody is a valid rigid body.

Writes RigidBody's local inertia to (X1,Y1,Z1) in the matrix buffer. (0,0,0) is written for static bodies instead of using a precondition.

int RigidBody_GetCollisionPointsFromBody_OutCB(int RigidBody);

This method does not care about the simulation. It calculate the contacts from the current locations of the bodies.

RigidBody is a valid rigid body.

Writes RigidBody's contacts with other bodies to the contact buffer.

int RigidBody_GetCollisionPointsBetweenBodies_OutCB(int RigidBodyA,int RigidBodyB);

This method does not care about the simulation. It calculate the contacts from the current locations of the bodies.

RigidBodyA and RigidBodyB are a valid rigid bodies.

Writes all contacts between RigidBodyA and RigidBodyB to the contact buffer.

void RigidBody_GetVelocityAtPoint_OutV3(int RigidBody,float WorldSpacePoint_X,float WorldSpacePoint_Y,float WorldSpacePoint_Z);

RigidBody is a valid rigid body.

Writes RigidBody's velocity from the point (WorldSpacePoint_X,WorldSpacePoint_Y,WorldSpacePoint_Z) in world space to (X1,Y1,Z1) in the matrix buffer.

int RigidBody_GetCollisionShape(int RigidBody);

RigidBody is a valid rigid body.

Returns the ID of RigidBody's collision shape. -1 is returned when the precondition is broken.

void RigidBody_SetUserData(int RigidBody, int Index, int NewValue);

The user data is an array of 8 integers that can be used for anything that you might need to store.

The most common use is to refer back to an element in a collection that store the rigid body reference number after getting the rigid body's ID from the contact buffer.

It is recomended to use named constants for Index to make the code more readable.

RigidBody is a valid rigid body and 0 ≤ Index ≤ 7.

Sets RigidBody's user data at Index to NewValue.

int RigidBody_GetUserData(int RigidBody, int Index);

RigidBody is a valid rigid body and 0 ≤ Index ≤ 7.

Returns RigidBody's user data at Index.

int RigidBody_GetFirstIntersection_Out2V3(float Start_X, float Start_Y, float Start_Z, float End_X, float End_Y, float End_Z, int RigidBody);

This method is used to get the first intersection with RigidBody in the line from (Start_X,Start_Y,Start_Z) to (End_X,End_Y,End_Z).

The first intersection is the intersection that is closest to Start.

Some collision shapes have backface culling so that the start position must be outside of the shape to intersect with the surface.

The line is bounded by it's points and therefor not infinite.

Writes the intersection's position in (X1,Y1,Z1) and normal in (X2,Y2,Z2).

Returns 1 if the line intersect with RigidBody or 0 for no intersection.