|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.emini.physics2D.Body
public class Body
The Body class represents the physical state of a body.
This comprises:
Each object can be static or dynamic.
Static objects do not move and act like having a mass of infinity.
Field Summary | |
---|---|
protected float |
mAngularVelocity2FX
Current angular velocity (2FX) of the body. |
protected int |
mId
Body id. |
protected FXVector |
mPositionFX
Position vector of the body. |
protected float |
mRotation2FX
Current angle (2FX) of the body. |
protected Shape |
mShape
The shape of the body. |
protected UserData |
mUserData
User data. |
protected FXVector |
mVelocityFX
Current velocity of the body. |
protected float |
mVirtualAngularVelocity2FX
Current Virtual angular velocity of the body. |
protected FXVector |
mVirtualVelocityFX
Current virtual velocity of the body. |
Constructor Summary | |
---|---|
Body(Body other)
Copy constructor. |
|
Body(FXVector pos,
Shape shape,
boolean dynamic)
Constructor. |
|
Body(int x,
int y,
Shape shape,
boolean dynamic)
Constructor. |
Method Summary | |
---|---|
void |
addCollisionLayer(int layer)
Add a collision layer to the body. |
protected void |
addContact(Contact c)
Adds a new contact. |
float |
angularVelocity2FX()
Gets the current angular velocity. |
void |
angularVelocity2FX(float angularVelocity2FX)
Sets the angular velocity. |
void |
applyAcceleration(FXVector acceleration,
float timestepFX)
Applies acceleration to the body. |
void |
applyForce(FXVector force,
float timestepFX)
Applies forces to the body. |
void |
applyMomentum(FXVector impulse)
Applies an impulse to the body center. |
void |
applyMomentumAt(FXVector impulse,
FXVector position)
Applies an impulse at a position. |
void |
applyTorque(float torqueFX)
Applies torque to the body. |
void |
applyVirtualMomentumAt(FXVector impulse,
FXVector position)
Applies a virtual impulse at a position. |
protected void |
calculateAABB(float timestepFX)
Recalculates the AABB. |
boolean |
canRotate()
Checks if the body can rotate. |
Body |
copy()
Copy method. |
boolean |
equals(Body other)
Compares two bodies. |
void |
forceUpdate(float timestepFX)
Forces an update of body internals. |
float |
getAABBMaxXFX()
Gets the right side of the AABB. |
float |
getAABBMaxYFX()
Gets the bottom of the AABB. |
float |
getAABBMinXFX()
Gets the left side of the AABB. |
float |
getAABBMinYFX()
Gets the top of the AABB. |
FXVector |
getAbsoluePoint(FXVector relativePoint)
Converts a relative position to absolute coordinates. |
void |
getAbsoluePoint(FXVector relativePoint,
FXVector target)
Converts a relative position to absolute coordinates. |
FXVector[] |
getAxes()
Calculates the projection axes in absolute coordinates. |
int |
getColissionBitFlag()
Gets the complete collision flag. |
protected Contact |
getContact(Body other)
Find a contact with another body. |
protected Contact |
getContact(int idx1,
Body other,
int idx2)
Find a contact with another body. |
Contact[] |
getContacts()
Gets the current contacts. |
int |
getId()
Gets the id. |
float |
getInvInertia2FX()
Gets the inverted inertia of the body. |
float |
getInvMass2FX()
Gets the inverted mass of the body. |
FXVector |
getRelativePoint(FXVector absolutePoint)
Converts an absolute position to relative coordinates. |
FXMatrix |
getRotationMatrix()
Gets the rotation matrix. |
UserData |
getUserData()
Get user data. |
FXVector |
getVelocity(FXVector relativePositionFX)
Calculates the velocity of a point of the body. |
void |
getVelocity(FXVector relativePositionFX,
FXVector result)
Calculates the velocity of a point (reuse object). |
FXVector[] |
getVertices()
Calculates the current vertices in absolute coordinates. |
protected FXVector |
getVirtualVelocity(FXVector relativePositionFX)
Calculates the virtual velocity of a point of the body. |
protected void |
getVirtualVelocity(FXVector relativePositionFX,
FXVector result)
Calculates the virtual velocity of a point (reuse object). |
protected void |
initShapeInternals()
Caches collision info from the shape. |
void |
integrateVelocity(float dtFX)
Integrates the velocity. |
void |
integrateVirtualVelocity(float dtFX,
FXVector gravity)
|
boolean |
isAffectedByGravity()
Checks if the body is affected by gravity. |
boolean |
isDynamic()
Checks if the body is dynamic. |
boolean |
isInteracting()
Checks if the body can interact with other bodies. |
boolean |
isResting()
Checks if the body is resting. |
static Body |
loadBody(PhysicsFileReader reader,
java.util.Vector shapes,
UserData userData)
Loads a body from stream. |
FXVector |
positionFX()
Gets the body position |
void |
removeCollisionLayer(int layer)
Remove a collision layer from the body. |
protected void |
resetContacts()
Clear all contacts from previous step. |
float |
rotation2FX()
Gets the current angle. |
float |
rotationVelocity2FX()
Gets the angulare velocity. |
void |
setDynamic(boolean dynamic)
Sets dynamic property of the body. |
void |
setGravityAffected(boolean affected)
Sets if the body is affected by gravity. |
void |
setInteracting(boolean interacting)
Sets if the body is allowed to interact with other bodies. |
void |
setPositionFX(FXVector positionFX)
Sets the position. |
void |
setRotatable(boolean rotatable)
Sets if the body is allowed to rotate. |
void |
setRotation2FX(float rotation2FX)
Sets the current angle (2FX). |
void |
setRotationDeg(int rot)
Sets the current angle. |
void |
setShape(Shape newShape)
Sets the shape. |
void |
setUserData(UserData userData)
Set User data |
Shape |
shape()
Gets the shape of the body. |
void |
translate(FXVector translation,
float timestepFX)
Moves the body directly. |
protected void |
updateVelocity(float dampingLinearFX,
float dampingRotationalFX)
Postprocesses the velocity. |
FXVector |
velocityFX()
Gets the current velocity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected FXVector mPositionFX
protected FXVector mVelocityFX
protected FXVector mVirtualVelocityFX
protected float mRotation2FX
protected float mAngularVelocity2FX
protected float mVirtualAngularVelocity2FX
protected Shape mShape
protected int mId
protected UserData mUserData
Constructor Detail |
---|
public Body(int x, int y, Shape shape, boolean dynamic)
World
to act there.
x
- x positiony
- y positionshape
- Shape of the bodydynamic
- whether the body can move or notpublic Body(FXVector pos, Shape shape, boolean dynamic)
World
to act there.
pos
- position of the body centershape
- Shape of the bodydynamic
- whether the body can move or notpublic Body(Body other)
other
- the source to copyMethod Detail |
---|
public Body copy()
public static Body loadBody(PhysicsFileReader reader, java.util.Vector shapes, UserData userData)
reader
- the file reader representing the data streamshapes
- a vector containing the shapes in correct order, (the order they are saved in the stored file)
public boolean equals(Body other)
other
- the other body to compare
protected void initShapeInternals()
public int getId()
public boolean isDynamic()
public boolean isResting()
public boolean canRotate()
public void setRotatable(boolean rotatable)
rotatable
- whether the body is allowed to rotate.public boolean isInteracting()
public void setInteracting(boolean interacting)
interacting
- whether the body is allowed to interact.public boolean isAffectedByGravity()
public void setGravityAffected(boolean affected)
affected
- whether the body is affecetd by gravity.public void addCollisionLayer(int layer)
mColissionBitFlag
.
layer
- the layer for the interaction,
must be smaller than 32 as the bitflag is stored in an intpublic void removeCollisionLayer(int layer)
mColissionBitFlag
.
layer
- the layer for the interaction,
must be smaller than 32 as the bitflag is stored in an intpublic final float getInvMass2FX()
public final float getInvInertia2FX()
public void translate(FXVector translation, float timestepFX)
translation
- vector for translationtimestepFX
- timestep of the simulationpublic void forceUpdate(float timestepFX)
timestepFX
- timestep of the simulationpublic final FXVector getAbsoluePoint(FXVector relativePoint)
relativePoint
- position relative to the body center,
public final void getAbsoluePoint(FXVector relativePoint, FXVector target)
relativePoint
- position relative to the body center,target
- the vector to store the result intopublic final FXVector getRelativePoint(FXVector absolutePoint)
absolutePoint
-
public final FXVector getVelocity(FXVector relativePositionFX)
relativePositionFX
- coordinates of the point relative to the body center
protected final FXVector getVirtualVelocity(FXVector relativePositionFX)
relativePositionFX
- coordinates of the point relative to the body center
public final void getVelocity(FXVector relativePositionFX, FXVector result)
relativePositionFX
- coordinates of the point relative to the center.result
- the vector for storing the resulting velocity.protected final void getVirtualVelocity(FXVector relativePositionFX, FXVector result)
relativePositionFX
- coordinates of the point relative to the center.result
- the vector, where the result is written topublic Shape shape()
public void setShape(Shape newShape)
newShape
- the shape of the body.public final FXVector[] getVertices()
public final FXVector[] getAxes()
public float rotation2FX()
public float angularVelocity2FX()
public FXMatrix getRotationMatrix()
public FXVector positionFX()
public FXVector velocityFX()
public float rotationVelocity2FX()
public void setRotation2FX(float rotation2FX)
rotation2FX
- new angle (2FX)public void setRotationDeg(int rot)
rot
- new angle in degrees (0-360)public void setPositionFX(FXVector positionFX)
positionFX
- new position for the center of gravity.public void angularVelocity2FX(float angularVelocity2FX)
angularVelocity2FX
- the new velocity (2FX)public void applyAcceleration(FXVector acceleration, float timestepFX)
acceleration
- the accelerationtimestepFX
- timestep of the simulation (= time that the force is acting).
This should not be larger than the simulation timestep.public void applyForce(FXVector force, float timestepFX)
force
- the applied forcetimestepFX
- timestep of the simulation (= time that the force is acting).
This should not be larger than the simulation timestep.public final void applyMomentumAt(FXVector impulse, FXVector position)
impulse
- the impulse vector.position
- position in the body (relative to the center).public final void applyVirtualMomentumAt(FXVector impulse, FXVector position)
impulse
- the virtual impulse vector.position
- position in the body (relative to the center).public final void applyMomentum(FXVector impulse)
impulse
- the impulse vector to applypublic final void applyTorque(float torqueFX)
torqueFX
- the torque to apply (FX).public final void integrateVelocity(float dtFX)
dtFX
- timestep (FX)public final void integrateVirtualVelocity(float dtFX, FXVector gravity)
protected final void calculateAABB(float timestepFX)
timestepFX
- the timestep for the lookahead. Use the current timestep of the world.protected final void updateVelocity(float dampingLinearFX, float dampingRotationalFX)
dampingLinearFX
- linear damping factordampingRotationalFX
- rotational damping factorprotected void resetContacts()
protected void addContact(Contact c)
c
- the new Contactpublic Contact[] getContacts()
protected Contact getContact(Body other)
other
- other body.
protected Contact getContact(int idx1, Body other, int idx2)
other
- other body.
public void setDynamic(boolean dynamic)
dynamic
- if the body can move.public float getAABBMinXFX()
public float getAABBMaxXFX()
public float getAABBMinYFX()
public float getAABBMaxYFX()
public int getColissionBitFlag()
public UserData getUserData()
public void setUserData(UserData userData)
userData
- the user data
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |