Package pybox2d :: Module Box2D :: Class b2Body |
[hide private]
[frames] | no frames]

# type b2Body

source code

A rigid body.

Instance Methods | [hide private]
__init__(self, *args, **kwargs) | source code
__repr__(self) | source code
__getstate__(self) Everything is essentially generic_getstate, except for edge shape handling. | source code
__setstate__(self, data) The factory output cannot be created just yet, so store the necessary information to create it later. | source code
_pickle_finalize(self, world=None, body=None) Finalize one of the outputs that we previously set as a dictionary. | source code
__eq__(a, b) | source code
__ne__(self, other) | source code
setAngle(self, angle) Set the angle without altering the position | source code
setPosition(self, position) Set the position without altering the angle | source code
getMassData(self) Get a b2MassData object that represents this b2Body | source code
GetShapeList(self, asType=True) Get a list of the shapes in this body | source code
__iter__(self) Iterates over the shapes in the body | source code
SetMass(...) b2Body_SetMass(b2Body self, b2MassData massData) | source code
SetMassFromShapes(...) b2Body_SetMassFromShapes(b2Body self) | source code
SetXForm(...) b2Body_SetXForm(b2Body self, b2Vec2 position, float32 angle) -> bool | source code
GetXForm(...) b2Body_GetXForm(b2Body self) -> b2XForm | source code
GetPosition(...) b2Body_GetPosition(b2Body self) -> b2Vec2 | source code
GetAngle(...) b2Body_GetAngle(b2Body self) -> float32 | source code
GetLinearDamping(...) b2Body_GetLinearDamping(b2Body self) -> float32 | source code
GetAngularDamping(...) b2Body_GetAngularDamping(b2Body self) -> float32 | source code
GetWorldCenter(...) b2Body_GetWorldCenter(b2Body self) -> b2Vec2 | source code
GetLocalCenter(...) b2Body_GetLocalCenter(b2Body self) -> b2Vec2 | source code
SetLinearVelocity(...) b2Body_SetLinearVelocity(b2Body self, b2Vec2 v) | source code
GetLinearVelocity(...) b2Body_GetLinearVelocity(b2Body self) -> b2Vec2 | source code
SetAngularVelocity(...) b2Body_SetAngularVelocity(b2Body self, float32 omega) | source code
GetAngularVelocity(...) b2Body_GetAngularVelocity(b2Body self) -> float32 | source code
ApplyForce(...) b2Body_ApplyForce(b2Body self, b2Vec2 force, b2Vec2 point) | source code
ApplyTorque(...) b2Body_ApplyTorque(b2Body self, float32 torque) | source code
ApplyImpulse(...) b2Body_ApplyImpulse(b2Body self, b2Vec2 impulse, b2Vec2 point) | source code
GetMass(...) b2Body_GetMass(b2Body self) -> float32 | source code
GetInertia(...) b2Body_GetInertia(b2Body self) -> float32 | source code
GetWorldPoint(...) b2Body_GetWorldPoint(b2Body self, b2Vec2 localPoint) -> b2Vec2 | source code
GetWorldVector(...) b2Body_GetWorldVector(b2Body self, b2Vec2 localVector) -> b2Vec2 | source code
GetLocalPoint(...) b2Body_GetLocalPoint(b2Body self, b2Vec2 worldPoint) -> b2Vec2 | source code
GetLocalVector(...) b2Body_GetLocalVector(b2Body self, b2Vec2 worldVector) -> b2Vec2 | source code
GetLinearVelocityFromWorldPoint(...) b2Body_GetLinearVelocityFromWorldPoint(b2Body self, b2Vec2 worldPoint) -> b2Vec2 | source code
GetLinearVelocityFromLocalPoint(...) b2Body_GetLinearVelocityFromLocalPoint(b2Body self, b2Vec2 localPoint) -> b2Vec2 | source code
IsBullet(...) b2Body_IsBullet(b2Body self) -> bool | source code
SetBullet(...) b2Body_SetBullet(b2Body self, bool flag) | source code
IsStatic(...) b2Body_IsStatic(b2Body self) -> bool | source code
IsDynamic(...) b2Body_IsDynamic(b2Body self) -> bool | source code
IsFrozen(...) b2Body_IsFrozen(b2Body self) -> bool | source code
IsSleeping(...) b2Body_IsSleeping(b2Body self) -> bool | source code
AllowSleeping(...) b2Body_AllowSleeping(b2Body self, bool flag) | source code
CanSleep(...) b2Body_CanSleep(b2Body self) -> bool | source code
IsRotationFixed(...) b2Body_IsRotationFixed(b2Body self) -> bool | source code
WakeUp(...) b2Body_WakeUp(b2Body self) | source code
PutToSleep(...) b2Body_PutToSleep(b2Body self) | source code
_GetShapeList(...) b2Body__GetShapeList(b2Body self) -> b2Shape | source code
GetJointList(...) b2Body_GetJointList(b2Body self) -> b2JointEdge | source code
GetControllerList(...) b2Body_GetControllerList(b2Body self) -> b2ControllerEdge | source code
GetNext(...) b2Body_GetNext(b2Body self) -> b2Body | source code
GetWorld(...) b2Body_GetWorld(b2Body self) -> b2World | source code
DestroyShape(...) b2Body_DestroyShape(b2Body self, b2Shape shape) | source code
CreateShape(...) b2Body_CreateShape(b2Body self, b2ShapeDef defn) -> b2Shape | source code
GetUserData(...) b2Body_GetUserData(b2Body self) -> PyObject | source code
SetUserData(...) b2Body_SetUserData(b2Body self, PyObject data) | source code
ClearUserData(...) b2Body_ClearUserData(b2Body self) | source code
__hash__(...) b2Body___hash__(b2Body self) -> int32 | source code

Properties | [hide private]
| thisown The membership flag
| userData GetUserData(self) -> PyObject
| massData Get a b2MassData object that represents this b2Body
| position GetPosition(self) -> b2Vec2
| angle GetAngle(self) -> float32
| linearDamping GetLinearDamping(self) -> float32
| angularDamping GetAngularDamping(self) -> float32
| allowSleep CanSleep(self) -> bool
| isSleeping IsSleeping(self) -> bool
| fixedRotation IsRotationFixed(self) -> bool
| isBullet IsBullet(self) -> bool
| angularVelocity GetAngularVelocity(self) -> float32
| linearVelocity GetLinearVelocity(self) -> b2Vec2
| shapeList Get a list of the shapes in this body

Method Details | [hide private]

### __init__(self, *args, **kwargs) (Constructor) | source code
Overrides: object.__init__ (inherited documentation)

### __repr__(self) (Representation operator) | source code
Overrides: object.__repr__ (inherited documentation)

### __getstate__(self) | source code
    Everything is essentially generic_getstate,
     except for edge shape handling.

    TODO: I can see a possible issue in this if joints are used on
    an edge shape or a body with edge shapes and other shapes.
    The shape list order could be improperly recreated. We'll see
    if anything happens...

### setAngle(self, angle) | source code
Set the angle without altering the position angle in radians.

### getMassData(self) | source code
Get a b2MassData object that represents this b2Body NOTE: To just get the mass, use body.mass (body.GetMass())

### GetShapeList(self, asType=True) | source code
Get a list of the shapes in this body Defaults to returning the typecasted objects. e.g., if there is a b2CircleShape and a b2PolygonShape: GetShapeList(True) = [b2CircleShape, b2PolygonShape] GetShapeList(False)= [b2Shape, b2Shape]

### SetMass(...) | source code
    b2Body_SetMass(b2Body self, b2MassData massData)

    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.

    Parameters:
    -----------

    massData: the mass properties.

### SetMassFromShapes(...) | source code
b2Body_SetMassFromShapes(b2Body self) 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.

### SetXForm(...) | source code
    b2Body_SetXForm(b2Body self, b2Vec2 position, float32 angle) -> bool

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

    Parameters:
    -----------

    position: the new world position of the body's origin (not necessarily the center of mass).

    angle: the new world rotation angle of the body in radians.

    false if the movement put a shape outside the world. In this case the body is automatically frozen.

### GetXForm(...) | source code
b2Body_GetXForm(b2Body self) -> b2XForm Get the body transform for the body's origin. the world transform of the body's origin.

### GetPosition(...) | source code
b2Body_GetPosition(b2Body self) -> b2Vec2 Get the world body origin position. the world position of the body's origin.

### GetAngle(...) | source code
b2Body_GetAngle(b2Body self) -> float32 Get the angle in radians. the current world rotation angle in radians.

### GetLinearDamping(...) | source code
b2Body_GetLinearDamping(b2Body self) -> float32 Get the linear damping.

