|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.physics.simulation.SimulationWorld
public abstract class SimulationWorld
A simulation world
| Field Summary | |
|---|---|
protected SimulationEngine |
engine
|
| Constructor Summary | |
|---|---|
SimulationWorld(SimulationEngine engine)
Creates a new simulation world. |
|
| Method Summary | |
|---|---|
void |
addBody(Body body)
Adds a body to the world. |
protected abstract void |
addBodyImpl(Body body)
Put impl-specific stuff here. |
void |
addJoint(Joint joint)
Adds a joint to the world. |
protected abstract void |
addJointImpl(Joint joint)
Put impl-specific stuff here. |
protected abstract void |
afterStep()
This method is called after the stepImpl(long) method is
called. |
protected abstract void |
beforeStep()
This method is called before the stepImpl(long) method is
called. |
Body |
getBody(int i)
Gets a body from its index. |
SimulationEngine |
getEngine()
|
org.openmali.vecmath2.Vector3f |
getGravity()
|
Joint |
getJoint(int i)
Gets a joint from its index. |
long |
getMaxStepSize()
|
abstract java.lang.String |
getStepperFunction()
|
abstract java.util.Set<java.lang.String> |
getStepperFunctions()
|
long |
getStepSize()
|
boolean |
isEnabled()
|
boolean |
isGravityEnabled()
|
BallJoint |
newBallJoint(Body body1,
Body body2)
Creates a new BallJoint. |
protected abstract BallJoint |
newBallJointImpl(Body body1,
Body body2)
Creates a new BallJoint. |
Body |
newBody()
Creates a new Body. |
protected abstract Body |
newBodyImpl()
Creates a new Body. |
FixedJoint |
newFixedJoint(Body body1,
Body body2)
Creates a new FixedJoint. |
protected abstract FixedJoint |
newFixedJointImpl(Body body1,
Body body2)
Creates a new FixedJoint. |
Hinge2Joint |
newHinge2Joint(Body body1,
Body body2)
Creates a new Hinge2Joint. |
protected abstract Hinge2Joint |
newHinge2JointImpl(Body body1,
Body body2)
Creates a new Hinge2Joint. |
HingeJoint |
newHingeJoint(Body body1,
Body body2)
Creates a new HingeJoint. |
protected abstract HingeJoint |
newHingeJointImpl(Body body1,
Body body2)
Creates a new HingeJoint. |
JointLimitMotor |
newJointLimitMotor()
|
protected JointLimitMotor |
newJointLimitMotor(float defaultCFM,
float defaultERP)
|
SliderJoint |
newSliderJoint(Body body1,
Body body2)
Creates a new SliderJoint. |
protected abstract SliderJoint |
newSliderJointImpl(Body body1,
Body body2)
Creates a new SliderJoint. |
int |
numBodies()
|
int |
numJoints()
|
void |
removeBody(Body body)
Removes a body from the world. |
protected abstract void |
removeBodyImpl(Body body)
Put impl-specific stuff here. |
void |
removeJoint(Joint joint)
Removes a joint from the world. |
protected abstract void |
removeJointImpl(Joint joint)
Put impl-specific stuff here |
abstract void |
resolveCollision(Collision collision,
Body body1,
Body body2,
SurfaceParameters surfParams)
This method should be called by yourself (yeah, SimulationWorld is listening to you !!) |
void |
resolveCollision(Collision collision,
SurfaceParameters surfParams)
This method should be called by yourself (yeah, SimulationWorld is listening to you !!) |
void |
setEnabled(boolean enabled)
Sets this SimulationWorld enabled/disabled. |
void |
setGravity(float x,
float y,
float z)
|
void |
setGravity(org.openmali.vecmath2.Vector3f gravity)
|
void |
setGravityEnabled(boolean enabled)
Sets whether gravity is (world-)globally enabled or not. |
protected abstract void |
setGravityImpl(float x,
float y,
float z)
Put impl-specific stuff here. |
void |
setMaxStepSize(long micros)
Sets the maximum internal step time in microseconds. |
abstract void |
setStepperFunction(java.lang.String stepperFunction)
Sets the stepping function to be used. |
void |
setStepSize(long micros)
Sets the constant internal step time in microseconds. |
void |
step(long stepMicros,
CollisionResolversManager collisionResolversManager)
Step the simulation = advance the time |
protected abstract void |
stepImpl(long stepMicros)
Step the simulation = advance the time |
void |
update(long gameTime,
long frameTime,
UpdatingThread.TimingMode timingMode)
Updates this Updatable object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SimulationEngine engine
| Constructor Detail |
|---|
public SimulationWorld(SimulationEngine engine)
engine - the simulation engine we belong to| Method Detail |
|---|
public SimulationEngine getEngine()
SimulationEngine.
protected abstract void setGravityImpl(float x,
float y,
float z)
public final void setGravity(float x,
float y,
float z)
x - the gravity to sety - the gravity to setz - the gravity to setpublic final void setGravity(org.openmali.vecmath2.Vector3f gravity)
gravity - the gravity to setpublic void setGravityEnabled(boolean enabled)
enabled - public final boolean isGravityEnabled()
public final org.openmali.vecmath2.Vector3f getGravity()
protected abstract Body newBodyImpl()
public final Body newBody()
protected abstract void addBodyImpl(Body body)
public final void addBody(Body body)
body - the body to be addedprotected abstract void removeBodyImpl(Body body)
public final void removeBody(Body body)
body - the body to be removedpublic final int numBodies()
public final Body getBody(int i)
i - the index of the body
protected JointLimitMotor newJointLimitMotor(float defaultCFM,
float defaultERP)
public final JointLimitMotor newJointLimitMotor()
protected abstract BallJoint newBallJointImpl(Body body1,
Body body2)
body1 - body2 -
public final BallJoint newBallJoint(Body body1,
Body body2)
body1 - body2 -
protected abstract FixedJoint newFixedJointImpl(Body body1,
Body body2)
body1 - body2 -
public final FixedJoint newFixedJoint(Body body1,
Body body2)
body1 - body2 -
protected abstract HingeJoint newHingeJointImpl(Body body1,
Body body2)
body1 - body2 -
public final HingeJoint newHingeJoint(Body body1,
Body body2)
body1 - body2 -
protected abstract Hinge2Joint newHinge2JointImpl(Body body1,
Body body2)
body1 - body2 -
public final Hinge2Joint newHinge2Joint(Body body1,
Body body2)
body1 - body2 -
protected abstract SliderJoint newSliderJointImpl(Body body1,
Body body2)
body1 - body2 -
public final SliderJoint newSliderJoint(Body body1,
Body body2)
body1 - body2 -
protected abstract void addJointImpl(Joint joint)
public final void addJoint(Joint joint)
joint - the joint to be addedprotected abstract void removeJointImpl(Joint joint)
public final void removeJoint(Joint joint)
joint - the joint to be removedpublic final int numJoints()
public final Joint getJoint(int i)
i - the index of the joint
public abstract java.util.Set<java.lang.String> getStepperFunctions()
public abstract void setStepperFunction(java.lang.String stepperFunction)
stepperFunction - the stepper function, it should be
one of the stepper functions proposed by getStepperFunctions()
If stepperFunction is not a valid stepping function, the stepping
function will not be changed.
If stepperFunction is null, the default stepping function will be set.public abstract java.lang.String getStepperFunction()
public final void setStepSize(long micros)
micros - public final long getStepSize()
public final void setMaxStepSize(long micros)
micros - public final long getMaxStepSize()
protected abstract void beforeStep()
stepImpl(long) method is
called.
protected abstract void afterStep()
stepImpl(long) method is
called.
protected abstract void stepImpl(long stepMicros)
stepMicros - the size of the step which should
be taken. Note that 2 steps of .01f isn't equal to
1 step of .02f : the smaller is your stepSize, the
more accurate your simulation (but computations take
more time). As always, you should find a tradeoff
between speed and accuracy (which is the whole point
of physic simulation, anyway).
Begin with .01f and adjust it later if you don't know
what to put.
Note : you could also make the stepSize "adaptative",
ie proportional to the (real) time that has passed since
the last step, but sometimes adaptive stepSize can
cause some simulation problems (jumps, instability).
If you have these problems you could also try to
advance by the right quantity of time by several
fixed size steps.setStepperFunction(String)
public final void step(long stepMicros,
CollisionResolversManager collisionResolversManager)
stepMicros - the size of the step which should
be taken. Note that 2 steps of .01f isn't equal to
1 step of .02f : the smaller is your stepSize, the
more accurate your simulation (but computations take
more time). As always, you should find a tradeoff
between speed and accuracy (which is the whole point
of physic simulation, anyway).
Begin with .01f and adjust it later if you don't know
what to put.
Note : you could also make the stepSize "adaptative",
ie proportional to the (real) time that has passed since
the last step, but sometimes adaptive stepSize can
cause some simulation problems (jumps, instability).
If you have these problems you could also try to
advance by the right quantity of time by several
fixed size steps.setStepperFunction(String)
public abstract void resolveCollision(Collision collision,
Body body1,
Body body2,
SurfaceParameters surfParams)
SimulationWorld, which normally means, that
the two bodies won't interpenetrate (well, if the
constraint is solvable).
You can set one Body to null, it means just one Body
needs to be moved (e.g. when a basket ball hits the
ground, you want the basket ball to react, not the
ground :) ).
collision - body1 - body2 - surfParams -
public final void resolveCollision(Collision collision,
SurfaceParameters surfParams)
SimulationWorld, which normally means, that
the two bodies won't interpenetrate (well, if the
constraint is solvable).
One of the Collideables can have no body, it means just one Body
needs to be moved (e.g. when a basket ball hit the
ground, you want the basket ball to react, not the
ground :) ).
collision - surfParams - public final void setEnabled(boolean enabled)
setEnabled in interface org.jagatoo.datatypes.Enableableenabled - public final boolean isEnabled()
isEnabled in interface org.jagatoo.datatypes.Enableable
public final void update(long gameTime,
long frameTime,
UpdatingThread.TimingMode timingMode)
update in interface UpdatablegameTime - the gameTime in MillisecondsframeTime - the frameTime in Milliseconds (needed time for the last frame)timingMode - the TimingMode to use for frameTime.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||