|
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.World
public class World
The world class represents the simulation environment.
It has the following responsibilities:
The simulation step consists of
Field Summary | |
---|---|
static int |
M_SHAPE_MAX_VERTICES
|
protected EventSet |
mEventSet
Eventset managing the events. |
protected java.util.Vector |
mForces
|
protected java.util.Vector |
mParticles
|
protected ShapeSet |
mShapeSet
Shapeset managing the shapes. |
protected UserData |
mUserData
User data |
Constructor Summary | |
---|---|
|
World()
Empty Constructor. |
protected |
World(ShapeSet set)
Constructor with shapes. |
|
World(World world)
Copy constructor. |
Method Summary | |
---|---|
void |
addBody(Body body)
Adds a body to the world. |
void |
addConstraint(Constraint constraint)
Adds a constraint to the world. |
void |
addEvent(Event event)
Adds an event definition to the world. |
void |
addExternalForce(ExternalForce externalForce)
Adds an external force to the world. |
void |
addParticleEmitter(ParticleEmitter particleEmitter)
Adds a particle emitter to the world. |
void |
addScript(Script script)
Adds a script definition to the world. |
protected void |
addScriptBody(int index,
Body b)
Adds a body for script execution. |
Body[] |
addWorld(World world)
Adds a a complete world. |
int |
bodyIndexOf(int id)
Gets the index of the body. |
protected void |
checkCollisions()
Checks all bodies for collisions. |
protected void |
collideParticles()
|
protected Body |
findBody(Body b)
Find reference to the body |
Body |
findBodyAt(float xFX,
float yFX)
Finds the body at position x,y. |
Body |
findBodyById(int id)
Find reference to the body |
protected Constraint |
findConstraint(Constraint c)
Gets reference to the constraint. |
protected float |
getAreaEndFX()
Gets the end position of the area simulation. |
protected float |
getAreaStartFX()
Gets the start position of the area simulation. |
Body[] |
getBodies()
Gets all bodies. |
int |
getBodyCount()
Gets the number of bodies. |
int |
getBodyEndIndex()
Gets the end index of the currently active bodies. |
int |
getBodyStartIndex()
Gets the start index of the currently active bodies. |
float |
getBodyTotalEnergyFX(Body b)
Get the body energy. |
int |
getConstraintCount()
Gets the number of constraints. |
int |
getConstraintIterations()
Returns constraint iteration number. |
Constraint[] |
getConstraints()
Gets all constraints. |
int |
getContactCount()
Gets the number of current contacts. |
Contact[] |
getContacts()
Gets all current contacts. |
Contact[] |
getContactsForBody(Body b)
Gets all current contacts for a body. |
float |
getDampingLateralFX()
Gets the lateral damping factor. |
float |
getDampingRotationalFX()
Gets the rotational damping factor. |
java.util.Vector |
getEvents()
Gets a vector containing all events. |
FXVector |
getGravity()
Gets the gravity vector. |
float |
getInverseTimestepFX()
Gets the inverse of the timestep. |
Landscape |
getLandscape()
Gets the landscape object. |
java.util.Vector |
getParticleEmitters()
Gets a vector containing all particle emitters. |
int |
getPositionConstraintIterations()
Returns position constraint iteration number. |
Script |
getScript(int index)
Gets a script. |
protected Body[] |
getScriptBodies()
Gets a list of all bodies that scripts are applied to. |
protected int |
getScriptBodyCount()
Gets the number of bodies that scripts are applied to. |
int |
getScriptCount()
Gets the number of scripts. |
protected int[] |
getScriptIndices()
Gets a list of all applied script indices. |
Script[] |
getScripts()
Gets all scripts. |
ShapeSet |
getShapeSet()
Gets the shape set. |
float |
getTimestepFX()
Gets the timestep. |
UserData |
getUserData()
Get user data. |
int |
indexOf(Constraint c)
Gets the index of the constraint. |
static Constraint |
loadConstraint(PhysicsFileReader reader,
java.util.Vector bodies,
UserData userData)
Loads a constraint from a stream. |
static World |
loadWorld(PhysicsFileReader reader)
Loads a world from a stream. |
static World |
loadWorld(PhysicsFileReader reader,
UserData userData)
Loads a world from a stream. |
void |
removeBody(Body body)
Removes a body from the world. |
void |
removeConstraint(Constraint c)
Removes a constraint from the world. |
void |
removeEvent(Event e)
Removes an event from the world. |
void |
removeExternalForce(ExternalForce externalForce)
Removes an external force from the world. |
void |
removeParticleEmitter(ParticleEmitter particleEmitter)
Removes a particle emitter from the world. |
void |
removeScript(Script script)
Removes a script from the world. |
void |
setConstraintIterationDynamic(boolean isDynamic)
Sets the constraint iteration mode to dynamic/fixed. |
void |
setConstraintIterations(int constraintIterations)
Sets the number of constraint iterations. |
void |
setDampingLateralFX(float dampingFX)
Sets lateral damping factor (FX). |
void |
setDampingRotationalFX(float dampingFX)
Sets rotational damping factor (FX). |
void |
setGravity(FXVector gravity)
Sets the gravity vector. |
void |
setGravity(int gravity)
Sets the gravity. |
void |
setLandscape(Landscape landscape)
Sets the landscape for the world. |
void |
setPhysicsEventListener(PhysicsEventListener listener)
Sets the event listener. |
void |
setPositionConstraintIterations(int positionConstraintIterations)
Sets the number of position constraint iterations. |
void |
setSimulationArea(int start,
int end)
Sets the simulation area. |
void |
setTimestepFX(float timeStepFX)
Sets the timestep. |
void |
setUserData(UserData userData)
Set User data |
void |
tick()
Performs a single step in the simulation. |
void |
translate(FXVector translation)
Method to displace all bodies in the world by a given vector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int M_SHAPE_MAX_VERTICES
protected ShapeSet mShapeSet
protected EventSet mEventSet
protected java.util.Vector mParticles
protected java.util.Vector mForces
protected UserData mUserData
Constructor Detail |
---|
public World()
protected World(ShapeSet set)
public World(World world)
world
- source world objectMethod Detail |
---|
public UserData getUserData()
public void setUserData(UserData userData)
userData
- the user datapublic static World loadWorld(PhysicsFileReader reader)
reader
- the reader.
public static World loadWorld(PhysicsFileReader reader, UserData userData)
reader
- the reader.userData
- empty user data object
public float getTimestepFX()
public float getInverseTimestepFX()
public void setTimestepFX(float timeStepFX)
timeStepFX
- the new timestep (FX)public void setConstraintIterations(int constraintIterations)
constraintIterations
- number of iterations for constraint (default: 10)public void setPositionConstraintIterations(int positionConstraintIterations)
positionConstraintIterations
- number of iterations for position constraints (default: 5)public int getConstraintIterations()
public int getPositionConstraintIterations()
public void setConstraintIterationDynamic(boolean isDynamic)
mConstraintIterations
).
The dynamic mode stops when all constraints are staisfied.
The iteration count still works as an upper limit.
isDynamic
- whether the constraint iteration length is dynamicpublic void setPhysicsEventListener(PhysicsEventListener listener)
listener
- the listener.public void setSimulationArea(int start, int end)
start
- the start coordinate of the simulation area (along the x-axis)end
- the end coordinate of the simulation area (along the x-axis)public ShapeSet getShapeSet()
public Body[] addWorld(World world)
world
- the elements to add to this worldpublic void addBody(Body body)
body
- new Body.public void setLandscape(Landscape landscape)
landscape
- the landscape object.public Landscape getLandscape()
public void addParticleEmitter(ParticleEmitter particleEmitter)
particleEmitter
- new particle emitter.public void addExternalForce(ExternalForce externalForce)
externalForce
- new external force.public void removeBody(Body body)
body
- the body to remove.public void removeConstraint(Constraint c)
c
- the constraint to remove.public void removeScript(Script script)
script
- the script to remove.public void removeEvent(Event e)
e
- the event to remove.public void removeParticleEmitter(ParticleEmitter particleEmitter)
particleEmitter
- particle emitter to remove.public void removeExternalForce(ExternalForce externalForce)
externalForce
- external force to remove.public Body findBodyById(int id)
protected Body findBody(Body b)
public Body findBodyAt(float xFX, float yFX)
xFX
- the x-position (FX)yFX
- the y-position (FX)
public int bodyIndexOf(int id)
id
- identifier of the body
protected Constraint findConstraint(Constraint c)
public int indexOf(Constraint c)
c
- the constraint.
public void addConstraint(Constraint constraint)
constraint
- the constrain.public void addScript(Script script)
script
- the script definition.protected void addScriptBody(int index, Body b)
index
- the index of the script.b
- the body to which the script applies to.public void addEvent(Event event)
event
- the event definition.public void setGravity(int gravity)
gravity
- the new gravity. The vector will be in downward direction.public void setGravity(FXVector gravity)
gravity
- the new gravity.public void setDampingLateralFX(float dampingFX)
dampingFX
- damping factorFXUtil
public void setDampingRotationalFX(float dampingFX)
dampingFX
- damping factorFXUtil
public void tick()
protected void checkCollisions()
protected void collideParticles()
public FXVector getGravity()
public float getDampingLateralFX()
public float getDampingRotationalFX()
public static Constraint loadConstraint(PhysicsFileReader reader, java.util.Vector bodies, UserData userData)
reader
- the file reader.bodies
- the body vector for correct referencing of bodies in the Constraint.
public java.util.Vector getEvents()
public java.util.Vector getParticleEmitters()
protected float getAreaStartFX()
protected float getAreaEndFX()
public int getBodyCount()
public Body[] getBodies()
public int getBodyStartIndex()
public int getBodyEndIndex()
public int getConstraintCount()
public Constraint[] getConstraints()
public int getContactCount()
public Contact[] getContacts()
public int getScriptCount()
public Script[] getScripts()
public Script getScript(int index)
index
- index of the script
protected int getScriptBodyCount()
protected Body[] getScriptBodies()
protected int[] getScriptIndices()
public Contact[] getContactsForBody(Body b)
b
- the body.
public void translate(FXVector translation)
translation
- vector for body translationpublic float getBodyTotalEnergyFX(Body b)
b
- the body
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |