Jeffrey T. Palmer > Box2D-0.07 > Box2D::b2Body

Download:
Box2D-0.07.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

Box2D::b2Body - A rigid body.

SYNOPSIS ^

  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 ) );

DESCRIPTION ^

A rigid body. These are created via Box2D::b2World::CreateBody.

METHODS ^

ApplyAngularImpulse( $impulse )

Apply an angular impulse.

Parameters:

ApplyForce( $force, $point )

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:

ApplyLinearImpulse( $impulse, $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.

Parameters:

ApplyTorque( $torque )

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

Parameters:

CreateFixture( $shape, $density )

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.

Parameters:

Returns a Box2D::b2Fixture

CreateFixtureDef( $def )

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.

Parameters:

Returns a Box2D::b2Fixture

DestroyFixture( $fixture )

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.

Parameters:

GetAngle()

Get the angle in radians.

Returns a float32 - the current world rotation angle in radians.

GetAngularDamping()

Get the angular damping of the body.

Returns a float32

GetAngularVelocity()

Get the angular velocity.

Returns a float32 - the angular velocity in radians/second.

GetInertia()

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

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

GetLinearDamping()

Get the linear damping of the body.

Returns a float32

GetLinearVelocity()

Get the linear velocity of the center of mass.

Returns a Box2D::b2Vec2 - the linear velocity of the center of mass.

GetLinearVelocityFromLocalPoint( $localPoint )

Get the world velocity of a local point.

Parameters:

Returns a Box2D::b2Vec2 - the world velocity of a point.

GetLinearVelocityFromWorldPoint( $worldPoint )

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

Parameters:

Returns a Box2D::b2Vec2 - the world velocity of a point.

GetLocalCenter()

Get the local position of the center of mass.

Returns a Box2D::b2Vec2

GetLocalPoint( $worldPoint )

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

Parameters:

Returns a Box2D::b2Vec2 - the corresponding local point relative to the body's origin.

GetLocalVector( $worldVector )

Gets a local vector given a world vector.

Parameters:

Returns a Box2D::b2Vec2 - the corresponding local vector.

GetMass()

Get the total mass of the body.

Returns a float32 - the mass, usually in kilograms (kg).

GetNext()

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

Returns a Box2D::b2Body

GetPosition()

Get the world body origin position.

Returns a Box2D::b2Vec2 - the world position of the body's origin.

GetTransform()

Get the body transform for the body's origin.

Returns a Box2D::b2Transform - the world transform of the body's origin.

GetType()

Get the type of this body.

Returns a Box2D::b2BodyType

GetUserData()

Get the user data pointer that was provided in the body definition.

Returns a scalar

GetWorld()

Get the parent world of this body.

Returns a Box2D::b2World

GetWorldCenter()

Get the world position of the center of mass.

Returns a Box2D::b2Vec2

GetWorldPoint( $localPoint )

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

Parameters:

Returns a Box2D::b2Vec2 - the same point expressed in world coordinates.

GetWorldVector( $localVector )

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

Parameters:

Returns a Box2D::b2Vec2 - the same vector expressed in world coordinates.

IsActive()

Get the active state of the body.

Returns a bool

IsAwake()

Get the sleeping state of this body.

Returns a bool - true if the body is sleeping.

IsBullet()

Is this body treated like a bullet for continuous collision detection?

Returns a bool

IsFixedRotation()

Does this body have fixed rotation?

Returns a bool

IsSleepingAllowed()

Is this body allowed to sleep.

Returns a bool

ResetMassData()

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.

SetActive( $flag )

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:

SetAngularDamping( $angularDamping )

Set the angular damping of the body.

Parameters:

SetAngularVelocity( $omega )

Set the angular velocity.

Parameters:

SetAwake( $flag )

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

Parameters:

SetBullet( $flag )

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

Parameters:

SetFixedRotation( $flag )

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

Parameters:

SetLinearDamping( $linearDamping )

Set the linear damping of the body.

Parameters:

SetLinearVelocity( $v )

Set the linear velocity of the center of mass.

Parameters:

SetSleepingAllowed( $flag )

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

Parameters:

SetTransform( $position, $angle )

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:

SetType( $type )

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

Parameters:

SetUserData( $data )

Set the user data. Use this to store your application specific data.

Parameters:

SEE ALSO ^

BUGS ^

See "BUGS" in Box2D

AUTHORS ^

See "AUTHORS" in Box2D

COPYRIGHT & LICENSE ^

See "COPYRIGHT & LICENSE" in Box2D

syntax highlighting: