C# Class Box2DX.Dynamics.Body

Inheritance: IDisposable
Show file Open project: KrugerHeavyIndustries/box2d-unity Class Usage Examples

Public Properties

Property Type Description
bodyID int

Public Methods

Method Description
AllowSleeping ( bool flag ) : void

You can disable sleeping on this body.

ApplyForce ( System.Vector2 force, System.Vector2 point ) : void

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.

ApplyImpulse ( System.Vector2 impulse, System.Vector2 point ) : void

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.

ApplyTorque ( float torque ) : void

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

CreateFixture ( FixtureDef def ) : Fixture

Creates a fixture and attach it to this body. @warning This function is locked during callbacks.

DestroyFixture ( Fixture fixture ) : void

Destroy a fixture. This removes the fixture from the broad-phase and therefore destroys any contacts associated with this fixture. All fixtures attached to a body are implicitly destroyed when the body is destroyed. @warning This function is locked during callbacks.

Dispose ( ) : void
GetAngle ( ) : float

Get the angle in radians.

GetAngularDamping ( ) : float
GetAngularVelocity ( ) : float

Get the angular velocity.

GetControllerList ( ) : ControllerEdge
GetFixtureList ( ) : Fixture

Get the list of all fixtures attached to this body.

GetInertia ( ) : float

Get the central rotational inertia of the body.

GetJointList ( ) : JointEdge

Get the list of all joints attached to this body.

GetLinearDamping ( ) : float
GetLinearVelocity ( ) : System.Vector2

Get the linear velocity of the center of mass.

GetLinearVelocityFromLocalPoint ( System.Vector2 localPoint ) : System.Vector2

Get the world velocity of a local point.

GetLinearVelocityFromWorldPoint ( System.Vector2 worldPoint ) : System.Vector2

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

GetLocalCenter ( ) : System.Vector2

Get the local position of the center of mass.

GetLocalPoint ( System.Vector2 worldPoint ) : System.Vector2

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

GetLocalVector ( System.Vector2 worldVector ) : System.Vector2

Gets a local vector given a world vector.

GetMass ( ) : float

Get the total mass of the body.

GetMassData ( ) : MassData

Get the mass data of the body.

GetNext ( ) : Body

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

GetPosition ( ) : System.Vector2

Get the world body origin position.

GetTransform ( ) : Box2DX.Common.Transform

Get the body Transform for the body's origin.

GetUserData ( ) : object

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

GetWorld ( ) : World

Get the parent world of this body.

GetWorldCenter ( ) : System.Vector2

Get the world position of the center of mass.

GetWorldPoint ( System.Vector2 localPoint ) : System.Vector2

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

GetWorldVector ( System.Vector2 localVector ) : System.Vector2

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

IsAllowSleeping ( ) : bool
IsBullet ( ) : bool

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

IsDynamic ( ) : bool

Is this body dynamic (movable)?

IsFixedRotation ( ) : bool
IsFrozen ( ) : bool

Is this body frozen?

IsSleeping ( ) : bool

Is this body sleeping (not simulating).

IsStatic ( ) : bool

Is this body static (immovable)?

PutToSleep ( ) : void

Put this body to sleep so it will stop simulating. This also sets the velocity to zero.

SetAngle ( float angle ) : void

Set the world body angle.

SetAngularDamping ( float angularDamping ) : void
SetAngularVelocity ( float w ) : void

Set the angular velocity.

SetBullet ( bool flag ) : void

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

SetFixedRotation ( bool fixedr ) : void
SetLinearDamping ( float linearDamping ) : void
SetLinearVelocity ( System.Vector2 v ) : void

Set the linear velocity of the center of mass.

SetMass ( MassData massData ) : void

Set the mass properties. Note that this changes the center of mass position. If you are not sure how to compute mass properties, use SetMassFromShapes. The inertia tensor is assumed to be relative to the center of mass.

SetMassFromShapes ( ) : void

Compute the mass properties from the attached shapes. You typically call this after adding all the shapes. If you add or remove shapes later, you may want to call this again. Note that this changes the center of mass position.

SetPosition ( System.Vector2 position ) : void

Set the world body origin position.

SetStatic ( ) : void
SetTransform ( Box2DX.Common.Transform xf ) : bool

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies. Note this is less efficient than the other overload - you should use that if the angle is available.

SetTransform ( System.Vector2 position, Mat22 rotation ) : bool

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies.

SetTransform ( System.Vector2 position, Quaternion rotation ) : bool
SetTransform ( System.Vector2 position, float angle ) : bool
SetUserData ( object data ) : void

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

WakeUp ( ) : void

Wake up this body so it will begin simulating.

Private Methods

Method Description
Advance ( float t ) : void
Body ( BodyDef bd, World world ) : System
IsConnected ( Body other ) : bool
SynchronizeFixtures ( ) : bool
SynchronizeTransform ( ) : void

Method Details

AllowSleeping() public method

You can disable sleeping on this body.
public AllowSleeping ( bool flag ) : void
flag bool
return void

ApplyForce() public method

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.
public ApplyForce ( System.Vector2 force, System.Vector2 point ) : void
force System.Vector2 The world force vector, usually in Newtons (N).
point System.Vector2 The world position of the point of application.
return void

ApplyImpulse() public method

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.
public ApplyImpulse ( System.Vector2 impulse, System.Vector2 point ) : void
impulse System.Vector2 The world impulse vector, usually in N-seconds or kg-m/s.
point System.Vector2 The world position of the point of application.
return void

ApplyTorque() public method

Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
public ApplyTorque ( float torque ) : void
torque float Torque about the z-axis (out of the screen), usually in N-m.
return void

CreateFixture() public method

Creates a fixture and attach it to this body. @warning This function is locked during callbacks.
public CreateFixture ( FixtureDef def ) : Fixture
def FixtureDef The fixture definition.
return Fixture

DestroyFixture() public method

Destroy a fixture. This removes the fixture from the broad-phase and therefore destroys any contacts associated with this fixture. All fixtures attached to a body are implicitly destroyed when the body is destroyed. @warning This function is locked during callbacks.
public DestroyFixture ( Fixture fixture ) : void
fixture Fixture The fixture to be removed.
return void

Dispose() public method

public Dispose ( ) : void
return void

GetAngle() public method

Get the angle in radians.
public GetAngle ( ) : float
return float

GetAngularDamping() public method

public GetAngularDamping ( ) : float
return float

GetAngularVelocity() public method

Get the angular velocity.
public GetAngularVelocity ( ) : float
return float

GetControllerList() public method

public GetControllerList ( ) : ControllerEdge
return Box2DX.Dynamics.Controllers.ControllerEdge

GetFixtureList() public method

Get the list of all fixtures attached to this body.
public GetFixtureList ( ) : Fixture
return Fixture

GetInertia() public method

Get the central rotational inertia of the body.
public GetInertia ( ) : float
return float

GetJointList() public method

Get the list of all joints attached to this body.
public GetJointList ( ) : JointEdge
return JointEdge

GetLinearDamping() public method

public GetLinearDamping ( ) : float
return float

GetLinearVelocity() public method

Get the linear velocity of the center of mass.
public GetLinearVelocity ( ) : System.Vector2
return System.Vector2

GetLinearVelocityFromLocalPoint() public method

Get the world velocity of a local point.
public GetLinearVelocityFromLocalPoint ( System.Vector2 localPoint ) : System.Vector2
localPoint System.Vector2 A point in local coordinates.
return System.Vector2

GetLinearVelocityFromWorldPoint() public method

Get the world linear velocity of a world point attached to this body.
public GetLinearVelocityFromWorldPoint ( System.Vector2 worldPoint ) : System.Vector2
worldPoint System.Vector2 A point in world coordinates.
return System.Vector2

GetLocalCenter() public method

Get the local position of the center of mass.
public GetLocalCenter ( ) : System.Vector2
return System.Vector2

GetLocalPoint() public method

Gets a local point relative to the body's origin given a world point.
public GetLocalPoint ( System.Vector2 worldPoint ) : System.Vector2
worldPoint System.Vector2 A point in world coordinates.
return System.Vector2

GetLocalVector() public method

Gets a local vector given a world vector.
public GetLocalVector ( System.Vector2 worldVector ) : System.Vector2
worldVector System.Vector2 A vector in world coordinates.
return System.Vector2

GetMass() public method

Get the total mass of the body.
public GetMass ( ) : float
return float

GetMassData() public method

Get the mass data of the body.
public GetMassData ( ) : MassData
return Box2DX.Collision.MassData

GetNext() public method

Get the next body in the world's body list.
public GetNext ( ) : Body
return Body

GetPosition() public method

Get the world body origin position.
public GetPosition ( ) : System.Vector2
return System.Vector2

GetTransform() public method

Get the body Transform for the body's origin.
public GetTransform ( ) : Box2DX.Common.Transform
return Box2DX.Common.Transform

