|
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.Motor
public class Motor
The Motor class represents a motor constraint for a body.
The constraint is applied to a single body.
The body is held at a constant velocity (either translational or rotational)
with a maximum force.
If the force is not sufficient, the body slows down.
This can happen if the body collides with a wall or has to work against gravity.
If one direction of the target velocities is zero (for translational),
it is not considered.
That means that the body behaves unconstrained in that direction.
Field Summary | |
---|---|
protected UserData |
mUserData
User data |
Fields inherited from interface at.emini.physics2D.Constraint |
---|
JOINT, MOTOR, SCRIPT, SPRING |
Constructor Summary | |
---|---|
Motor(Body b,
float targetRotation2FX,
float maxForceFX)
Constructor for a rotational motor. |
|
Motor(Body b,
float targetXFX,
float targetYFX,
float maxForceFX)
Constructor for a translational motor. |
|
Motor(Motor other,
Body[] bodyMapping)
Copy constructor. |
Method Summary | |
---|---|
boolean |
applyMomentum(float invTimestepFX)
Applies the impulse of the motor. |
Body |
body()
Gets the body, that the motor applies to. |
boolean |
concernsBody(Body b)
Checks if the constraint applies to a body. |
Constraint |
copy(Body[] bodyMapping)
Copies the motor constraint. |
boolean |
equals(Constraint other)
Checks for equality of two constraints. |
float |
getImpulseFX()
Gets the last impulse. |
float |
getMaxForceFX()
Gets the maximum force. |
protected float |
getTargetAFX()
gets the target X. |
protected float |
getTargetBFX()
gets the target Y. |
UserData |
getUserData()
Get user data. |
boolean |
isFixOrthogonal()
Checks if the orthogonal movement is treated as well by the motor. |
boolean |
isRelative()
Checks if the velocity is applied relative. |
boolean |
isRotation()
Checks if the constraint type is rotation. |
static Motor |
loadMotor(PhysicsFileReader reader,
java.util.Vector bodies,
UserData userData)
Loads a motor from a stream. |
void |
postStep()
Empty. |
void |
precalculate(float invTimestepFX)
Performs the warmstarting. |
protected void |
setFixOrthogonal(boolean fixOrthogonal)
Sets the fix orthogonal flag. |
protected void |
setIsRelative(boolean isRelative)
Sets the relative flag. |
void |
setMaxForceFX(float maxForceFX)
Sets the maximum force. |
void |
setParameter(float targetAFX,
float targetBFX,
boolean rotate,
boolean isRelative,
boolean isOrthogonal)
Sets the motor parameters directly. |
protected void |
setRotation(boolean isRotation)
Sets the rotation mode. |
protected void |
setTargetAFX(float targetAFX)
Sets the target velocity X. |
protected void |
setTargetBFX(float targetBFX)
Sets the target velocity Y. |
void |
setUserData(UserData userData)
Set User data |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected UserData mUserData
Constructor Detail |
---|
public Motor(Body b, float targetRotation2FX, float maxForceFX)
b
- the body that is affected by the motor.targetRotation2FX
- the target angular velocity (2FX).maxForceFX
- the maximum force that the motor can apply (FX).public Motor(Body b, float targetXFX, float targetYFX, float maxForceFX)
b
- the body that is affected by the motor.targetXFX
- the target speed in x direction (FX).targetYFX
- the target speed in y direction (FX).maxForceFX
- the maximum force that the motor can apply (FX).public Motor(Motor other, Body[] bodyMapping)
other
- the motor constraint to copy.bodyMapping
- the mapping of bodies in the new world (null if not used).Method Detail |
---|
public void setParameter(float targetAFX, float targetBFX, boolean rotate, boolean isRelative, boolean isOrthogonal)
targetAFX
- the x velocity component or rotational velocity.targetBFX
- the y velocity component.rotate
- whether the motor is rotational of translational.isRelative
- if not rotate: whether the motor is working in absolute coordinates or relative to the body it's applied to.isOrthogonal
- if not rotate: whether the motor forces the orthogonal direction to zero.public Constraint copy(Body[] bodyMapping)
copy
in interface Constraint
bodyMapping
- A mapping of the body indices from the old world to the new
public static Motor loadMotor(PhysicsFileReader reader, java.util.Vector bodies, UserData userData)
reader
- the physics reader.bodies
- the body vector with the correct indexing.
public void precalculate(float invTimestepFX)
precalculate
in interface Constraint
invTimestepFX
- the inverse timestep of the simulationpublic boolean applyMomentum(float invTimestepFX)
applyMomentum
in interface Constraint
invTimestepFX
- the inverse timestep of the simulationpublic void postStep()
postStep
in interface Constraint
public boolean concernsBody(Body b)
concernsBody
in interface Constraint
b
- the body the check.
public boolean equals(Constraint other)
equals
in interface Constraint
other
- the other constraint to check.
public float getImpulseFX()
getImpulseFX
in interface Constraint
public Body body()
public boolean isRotation()
public boolean isRelative()
public boolean isFixOrthogonal()
public float getMaxForceFX()
protected float getTargetAFX()
protected float getTargetBFX()
protected void setTargetAFX(float targetAFX)
targetAFX
- the x component of the target velocity.protected void setTargetBFX(float targetBFX)
targetBFX
- the x component of the target velocity.public void setMaxForceFX(float maxForceFX)
maxForceFX
- the maximum allowed force by the motor.protected void setRotation(boolean isRotation)
isRotation
- the rotation mode.protected void setIsRelative(boolean isRelative)
isRelative
- flag whether to apply the velocity relative.protected void setFixOrthogonal(boolean fixOrthogonal)
fixOrtogonal
- flag deciding whether to apply the orthogonal correction.public UserData getUserData()
getUserData
in interface Constraint
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 |