public final class Body extends Object
Modifier and Type | Field and Description |
---|---|
static int |
e_activeFlag |
static int |
e_autoSleepFlag |
static int |
e_awakeFlag |
static int |
e_bulletFlag |
static int |
e_fixedRotationFlag |
static int |
e_islandFlag |
static int |
e_toiFlag |
float |
m_angularVelocity |
ContactEdge |
m_contactList |
int |
m_flags |
Vec2 |
m_force |
float |
m_invI |
float |
m_invMass |
int |
m_islandIndex |
JointEdge |
m_jointList |
Vec2 |
m_linearVelocity |
float |
m_mass |
Sweep |
m_sweep
The swept motion for CCD
|
float |
m_torque |
Transform |
m_xf
The body origin transform.
|
Transform |
m_xf0
The previous transform for particle simulation
|
Modifier and Type | Method and Description |
---|---|
void |
applyAngularImpulse(float impulse)
Apply an angular impulse.
|
void |
applyForce(Vec2 force,
Vec2 point)
Apply a force at a world point.
|
void |
applyForceToCenter(Vec2 force)
Apply a force to the center of mass.
|
void |
applyLinearImpulse(Vec2 impulse,
Vec2 point,
boolean wake)
Apply an impulse at a point.
|
void |
applyTorque(float torque)
Apply a torque.
|
Fixture |
createFixture(FixtureDef def)
Creates a fixture and attach it to this body.
|
Fixture |
createFixture(Shape shape,
float density)
Creates a fixture from a shape and attach it to this body.
|
void |
destroyFixture(Fixture fixture)
Destroy a fixture.
|
float |
getAngle()
Get the angle in radians.
|
float |
getAngularDamping()
Get the angular damping of the body.
|
float |
getAngularVelocity()
Get the angular velocity.
|
ContactEdge |
getContactList()
Get the list of all contacts attached to this body.
|
List<Fixture> |
getFixtures() |
float |
getGravityScale() |
float |
getInertia() |
JointEdge |
getJointList()
Get the list of all joints attached to this body.
|
float |
getLinearDamping()
Get the linear damping of the body.
|
Vec2 |
getLinearVelocity()
Get the linear velocity of the center of mass.
|
Vec2 |
getLinearVelocityFromLocalPoint(Vec2 localPoint)
Get the world velocity of a local point.
|
void |
getLinearVelocityFromLocalPointToOut(Vec2 localPoint,
Vec2 out) |
Vec2 |
getLinearVelocityFromWorldPoint(Vec2 worldPoint)
Get the world linear velocity of a world point attached to this body.
|
void |
getLinearVelocityFromWorldPointToOut(Vec2 worldPoint,
Vec2 out) |
Vec2 |
getLocalCenter()
Get the local position of the center of mass.
|
Vec2 |
getLocalPoint(Vec2 worldPoint)
Gets a local point relative to the body's origin given a world point.
|
void |
getLocalPointToOut(Vec2 worldPoint,
Vec2 out) |
Vec2 |
getLocalVector(Vec2 worldVector)
Gets a local vector given a world vector.
|
void |
getLocalVectorToOut(Vec2 worldVector,
Vec2 out) |
void |
getLocalVectorToOutUnsafe(Vec2 worldVector,
Vec2 out) |
float |
getMass() |
void |
getMassData(MassData data)
Get the mass data of the body.
|
Vec2 |
getPosition()
Get the world body origin position.
|
float |
getSleepTime() |
Transform |
getTransform() |
BodyType |
getType() |
Object |
getUserData()
Get the user data pointer that was provided in the body definition.
|
World |
getWorld()
Get the parent world of this body.
|
Vec2 |
getWorldCenter()
Get the world position of the center of mass.
|
Vec2 |
getWorldPoint(Vec2 localPoint)
Get the world coordinates of a point given the local coordinates.
|
void |
getWorldPointToOut(Vec2 localPoint,
Vec2 out) |
Vec2 |
getWorldVector(Vec2 localVector)
Get the world coordinates of a vector given the local coordinates.
|
void |
getWorldVectorToOut(Vec2 localVector,
Vec2 out) |
void |
getWorldVectorToOutUnsafe(Vec2 localVector,
Vec2 out) |
boolean |
isActive() |
boolean |
isAwake()
Get the sleeping state of this body.
|
boolean |
isBullet() |
boolean |
isFixedRotation() |
boolean |
isSleepingAllowed() |
void |
resetMassData()
This resets the mass properties to the sum of the mass properties of the fixtures.
|
void |
setActive(boolean flag)
Set the active state of the body.
|
void |
setAngularDamping(float angularDamping)
Set the angular damping of the body.
|
void |
setAngularVelocity(float w)
Set the angular velocity.
|
void |
setAwake(boolean flag)
Set the sleep state of the body.
|
void |
setBullet(boolean flag)
Should this body be treated like a bullet for continuous collision detection?
|
void |
setFixedRotation(boolean flag)
Set this body to have fixed rotation.
|
void |
setGravityScale(float gravityScale)
Set the gravity scale of the body.
|
void |
setLinearDamping(float linearDamping)
Set the linear damping of the body.
|
void |
setLinearVelocity(Vec2 v)
Set the linear velocity of the center of mass.
|
void |
setMassData(MassData massData)
Set the mass properties to override the mass properties of the fixtures.
|
void |
setSleepingAllowed(boolean flag)
You can disable sleeping on this body.
|
void |
setTransform(Vec2 position,
float angle)
Set the position of the body's origin and rotation.
|
void |
setType(BodyType type)
Set the type of this body.
|
void |
setUserData(Object data)
Set the user data.
|
boolean |
shouldCollide(Body other)
This is used to prevent connected bodies from colliding.
|
public static final int e_islandFlag
public static final int e_awakeFlag
public static final int e_autoSleepFlag
public static final int e_bulletFlag
public static final int e_fixedRotationFlag
public static final int e_activeFlag
public static final int e_toiFlag
public JointEdge m_jointList
public ContactEdge m_contactList
public int m_flags
public int m_islandIndex
public final Transform m_xf
public final Transform m_xf0
public final Sweep m_sweep
public final Vec2 m_linearVelocity
public float m_angularVelocity
public final Vec2 m_force
public float m_torque
public float m_mass
public float m_invMass
public float m_invI
public List<Fixture> getFixtures()
public Fixture createFixture(FixtureDef def)
def
- the fixture definitionpublic Fixture createFixture(Shape shape, float density)
shape
- the shape to be cloned.density
- the shape density (set to zero for static bodies).public void destroyFixture(Fixture fixture)
fixture
- the fixture to be removedpublic void setTransform(Vec2 position, float angle)
position
- the world position of the body's local originangle
- the world rotation in radianspublic Transform getTransform()
public Vec2 getPosition()
public float getAngle()
public Vec2 getWorldCenter()
public Vec2 getLocalCenter()
public void setLinearVelocity(Vec2 v)
v
- the new linear velocity of the center of mass.public Vec2 getLinearVelocity()
setLinearVelocity(Vec2)
.public void setAngularVelocity(float w)
w
- the new angular velocity in radians/second.public float getAngularVelocity()
public float getGravityScale()
public void setGravityScale(float gravityScale)
gravityScale
- gravity scalepublic void applyForce(Vec2 force, Vec2 point)
force
- the world force vector, usually in Newtons (N)point
- the world position of the point of applicationpublic void applyForceToCenter(Vec2 force)
force
- the world force vector, usually in Newtons (N)public void applyTorque(float torque)
torque
- about the z-axis (out of the screen), usually in N-mpublic void applyLinearImpulse(Vec2 impulse, Vec2 point, boolean wake)
impulse
- the world impulse vector, usually in N-seconds or kg-m/spoint
- the world position of the point of applicationwake
- also wake up the bodypublic void applyAngularImpulse(float impulse)
impulse
- the angular impulse in units of kg*m*m/spublic float getMass()
public float getInertia()
public void getMassData(MassData data)
public void setMassData(MassData massData)
massData
- the mass properties.public void resetMassData()
public Vec2 getWorldPoint(Vec2 localPoint)
localPoint
- a point on the body measured relative the the body's origin.public Vec2 getWorldVector(Vec2 localVector)
localVector
- a vector fixed in the body.public Vec2 getLocalPoint(Vec2 worldPoint)
worldPoint
- point in world coordinates.public Vec2 getLocalVector(Vec2 worldVector)
worldVector
- vector in world coordinates.public Vec2 getLinearVelocityFromWorldPoint(Vec2 worldPoint)
worldPoint
- point in world coordinates.public void getLinearVelocityFromWorldPointToOut(Vec2 worldPoint, Vec2 out)
public Vec2 getLinearVelocityFromLocalPoint(Vec2 localPoint)
localPoint
- point in local coordinates.public void getLinearVelocityFromLocalPointToOut(Vec2 localPoint, Vec2 out)
public float getLinearDamping()
public void setLinearDamping(float linearDamping)
public float getAngularDamping()
public void setAngularDamping(float angularDamping)
public float getSleepTime()
public BodyType getType()
public void setType(BodyType type)
type
- body typepublic boolean isBullet()
public void setBullet(boolean flag)
public void setSleepingAllowed(boolean flag)
flag
- sleep flagpublic boolean isSleepingAllowed()
public void setAwake(boolean flag)
flag
- set to true to put body to sleep, false to wake itpublic boolean isAwake()
public void setActive(boolean flag)
flag
- active flagpublic boolean isActive()
public void setFixedRotation(boolean flag)
flag
- fixed rotation flagpublic boolean isFixedRotation()
public JointEdge getJointList()
public ContactEdge getContactList()
public Object getUserData()
public void setUserData(Object data)
public World getWorld()
public boolean shouldCollide(Body other)
other
- other bodyCopyright © 2018. All rights reserved.