GetUserData() public method

Get the user data pointer that was provided in the body definition.
public GetUserData ( ) : object
return object

GetWorld() public method

Get the parent world of this body.
public GetWorld ( ) : World
return World

GetWorldCenter() public method

Get the world position of the center of mass.
public GetWorldCenter ( ) : System.Vector2
return System.Vector2

GetWorldPoint() public method

Get the world coordinates of a point given the local coordinates.
public GetWorldPoint ( System.Vector2 localPoint ) : System.Vector2
localPoint System.Vector2 A point on the body measured relative the the body's origin.
return System.Vector2

GetWorldVector() public method

Get the world coordinates of a vector given the local coordinates.
public GetWorldVector ( System.Vector2 localVector ) : System.Vector2
localVector System.Vector2 A vector fixed in the body.
return System.Vector2

IsAllowSleeping() public method

public IsAllowSleeping ( ) : bool
return bool

IsBullet() public method

Is this body treated like a bullet for continuous collision detection?
public IsBullet ( ) : bool
return bool

IsDynamic() public method

Is this body dynamic (movable)?
public IsDynamic ( ) : bool
return bool

IsFixedRotation() public method

public IsFixedRotation ( ) : bool
return bool

IsFrozen() public method

Is this body frozen?
public IsFrozen ( ) : bool
return bool

IsSleeping() public method

Is this body sleeping (not simulating).
public IsSleeping ( ) : bool
return bool

IsStatic() public method

Is this body static (immovable)?
public IsStatic ( ) : bool
return bool

PutToSleep() public method

Put this body to sleep so it will stop simulating. This also sets the velocity to zero.
public PutToSleep ( ) : void
return void

SetAngle() public method

Set the world body angle.
public SetAngle ( float angle ) : void
angle float The new angle of the body in radians
return void

SetAngularDamping() public method

public SetAngularDamping ( float angularDamping ) : void
angularDamping float
return void

SetAngularVelocity() public method

Set the angular velocity.
public SetAngularVelocity ( float w ) : void
w float
return void

SetBullet() public method

Should this body be treated like a bullet for continuous collision detection?
public SetBullet ( bool flag ) : void
flag bool
return void

SetFixedRotation() public method

public SetFixedRotation ( bool fixedr ) : void
fixedr bool
return void

SetLinearDamping() public method

public SetLinearDamping ( float linearDamping ) : void
linearDamping float
return void

SetLinearVelocity() public method

Set the linear velocity of the center of mass.
public SetLinearVelocity ( System.Vector2 v ) : void
v System.Vector2 The new linear velocity of the center of mass.
return void

SetMass() public method

Set the mass properties. Note that this changes the center of mass position. If you are not sure how to compute mass properties, use SetMassFromShapes. The inertia tensor is assumed to be relative to the center of mass.
public SetMass ( MassData massData ) : void
massData Box2DX.Collision.MassData The mass properties.
return void

SetMassFromShapes() public method

Compute the mass properties from the attached shapes. You typically call this after adding all the shapes. If you add or remove shapes later, you may want to call this again. Note that this changes the center of mass position.
public SetMassFromShapes ( ) : void
return void

SetPosition() public method

Set the world body origin position.
public SetPosition ( System.Vector2 position ) : void
position System.Vector2 The new position of the body.
return void

SetStatic() public method

public SetStatic ( ) : void
return void

SetTransform() public method

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies. Note this is less efficient than the other overload - you should use that if the angle is available.
public SetTransform ( Box2DX.Common.Transform xf ) : bool
xf Box2DX.Common.Transform The Transform of position and angle to set the body to.
return bool

SetTransform() public method

Set the position of the body's origin and rotation (radians). This breaks any contacts and wakes the other bodies.
public SetTransform ( System.Vector2 position, Mat22 rotation ) : bool
position System.Vector2 The new world position of the body's origin (not necessarily /// the center of mass).
rotation Box2DX.Common.Mat22
return bool

SetTransform() public method

public SetTransform ( System.Vector2 position, Quaternion rotation ) : bool
position System.Vector2
rotation Quaternion
return bool

SetTransform() public method

public SetTransform ( System.Vector2 position, float angle ) : bool
position System.Vector2
angle float
return bool

SetUserData() public method

Set the user data. Use this to store your application specific data.
public SetUserData ( object data ) : void
data object
return void

WakeUp() public method

Wake up this body so it will begin simulating.
public WakeUp ( ) : void
return void

Property Details

bodyID public property

public int bodyID
return int