C# Class Box2D.Dynamics.Body

A rigid body. These are created via World.createBody.
Mostrar archivo Open project: gerich-home/box2dnet Class Usage Examples

Public Properties

Property Type Description
FixtureCount int
Flags TypeFlags
Force Box2D.Common.Vec2
I float
InvI float
InvMass float
IslandIndex int
Prev Body
SleepTime float
Sweep Box2D.Common.Sweep
Torque float
Xf Box2D.Common.Transform

Public Methods

Method Description
ApplyAngularImpulse ( float impulse ) : void

Apply an angular impulse.

ApplyForce ( Vec2 force, Vec2 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.

ApplyForceToCenter ( Vec2 force ) : void

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

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

Body ( BodyDef bd, World world ) : System
CreateFixture ( FixtureDef def ) : Fixture

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.

CreateFixture ( Shape shape, float density ) : Fixture

Creates a fixture from a shape and attach it to this body. This is a convenience function. Use FixtureDef 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.

DestroyFixture ( Fixture fixture ) : void

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.

GetLinearVelocityFromLocalPoint ( Vec2 localPoint ) : Vec2

Get the world velocity of a local point.

GetLinearVelocityFromLocalPointToOut ( Vec2 localPoint, Vec2 result ) : void
GetLinearVelocityFromWorldPoint ( Vec2 worldPoint ) : Vec2

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

GetLinearVelocityFromWorldPointToOut ( Vec2 worldPoint, Vec2 result ) : void
GetLocalPoint ( Vec2 worldPoint ) : Vec2

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

GetLocalPointToOut ( Vec2 worldPoint, Vec2 result ) : void
GetLocalVector ( Vec2 worldVector ) : Vec2

Gets a local vector given a world vector.

GetLocalVectorToOut ( Vec2 worldVector, Vec2 result ) : void
GetLocalVectorToOutUnsafe ( Vec2 worldVector, Vec2 result ) : void
GetMassData ( MassData data ) : void

Get the mass data of the body. The rotational inertia is relative to the center of mass.

GetTransform ( ) : Transform

Get the body transform for the body's origin.

GetWorldPoint ( Vec2 localPoint ) : Vec2

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

GetWorldPointToOut ( Vec2 localPoint, Vec2 result ) : void
GetWorldVector ( Vec2 localVector ) : Vec2

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

GetWorldVectorToOut ( Vec2 localVector, Vec2 result ) : void
GetWorldVectorToOutUnsafe ( Vec2 localVector, Vec2 result ) : void
ResetMassData ( ) : void

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.

SetMassData ( MassData massData ) : void

Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic.

SetTransform ( Vec2 position, float angle ) : void

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.

ShouldCollide ( Body other ) : bool

This is used to prevent connected bodies from colliding. It may lie, depending on the collideConnected flag.

SynchronizeTransform ( ) : void

Private Methods

Method Description
Advance ( float t ) : void
SynchronizeFixtures ( ) : void

Method Details

ApplyAngularImpulse() public method

Apply an angular impulse.
public ApplyAngularImpulse ( float impulse ) : void
impulse float the angular impulse in units of kg*m*m/s
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 ( Vec2 force, Vec2 point ) : void
force Box2D.Common.Vec2 the world force vector, usually in Newtons (N).
point Box2D.Common.Vec2 the world position of the point of application.
return void

ApplyForceToCenter() public method

Apply a force to the center of mass. This wakes up the body.
public ApplyForceToCenter ( Vec2 force ) : void
force Box2D.Common.Vec2 the world force vector, usually in Newtons (N).
return void

ApplyLinearImpulse() 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 ApplyLinearImpulse ( Vec2 impulse, Vec2 point ) : void
impulse Box2D.Common.Vec2 the world impulse vector, usually in N-seconds or kg-m/s.
point Box2D.Common.Vec2 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 about the z-axis (out of the screen), usually in N-m.
return void

Body() public method

public Body ( BodyDef bd, World world ) : System
bd BodyDef
world World
return System

CreateFixture() public method

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.
public CreateFixture ( FixtureDef def ) : Fixture
def FixtureDef the fixture definition.
return Fixture

CreateFixture() public method

Creates a fixture from a shape and attach it to this body. This is a convenience function. Use FixtureDef 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.
public CreateFixture ( Shape shape, float density ) : Fixture
shape Box2D.Collision.Shapes.Shape the shape to be cloned.
density float the shape density (set to zero for static bodies).
return Fixture

DestroyFixture() public method

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.
public DestroyFixture ( Fixture fixture ) : void
fixture Fixture the fixture to be removed.
return void

GetLinearVelocityFromLocalPoint() public method

Get the world velocity of a local point.
public GetLinearVelocityFromLocalPoint ( Vec2 localPoint ) : Vec2
localPoint Box2D.Common.Vec2 point in local coordinates.
return Box2D.Common.Vec2

GetLinearVelocityFromLocalPointToOut() public method

public GetLinearVelocityFromLocalPointToOut ( Vec2 localPoint, Vec2 result ) : void
localPoint Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetLinearVelocityFromWorldPoint() public method

Get the world linear velocity of a world point attached to this body.
public GetLinearVelocityFromWorldPoint ( Vec2 worldPoint ) : Vec2
worldPoint Box2D.Common.Vec2 point in world coordinates.
return Box2D.Common.Vec2

GetLinearVelocityFromWorldPointToOut() public method

public GetLinearVelocityFromWorldPointToOut ( Vec2 worldPoint, Vec2 result ) : void
worldPoint Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetLocalPoint() public method

Gets a local point relative to the body's origin given a world point.
public GetLocalPoint ( Vec2 worldPoint ) : Vec2
worldPoint Box2D.Common.Vec2 point in world coordinates.
return Box2D.Common.Vec2

GetLocalPointToOut() public method

public GetLocalPointToOut ( Vec2 worldPoint, Vec2 result ) : void
worldPoint Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetLocalVector() public method

Gets a local vector given a world vector.
public GetLocalVector ( Vec2 worldVector ) : Vec2
worldVector Box2D.Common.Vec2 vector in world coordinates.
return Box2D.Common.Vec2

GetLocalVectorToOut() public method

public GetLocalVectorToOut ( Vec2 worldVector, Vec2 result ) : void
worldVector Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetLocalVectorToOutUnsafe() public method

public GetLocalVectorToOutUnsafe ( Vec2 worldVector, Vec2 result ) : void
worldVector Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetMassData() public method

Get the mass data of the body. The rotational inertia is relative to the center of mass.
public GetMassData ( MassData data ) : void
data Box2D.Collision.Shapes.MassData
return void

GetTransform() public method

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

GetWorldPoint() public method

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

GetWorldPointToOut() public method

public GetWorldPointToOut ( Vec2 localPoint, Vec2 result ) : void
localPoint Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetWorldVector() public method

Get the world coordinates of a vector given the local coordinates.
public GetWorldVector ( Vec2 localVector ) : Vec2
localVector Box2D.Common.Vec2 a vector fixed in the body.
return Box2D.Common.Vec2

GetWorldVectorToOut() public method

public GetWorldVectorToOut ( Vec2 localVector, Vec2 result ) : void
localVector Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

GetWorldVectorToOutUnsafe() public method

public GetWorldVectorToOutUnsafe ( Vec2 localVector, Vec2 result ) : void
localVector Box2D.Common.Vec2
result Box2D.Common.Vec2
return void

ResetMassData() public method

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.
public ResetMassData ( ) : void
return void

SetMassData() public method

Set the mass properties to override the mass properties of the fixtures. Note that this changes the center of mass position. Note that creating or destroying fixtures can also alter the mass. This function has no effect if the body isn't dynamic.
public SetMassData ( MassData massData ) : void
massData Box2D.Collision.Shapes.MassData the mass properties.
return void

SetTransform() public method

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.
public SetTransform ( Vec2 position, float angle ) : void
position Box2D.Common.Vec2 the world position of the body's local origin.
angle float the world rotation in radians.
return void

ShouldCollide() public method

This is used to prevent connected bodies from colliding. It may lie, depending on the collideConnected flag.
public ShouldCollide ( Body other ) : bool
other Body
return bool

SynchronizeTransform() public method

public SynchronizeTransform ( ) : void
return void

Property Details

FixtureCount public_oe property

public int FixtureCount
return int

Flags public_oe property

public TypeFlags Flags
return TypeFlags

Force public_oe property

public Vec2,Box2D.Common Force
return Box2D.Common.Vec2

I public_oe property

public float I
return float

InvI public_oe property

public float InvI
return float

InvMass public_oe property

public float InvMass
return float

IslandIndex public_oe property

public int IslandIndex
return int

Prev public_oe property

public Body,Box2D.Dynamics Prev
return Body

SleepTime public_oe property

public float SleepTime
return float

Sweep public_oe property

The swept motion for CCD
public Sweep,Box2D.Common Sweep
return Box2D.Common.Sweep

Torque public_oe property

public float Torque
return float

Xf public_oe property

The body origin transform.
public Transform,Box2D.Common Xf
return Box2D.Common.Transform