b2d.body

Functions for interacting with Box2D bodies.

b2d.body.B2_STATIC_BODY

Static (immovable) body

Static (immovable) body


b2d.body.B2_KINEMATIC_BODY

Kinematic body

Kinematic body


b2d.body.B2_DYNAMIC_BODY

Dynamic body

Dynamic body


b2d.body.set_transform(body, position, angle)

Set the position of the body's origin and rotation

Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.

PARAMETERS

body - body

position - the world position of the body's local origin.

angle - the world position of the body's local origin.


b2d.body.get_position(body)

Get the world body origin position.

Get the world body origin position.

PARAMETERS

body - body

RETURN

position - the world position of the body's origin.


b2d.body.get_world_center(body)

Get the angle in radians.

Get the angle in radians.

PARAMETERS

body - body

RETURN

angle - the current world rotation angle in radians.


b2d.body.get_world_center(body)

Get the world position of the center of mass.

Get the world position of the center of mass.

PARAMETERS

body - body

RETURN

center - Get the world position of the center of mass.


b2d.body.get_local_center(body)

Get the local position of the center of mass.

Get the local position of the center of mass.

PARAMETERS

body - body

RETURN

center - Get the local position of the center of mass.


b2d.body.set_linear_velocity(body, velocity)

Set the linear velocity of the center of mass.

Set the linear velocity of the center of mass.

PARAMETERS

body - body

velocity - the new linear velocity of the center of mass.


b2d.body.get_linear_velocity(body)

Get the linear velocity of the center of mass.

Get the linear velocity of the center of mass.

PARAMETERS

body - body

RETURN

velocity - the linear velocity of the center of mass.


b2d.body.get_angular_velocity(body, omega)

Set the angular velocity.

Set the angular velocity.

PARAMETERS

body - body

omega - the new angular velocity in radians/second.


b2d.body.get_angular_velocity(body)

Get the angular velocity.

Get the angular velocity.

PARAMETERS

body - body

RETURN

velocity - the angular velocity in radians/second.


b2d.body.apply_force(body, force, point)

Apply a force at a world point. If the force is no...

Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.

PARAMETERS

body - body

force - the world force vector, usually in Newtons (N).

point - the world position of the point of application.


b2d.body.apply_force_to_center(body, force)

Apply a force to the center of mass. This wakes up the body.

Apply a force to the center of mass. This wakes up the body.

PARAMETERS

body - body

force - the world force vector, usually in Newtons (N).


b2d.body.apply_torque(body, torque)

Apply a torque. This affects the angular velocity ...

Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.

PARAMETERS

body - body

torque - torque about the z-axis (out of the screen), usually in N-m.


b2d.body.apply_linear_impulse(body, impulse, point)

Apply an impulse at a point. This immediately modi...

Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.

PARAMETERS

body - body

impulse - the world impulse vector, usually in N-seconds or kg-m/s.

point - the world position of the point of application.


b2d.body.apply_angular_impulse(body, impulse)

Apply an angular impulse.

Apply an angular impulse.

PARAMETERS

body - body

impulse - impulse the angular impulse in units of kgmm/s


b2d.body.get_mass(body)

Get the total mass of the body.

Get the total mass of the body.

PARAMETERS

body - body

RETURN

mass - the mass, usually in kilograms (kg).


b2d.body.get_inertia(body)

Get the rotational inertia of the body about the local origin.

Get the rotational inertia of the body about the local origin.

PARAMETERS

body - body

RETURN

inertia - the rotational inertia, usually in kg-m^2.


b2d.body.reset_mass_data(body)

This resets the mass properties to the sum of the ...

This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override

PARAMETERS

body - body


b2d.body.get_world_point(body, local_vector)

Get the world coordinates of a point given the local coordinates.

Get the world coordinates of a point given the local coordinates.

PARAMETERS

body - body

local_vector - localPoint a point on the body measured relative the the body's origin.

RETURN

vector - the same point expressed in world coordinates.


b2d.body.get_world_vector(body, local_vector)

Get the world coordinates of a vector given the local coordinates.

Get the world coordinates of a vector given the local coordinates.

PARAMETERS

body - body

local_vector - a vector fixed in the body.

RETURN

vector - the same vector expressed in world coordinates.


b2d.body.get_local_point(body, world_point)

Gets a local point relative to the body's origin given a world point.

Gets a local point relative to the body's origin given a world point.

PARAMETERS

body - body

world_point - a point in world coordinates.

RETURN

vector - the corresponding local point relative to the body's origin.


b2d.body.get_local_vector(body, world_vector)