### GetAngularDamping(...) | source code
b2Body_GetAngularDamping(b2Body self) -> float32 Get the angular damping.

### GetWorldCenter(...) | source code
b2Body_GetWorldCenter(b2Body self) -> b2Vec2 Get the world position of the center of mass.

### GetLocalCenter(...) | source code
b2Body_GetLocalCenter(b2Body self) -> b2Vec2 Get the local position of the center of mass.

### SetLinearVelocity(...) | source code
    b2Body_SetLinearVelocity(b2Body self, b2Vec2 v)

    Set the linear velocity of the center of mass.

    Parameters:
    -----------

    v: the new linear velocity of the center of mass.

### GetLinearVelocity(...) | source code
b2Body_GetLinearVelocity(b2Body self) -> b2Vec2 Get the linear velocity of the center of mass. the linear velocity of the center of mass.

### SetAngularVelocity(...) | source code
    b2Body_SetAngularVelocity(b2Body self, float32 omega)

    Set the angular velocity.

    Parameters:
    -----------

    omega: the new angular velocity in radians/second.

### GetAngularVelocity(...) | source code
b2Body_GetAngularVelocity(b2Body self) -> float32 Get the angular velocity. the angular velocity in radians/second.

### ApplyForce(...) | source code
    b2Body_ApplyForce(b2Body self, b2Vec2 force, b2Vec2 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:
    -----------

    force: the world force vector, usually in Newtons (N).

    point: the world position of the point of application.

### ApplyTorque(...) | source code
    b2Body_ApplyTorque(b2Body self, float32 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:
    -----------

    torque: about the z-axis (out of the screen), usually in N-m.

### ApplyImpulse(...) | source code
    b2Body_ApplyImpulse(b2Body self, b2Vec2 impulse, b2Vec2 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:
    -----------

    impulse: the world impulse vector, usually in N-seconds or kg-m/s.

    point: the world position of the point of application.

### GetMass(...) | source code
b2Body_GetMass(b2Body self) -> float32 Get the total mass of the body. the mass, usually in kilograms (kg).

### GetInertia(...) | source code
b2Body_GetInertia(b2Body self) -> float32 Get the central rotational inertia of the body. the rotational inertia, usually in kg-m^2.

### GetWorldPoint(...) | source code
    b2Body_GetWorldPoint(b2Body self, b2Vec2 localPoint) -> b2Vec2

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

    Parameters:
    -----------

    localPoint: a point on the body measured relative the the body's origin.

    the same point expressed in world coordinates.

### GetWorldVector(...) | source code
    b2Body_GetWorldVector(b2Body self, b2Vec2 localVector) -> b2Vec2

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

    Parameters:
    -----------

    localVector: a vector fixed in the body.

    the same vector expressed in world coordinates.

### GetLocalPoint(...) | source code
    b2Body_GetLocalPoint(b2Body self, b2Vec2 worldPoint) -> b2Vec2

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

    Parameters:
    -----------

    a: point in world coordinates.

    the corresponding local point relative to the body's origin.

### GetLocalVector(...) | source code
    b2Body_GetLocalVector(b2Body self, b2Vec2 worldVector) -> b2Vec2

    Gets a local vector given a world vector.

    Parameters:
    -----------

    a: vector in world coordinates.

    the corresponding local vector.

### GetLinearVelocityFromWorldPoint(...) | source code
    b2Body_GetLinearVelocityFromWorldPoint(b2Body self, b2Vec2 worldPoint) -> b2Vec2

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

    Parameters:
    -----------

    a: point in world coordinates.

    the world velocity of a point.

### GetLinearVelocityFromLocalPoint(...) | source code
    b2Body_GetLinearVelocityFromLocalPoint(b2Body self, b2Vec2 localPoint) -> b2Vec2

    Get the world velocity of a local point.

    Parameters:
    -----------

    a: point in local coordinates.

    the world velocity of a point.

### IsBullet(...) | source code
b2Body_IsBullet(b2Body self) -> bool Is this body treated like a bullet for continuous collision detection?

### SetBullet(...) | source code
b2Body_SetBullet(b2Body self, bool flag) Should this body be treated like a bullet for continuous collision detection?

### IsStatic(...) | source code
b2Body_IsStatic(b2Body self) -> bool Is this body static (immovable)?

### IsDynamic(...) | source code
b2Body_IsDynamic(b2Body self) -> bool Is this body dynamic (movable)?

### IsFrozen(...) | source code
b2Body_IsFrozen(b2Body self) -> bool Is this body frozen?

### IsSleeping(...) | source code
b2Body_IsSleeping(b2Body self) -> bool Is this body sleeping (not simulating).

### AllowSleeping(...) | source code
b2Body_AllowSleeping(b2Body self, bool flag) You can disable sleeping on this body.

### CanSleep(...) | source code
b2Body_CanSleep(b2Body self) -> bool Get whether or not this body is allowed to sleep.

### IsRotationFixed(...) | source code
b2Body_IsRotationFixed(b2Body self) -> bool Get whether or not this body is allowed to rotate.

### WakeUp(...) | source code
b2Body_WakeUp(b2Body self) Wake up this body so it will begin simulating.

### PutToSleep(...) | source code
b2Body_PutToSleep(b2Body self) Put this body to sleep so it will stop simulating. This also sets the velocity to zero.

### _GetShapeList(...) | source code
b2Body__GetShapeList(b2Body self) -> b2Shape Get the list of all shapes attached to this body.

### GetJointList(...) | source code
b2Body_GetJointList(b2Body self) -> b2JointEdge Get the list of all joints attached to this body.

### GetControllerList(...) | source code
b2Body_GetControllerList(b2Body self) -> b2ControllerEdge Get the list of all controllers attached to this body.

### GetNext(...) | source code
b2Body_GetNext(b2Body self) -> b2Body Get the next body in the world's body list.

### GetWorld(...) | source code
b2Body_GetWorld(b2Body self) -> b2World Get the parent world of this body.

### DestroyShape(...) | source code
    b2Body_DestroyShape(b2Body self, b2Shape shape)

    Destroy a shape. This removes the shape from the broad-phase and therefore destroys any contacts associated with this shape. All shapes attached to a body are implicitly destroyed when the body is destroyed.

    Parameters:
    -----------

    shape: the shape to be removed.

    WARNING:
    This function is locked during callbacks.

### CreateShape(...) | source code
    b2Body_CreateShape(b2Body self, b2ShapeDef defn) -> b2Shape

    Creates a shape and attach it to this body.

    Parameters:
    -----------

    shapeDef: the shape definition.

    WARNING:
    This function is locked during callbacks.

### GetUserData(...) | source code
b2Body_GetUserData(b2Body self) -> PyObject Get the user data pointer that was provided in the body definition.

### SetUserData(...) | source code
b2Body_SetUserData(b2Body self, PyObject data) Set the user data. Use this to store your application specific data.

### __hash__(...) (Hashing function) | source code
b2Body___hash__(b2Body self) -> int32 Overrides: object.__hash__

Property Details | [hide private]

### thisown The membership flag

### userData GetUserData(self) -> PyObject Get the user data pointer that was provided in the body definition.

### massData Get a b2MassData object that represents this b2Body NOTE: To just get the mass, use body.mass (body.GetMass()) Get Method: getMassData(self) - Get a b2MassData object that represents this b2Body

### position GetPosition(self) -> b2Vec2 Get the world body origin position. the world position of the body's origin. Set Method: setPosition(self, position) - Set the position without altering the angle

### angle GetAngle(self) -> float32 Get the angle in radians. the current world rotation angle in radians. Set Method: setAngle(self, angle) - Set the angle without altering the position

### linearDamping GetLinearDamping(self) -> float32 Get the linear damping.

### angularDamping GetAngularDamping(self) -> float32 Get the angular damping.

### allowSleep CanSleep(self) -> bool Get whether or not this body is allowed to sleep.

### isSleeping IsSleeping(self) -> bool Is this body sleeping (not simulating).

### fixedRotation IsRotationFixed(self) -> bool Get whether or not this body is allowed to rotate.

### isBullet IsBullet(self) -> bool Is this body treated like a bullet for continuous collision detection?

### angularVelocity GetAngularVelocity(self) -> float32 Get the angular velocity. the angular velocity in radians/second.

### linearVelocity GetLinearVelocity(self) -> b2Vec2 Get the linear velocity of the center of mass. the linear velocity of the center of mass.

### shapeList Get a list of the shapes in this body Defaults to returning the typecasted objects. e.g., if there is a b2CircleShape and a b2PolygonShape: GetShapeList(True) = [b2CircleShape, b2PolygonShape] GetShapeList(False)= [b2Shape, b2Shape] Get Method: GetShapeList(self, asType=True) - Get a list of the shapes in this body