Box2D::b2Body - A rigid body.
my $body = $world->CreateBody( $body_def ); my $fixture = $body->CreateFixture(); my $position = $body->GetPosition(); my $center = $body->GetWorldCenter(); $body->SetAngularVelocity( $v ); $body->SetLinearVelocity( Box2D::b2Vec2->new( $vx, $vy ) );
A rigid body. These are created via Box2D::b2World::CreateBody.
Box2D::b2World::CreateBody
Apply an angular impulse.
Parameters:
float32 $impulse - the angular impulse in units of kg*m*m/s
float32
$impulse
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.
Box2D::b2Vec2 $force - the world force vector, usually in Newtons (N).
Box2D::b2Vec2
$force
Box2D::b2Vec2 $point - the world position of the point of application.
$point
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.
Box2D::b2Vec2 $impulse - the world impulse vector, usually in N-seconds or kg-m/s.
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
float32 $torque - about the z-axis (out of the screen), usually in N-m.
$torque
Creates a fixture from a shape and attach it to this body. This is a convenience function. Use b2FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. If the density is non-zero, this function automatically updates the mass of the body.
Box2D::b2Shape $shape - the shape to be cloned.
Box2D::b2Shape
$shape
float32 $density - the shape density (set to zero for static bodies). Warning:This function is locked during callbacks.
$density
Returns a Box2D::b2Fixture
Box2D::b2Fixture
Creates a fixture and attach it to this body. Use this function if you need to set some fixture parameters, like friction. Otherwise you can create the fixture directly from a shape. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step.
Box2D::b2FixtureDef $def - the fixture definition. Warning:This function is locked during callbacks.
Box2D::b2FixtureDef
$def
Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed.
Box2D::b2Fixture $fixture - the fixture to be removed. Warning:This function is locked during callbacks.
$fixture
Get the angle in radians.
Returns a float32 - the current world rotation angle in radians.
Get the angular damping of the body.
Returns a float32
Get the angular velocity.
Returns a float32 - the angular velocity in radians/second.
Get the rotational inertia of the body about the local origin.
Returns a float32 - the rotational inertia, usually in kg-m^2.
Get the linear damping of the body.
Get the linear velocity of the center of mass.
Returns a Box2D::b2Vec2 - the linear velocity of the center of mass.
Get the world velocity of a local point.
Box2D::b2Vec2 $localPoint
$localPoint
Returns a Box2D::b2Vec2 - the world velocity of a point.
Get the world linear velocity of a world point attached to this body.
Box2D::b2Vec2 $worldPoint
$worldPoint
Get the local position of the center of mass.
Returns a Box2D::b2Vec2
Gets a local point relative to the body's origin given a world point.
Returns a Box2D::b2Vec2 - the corresponding local point relative to the body's origin.
Gets a local vector given a world vector.
Box2D::b2Vec2 $worldVector
$worldVector
Returns a Box2D::b2Vec2 - the corresponding local vector.
Get the total mass of the body.
Returns a float32 - the mass, usually in kilograms (kg).
Get the next body in the world's body list.
Returns a Box2D::b2Body
Box2D::b2Body
Get the world body origin position.
Returns a Box2D::b2Vec2 - the world position of the body's origin.
Get the body transform for the body's origin.
Returns a Box2D::b2Transform - the world transform of the body's origin.
Box2D::b2Transform
Get the type of this body.
Returns a Box2D::b2BodyType
Box2D::b2BodyType
Get the user data pointer that was provided in the body definition.
Returns a scalar
scalar
Get the parent world of this body.
Returns a Box2D::b2World
Box2D::b2World
Get the world position of the center of mass.
Get the world coordinates of a point given the local coordinates.
Box2D::b2Vec2 $localPoint - a point on the body measured relative the the body's origin.
Returns a Box2D::b2Vec2 - the same point expressed in world coordinates.
Get the world coordinates of a vector given the local coordinates.
Box2D::b2Vec2 $localVector - a vector fixed in the body.
$localVector
Returns a Box2D::b2Vec2 - the same vector expressed in world coordinates.
Get the active state of the body.
Returns a bool
bool
Get the sleeping state of this body.
Returns a bool - true if the body is sleeping.
Is this body treated like a bullet for continuous collision detection?
Does this body have fixed rotation?
Is this body allowed to sleep.
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 the mass and you later want to reset the mass.
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.
bool $flag
$flag
Set the angular damping of the body.
float32 $angularDamping
$angularDamping
Set the angular velocity.
float32 $omega - the new angular velocity in radians/second.
$omega
Set the sleep state of the body. A sleeping body has very low CPU cost.
bool $flag - set to true to put body to sleep, false to wake it.
Should this body be treated like a bullet for continuous collision detection?
Set this body to have fixed rotation. This causes the mass to be reset.
Set the linear damping of the body.
float32 $linearDamping
$linearDamping
Set the linear velocity of the center of mass.
Box2D::b2Vec2 $v - the new linear velocity of the center of mass.
$v
You can disable sleeping on this body. If you disable sleeping, the body will be woken.
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.
Box2D::b2Vec2 $position - the world position of the body's local origin.
$position
float32 $angle - the world rotation in radians.
$angle
Set the type of this body. This may alter the mass and velocity.
Box2D::b2BodyType $type
$type
Set the user data. Use this to store your application specific data.
scalar $data
$data
Box2D
Box2D::b2BodyDef
See "BUGS" in Box2D
See "AUTHORS" in Box2D
See "COPYRIGHT & LICENSE" in Box2D
To install Box2D, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Box2D
CPAN shell
perl -MCPAN -e shell install Box2D
For more information on module installation, please visit the detailed CPAN module installation guide.