Gets a local vector given a world vector.

Gets a local vector given a world vector.

PARAMETERS

body - body

world_vector - a vector in world coordinates.

RETURN

vector - the corresponding local vector.


b2d.body.get_linear_velocity_from_world_point(body, world_point)

Get the world linear velocity of a world point attached to this body.

Get the world linear velocity of a world point attached to this body.

PARAMETERS

body - body

world_point - a point in world coordinates.

RETURN

velocity - the world velocity of a point.


b2d.body.get_linear_velocity_from_world_point(body, world_point)

Get the world velocity of a local point.

Get the world velocity of a local point.

PARAMETERS

body - body

world_point - a point in local coordinates.

RETURN

velocity - the world velocity of a point.


b2d.body.set_linear_damping(body, damping)

Set the linear damping of the body.

Set the linear damping of the body.

PARAMETERS

body - body

damping - the damping


b2d.body.get_linear_damping(body)

Get the linear damping of the body.

Get the linear damping of the body.

PARAMETERS

body - body

RETURN

damping - the damping


b2d.body.set_angular_damping(body, damping)

Set the angular damping of the body.

Set the angular damping of the body.

PARAMETERS

body - body

damping - the damping


b2d.body.get_angular_damping(body)

Get the angular damping of the body.

Get the angular damping of the body.

PARAMETERS

body - body

RETURN

damping - the damping


b2d.body.set_gravity_scale(body, scale)

Set the gravity scale of the body.

Set the gravity scale of the body.

PARAMETERS

body - body

scale - the scale


b2d.body.get_gravity_scale(body)

Get the gravity scale of the body.

Get the gravity scale of the body.

PARAMETERS

body - body

RETURN

scale - the scale


b2d.body.set_type(body, type)

Set the type of this body. This may alter the mass and velocity.

Set the type of this body. This may alter the mass and velocity.

PARAMETERS

body - body

type - the body type


b2d.body.get_type(body)

Get the type of this body.

Get the type of this body.

PARAMETERS

body - body

RETURN

type - the body type


b2d.body.set_bullet(body, enable)

Should this body be treated like a bullet for continuous collision detection?

Should this body be treated like a bullet for continuous collision detection?

PARAMETERS

body - body

enable - if true, the body will be in bullet mode


b2d.body.is_bullet(body)

Is this body in bullet mode

Is this body in bullet mode

PARAMETERS

body - body

RETURN

enabled - true if the body is in bullet mode


b2d.body.set_sleeping_allowed(body, enable)

You can disable sleeping on this body. If you disable sleeping, the body will be woken.

You can disable sleeping on this body. If you disable sleeping, the body will be woken.

PARAMETERS

body - body

enable - if false, the body will never sleep, and consume more CPU


b2d.body.is_sleeping_allowed(body)

Is this body allowed to sleep

Is this body allowed to sleep

PARAMETERS

body - body

RETURN

enabled - true if the body is allowed to sleep


b2d.body.set_awake(body, enable)

Set the sleep state of the body. A sleeping body has very low CPU cost.

Set the sleep state of the body. A sleeping body has very low CPU cost.

PARAMETERS

body - body

enable - flag set to false to put body to sleep, true to wake it.


b2d.body.is_awake(body)

Get the sleeping state of this body.

Get the sleeping state of this body.

PARAMETERS

body - body

RETURN

enabled - true if the body is awake, false if it's sleeping.


b2d.body.set_active(body, enable)

Set the active state of the body

Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list.

PARAMETERS

body - body

enable - true if the body should be active


b2d.body.is_active(body)

Get the active state of the body.

Get the active state of the body.

PARAMETERS

body - body

RETURN

enabled - is the body active


b2d.body.set_fixed_rotation(body, enable)

Set this body to have fixed rotation. This causes the mass to be reset.

Set this body to have fixed rotation. This causes the mass to be reset.

PARAMETERS

body - body

enable - true if the rotation should be fixed


b2d.body.is_fixed_rotation(body)

Does this body have fixed rotation?

Does this body have fixed rotation?

PARAMETERS

body - body

RETURN

enabled - is the rotation fixed


b2d.body.get_next(body)

Get the next body in the world's body list.

Get the next body in the world's body list.

PARAMETERS

body - body

RETURN

body - the next body


b2d.body.get_world(body)

Get the parent world of this body.

Get the parent world of this body.

PARAMETERS

body - body

RETURN

world -


b2d.body.dump(body)

Print the body representation to the log output

Print the body representation to the log output

PARAMETERS

body - body