|
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.Spring
public class Spring
The Spring class represents a spring constraint on two bodies body.
The constraint connects two bodies by a spring.
It fixes the distance of two points relative to two bodies like a physical spring.
The spring constant can be adjusted.
A fixed mode is also possible, where no slack is allowed.
Field Summary | |
---|---|
protected float |
mCoefficientFX
The spring coefficient (0 = no spring) FX |
protected UserData |
mUserData
User data |
Fields inherited from interface at.emini.physics2D.Constraint |
---|
JOINT, MOTOR, SCRIPT, SPRING |
Constructor Summary | |
---|---|
|
Spring(Body b1,
Body b2,
FXVector p1,
FXVector p2,
int distance)
Constructor. |
protected |
Spring(Spring other,
Body[] bodyMapping)
Copy constructor. |
Method Summary | |
---|---|
boolean |
applyMomentum(float invTimestepFX)
Applies the momentum of the constraint. |
protected void |
calcDistance()
Calculates the default distance. |
boolean |
concernsBody(Body b)
Checks if the spring is applied to a body. |
Constraint |
copy(Body[] bodyMapping)
Copies the spring. |
boolean |
equals(Constraint other)
Checks for equality of two constraints. |
Body |
getBody1()
Gets the first body. |
Body |
getBody2()
Gets the second body. |
float |
getCoefficientFX()
Gets the spring coefficient. |
int |
getDistance()
Returns the default distance of the spring. |
float |
getDistanceFX()
Returns the default distance of the spring (FX). |
float |
getImpulseFX()
Gets the last applied impulse. |
FXVector |
getPoint1()
Gets the absolute position of point 1. |
void |
getPoint1(FXVector target)
Gets the absolute position of point 1. |
FXVector |
getPoint2()
Gets the absolute position of point 2. |
void |
getPoint2(FXVector target)
Gets the absolute position of point 2. |
FXVector |
getRawPoint1()
Gets the relative position of point 1. |
FXVector |
getRawPoint2()
Gets the relative position of point 2. |
UserData |
getUserData()
Get user data. |
static Spring |
loadSpring(PhysicsFileReader reader,
java.util.Vector bodies,
UserData userData)
Loads a spring from a stream. |
void |
postStep()
Empty. |
void |
precalculate(float invTimestepFX)
Precalculates the values for the constraint solver iteration. |
protected void |
setAbsolutePoint1(FXVector absolutePoint)
Sets the first absolute anchor position. |
protected void |
setAbsolutePoint2(FXVector absolutePoint)
Sets the second absolute anchor position. |
protected void |
setBody1(Body body1)
Sets the first body. |
protected void |
setBody2(Body body2)
Sets the second body. |
void |
setCoefficient(int coeff)
Sets the spring coefficient. |
void |
setCoefficientFX(float coeffFX)
Sets the spring coefficient (FX). |
void |
setCollisionLayer(int layer)
Sets collision layers for joined bodies. |
void |
setDistanceFX(float distanceFX)
Sets the default distance of the spring (FX). |
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 float mCoefficientFX
protected UserData mUserData
Constructor Detail |
---|
public Spring(Body b1, Body b2, FXVector p1, FXVector p2, int distance)
b1
- Body 1.b2
- Body 2.p1
- relative point 1.p2
- relative point 2.distance
- default distance of the spring.
If -1 is passed, the distance is computed from the current body positions.protected Spring(Spring other, Body[] bodyMapping)
other
- the source spring object.bodyMapping
- the mapping of bodies in the new world (null if not used).Method Detail |
---|
public Constraint copy(Body[] bodyMapping)
copy
in interface Constraint
bodyMapping
- the mapping of bodies in the new world (null if not used).
public static Spring loadSpring(PhysicsFileReader reader, java.util.Vector bodies, UserData userData)
reader
- the file reader.bodies
- the list of bodies that is references by indices in the stream.
protected void calcDistance()
public void setCoefficient(int coeff)
coeff
- the coefficient.mCoefficientFX
public void setCoefficientFX(float coeffFX)
coeffFX
- the coefficient (FX)mCoefficientFX
public float getCoefficientFX()
mCoefficientFX
)mCoefficientFX
public void setCollisionLayer(int layer)
layer
- the layer number (somewhere between 0 and 32).Body.mColissionBitFlag
public FXVector getPoint1()
public void getPoint1(FXVector target)
target
- the target vectorpublic FXVector getPoint2()
public void getPoint2(FXVector target)
target
- the target vectorpublic FXVector getRawPoint1()
public FXVector getRawPoint2()
public Body getBody1()
public Body getBody2()
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 int getDistance()
public float getDistanceFX()
public void setDistanceFX(float distanceFX)
distanceFX
- the new distance (FX) of the spring.public float getImpulseFX()
getImpulseFX
in interface Constraint
public boolean concernsBody(Body b)
concernsBody
in interface Constraint
b
- the body to be checked.
public boolean equals(Constraint other)
equals
in interface Constraint
other
- the comparison constraint.
protected void setBody1(Body body1)
body1
- the body.protected void setBody2(Body body2)
body2
- the body.protected void setAbsolutePoint1(FXVector absolutePoint)
absolutePoint
- the absolute position.protected void setAbsolutePoint2(FXVector absolutePoint)
absolutePoint
- the absolute position.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 |