B2Body

From Box2D Wiki

b2Body
Box2D/Dynamics
Visibility Public
Definition Object b2BodyDef
Manual reference [1]
API reference [2]
Source reference H.png Cpp.png

b2Body is the object used to represent one rigid body. The entire world is built out of bodies.

b2Body stores all the dynamic properties; its position, rotation, and motion. It also has a number of flags that determine its current behaviour in the world, see sensors, bullets, sleeping and frozen.

However the material properties and the description of the shape or form of the body is specified by the list of shapes it contains. This can be manipulated by GetShapeList, CreateShape and DestroyShape.

Properties

Type Definition Getter Setter
Dynamic
b2MassData massData

fixedRotation

GetMass

GetInertia

GetWorldCenter

SetMass
b2Vec2

float32

position

angle

GetPosition

GetAngle

GetXForm

SetXForm
b2Vec2GetLinearVelocitySetLinearVelocity
b2Vec2GetAngularVelocitySetAngularVelocity
float32linearDamping
float32angularDamping
Lists
b2Shape*GetShapeListCreateShape

DestroyShape

b2JointEdge*GetJointList
b2ContactEdge*GetContactList
b2Body*GetNext
Flags
boolallowSleepAllowSleeping
boolisSleepingIsSleepingWakeUp
boolisBulletIsBulletSetBullet
bool See here IsStatic

IsDynamic

boolIsFrozen
Misc
void*userDataGetUserData

Methods

SetMassFromShapes

The b2Body.SetMassFromShapes method calculates the mass and center of mass of a body by using the size and density of each of the shapes attached to the body. This is the default and recommended way of creating a dynamic body; if you want more precise control over a body's mass, you will have to create a MassData object.

  • GetWorldCenter/GetLocalCenter
  • ApplyForce
  • ApplyTorque
  • ApplyImpulse
  • GetWorldPoint/GetLocalPoint
  • GetWorldVector/GetLocalVector


TOOLBOX
LANGUAGES