public class Body
extends java.lang.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_angularDamping |
float |
m_angularVelocity |
ContactEdge |
m_contactList |
int |
m_fixtureCount |
Fixture |
m_fixtureList |
int |
m_flags |
Vec2 |
m_force |
float |
m_gravityScale |
float |
m_I |
float |
m_invI |
float |
m_invMass |
int |
m_islandIndex |
JointEdge |
m_jointList |
float |
m_linearDamping |
Vec2 |
m_linearVelocity |
float |
m_mass |
Body |
m_next |
Body |
m_prev |
float |
m_sleepTime |
Sweep |
m_sweep
The swept motion for CCD
|
float |
m_torque |
BodyType |
m_type |
java.lang.Object |
m_userData |
World |
m_world |
Transform |
m_xf
The body origin transform.
|
Modifier and Type | Method and Description |
---|---|
protected void |
advance(float t) |
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)
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.
|
Fixture |
getFixtureList()
Get the list of all fixtures attached to this body.
|
float |
getGravityScale()
Get the gravity scale of the body.
|
float |
getInertia()
Get the central rotational inertia of the body.
|
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()
Get the total mass of the body.
|
void |
getMassData(MassData data)
Get the mass data of the body.
|
Body |
getNext()
Get the next body in the world's body list.
|
Vec2 |
getPosition()
Get the world body origin position.
|
Transform |
getTransform()
Get the body transform for the body's origin.
|
BodyType |
getType() |
java.lang.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()
Get the active state of the body.
|
boolean |
isAwake()
Get the sleeping state of this body.
|
boolean |
isBullet()
Is this body treated like a bullet for continuous collision detection?
|
boolean |
isFixedRotation()
Does this body have fixed rotation?
|
boolean |
isSleepingAllowed()
Is this body allowed to sleep
|
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(java.lang.Object data)
Set the user data.
|
boolean |
shouldCollide(Body other)
This is used to prevent connected bodies from colliding.
|
protected void |
synchronizeFixtures() |
void |
synchronizeTransform() |
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 BodyType m_type
public int m_flags
public int m_islandIndex
public final Transform m_xf
public final Sweep m_sweep
public final Vec2 m_linearVelocity
public float m_angularVelocity
public final Vec2 m_force
public float m_torque
public World m_world
public Body m_prev
public Body m_next
public Fixture m_fixtureList
public int m_fixtureCount
public JointEdge m_jointList
public ContactEdge m_contactList
public float m_mass
public float m_invMass
public float m_I
public float m_invI
public float m_linearDamping
public float m_angularDamping
public float m_gravityScale
public float m_sleepTime
public java.lang.Object m_userData
public final Fixture createFixture(FixtureDef def)
def
- the fixture definition.public final Fixture createFixture(Shape shape, float density)
shape
- the shape to be cloned.density
- the shape density (set to zero for static bodies).public final void destroyFixture(Fixture fixture)
fixture
- the fixture to be removed.public final void setTransform(Vec2 position, float angle)
position
- the world position of the body's local origin.angle
- the world rotation in radians.public final Transform getTransform()
public final Vec2 getPosition()
public final float getAngle()
public final Vec2 getWorldCenter()
public final Vec2 getLocalCenter()
public final void setLinearVelocity(Vec2 v)
v
- the new linear velocity of the center of mass.public final Vec2 getLinearVelocity()
setLinearVelocity(Vec2)
.public final void setAngularVelocity(float w)
omega
- the new angular velocity in radians/second.public final float getAngularVelocity()
public float getGravityScale()
public void setGravityScale(float gravityScale)
gravityScale
- public final void applyForce(Vec2 force, Vec2 point)
force
- the world force vector, usually in Newtons (N).point
- the world position of the point of application.public final void applyForceToCenter(Vec2 force)
force
- the world force vector, usually in Newtons (N).public final void applyTorque(float torque)
torque
- about the z-axis (out of the screen), usually in N-m.public final void applyLinearImpulse(Vec2 impulse, Vec2 point)
impulse
- the world impulse vector, usually in N-seconds or kg-m/s.point
- the world position of the point of application.public void applyAngularImpulse(float impulse)
impulse
- the angular impulse in units of kg*m*m/spublic final float getMass()
public final float getInertia()
public final void getMassData(MassData data)
public final void setMassData(MassData massData)
massData
- the mass properties.public final void resetMassData()
public final Vec2 getWorldPoint(Vec2 localPoint)
localPoint
- a point on the body measured relative the the body's origin.public final Vec2 getWorldVector(Vec2 localVector)
localVector
- a vector fixed in the body.public final Vec2 getLocalPoint(Vec2 worldPoint)
a
- point in world coordinates.public final Vec2 getLocalVector(Vec2 worldVector)
a
- vector in world coordinates.public final Vec2 getLinearVelocityFromWorldPoint(Vec2 worldPoint)
a
- point in world coordinates.public final void getLinearVelocityFromWorldPointToOut(Vec2 worldPoint, Vec2 out)
public final Vec2 getLinearVelocityFromLocalPoint(Vec2 localPoint)
a
- point in local coordinates.public final void getLinearVelocityFromLocalPointToOut(Vec2 localPoint, Vec2 out)
public final float getLinearDamping()
public final void setLinearDamping(float linearDamping)
public final float getAngularDamping()
public final void setAngularDamping(float angularDamping)
public BodyType getType()
public void setType(BodyType type)
type
- public final boolean isBullet()
public final void setBullet(boolean flag)
public void setSleepingAllowed(boolean flag)
flag
- public boolean isSleepingAllowed()
public void setAwake(boolean flag)
flag
- set to true to put body to sleep, false to wake it.flag
- public boolean isAwake()
public void setActive(boolean flag)
flag
- public boolean isActive()
public void setFixedRotation(boolean flag)
flag
- public boolean isFixedRotation()
public final Fixture getFixtureList()
public final JointEdge getJointList()
public final ContactEdge getContactList()
public final Body getNext()
public final java.lang.Object getUserData()
public final void setUserData(java.lang.Object data)
public final World getWorld()
protected final void synchronizeFixtures()
public final void synchronizeTransform()
public boolean shouldCollide(Body other)
other
- protected final void advance(float t)
Copyright © 2017. All Rights Reserved.