diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-02-11 18:53:32 +0000 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2011-02-11 18:53:32 +0000 |
commit | 354041e8d61571b25c6eeb672537a013d3e0fa60 (patch) | |
tree | 0ddd07f6fa6867148e3e8c75155c10a238ccd42c /src/tesseract/objects/ForceableObject.java | |
parent | 39662ca98a4ea3de28d5ef4c113435d591ec471c (diff) |
Broke the grabbing code but added Alden's collision code. Not sure if its working yet since my Mac doesn't like it.
Diffstat (limited to 'src/tesseract/objects/ForceableObject.java')
-rw-r--r-- | src/tesseract/objects/ForceableObject.java | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/tesseract/objects/ForceableObject.java b/src/tesseract/objects/ForceableObject.java deleted file mode 100644 index b918452..0000000 --- a/src/tesseract/objects/ForceableObject.java +++ /dev/null @@ -1,90 +0,0 @@ -package tesseract.objects; - -import java.util.List; - -import javax.vecmath.Vector3f; - -/** - * This class is the an abstract parent class for forceable objects. - * - * @author Jesse Morgan - */ -public abstract class ForceableObject - extends PhysicalObject implements Forceable { - /** - * The inverse of the object's mass. - */ - protected float myInverseMass; - - /** - * Object's velocity. - */ - private Vector3f myVelocity; - - /** - * Sum of all the forces affecting this object. - */ - private Vector3f myForces; - - /** - * Construct a new ForceableObject. - * - * @param position Initial Position. - * @param mass Initial Mass. - */ - public ForceableObject(final Vector3f position, final float mass) { - super(position); - - myInverseMass = 1 / mass; - myVelocity = new Vector3f(0, 0, 0); - myForces = new Vector3f(0, 0, 0); - } - - /** - * @return The inverse mass of the object. - */ - public float getInverseMass() { - return myInverseMass; - } - - /** - * @return Get the velocity of the object. - */ - public Vector3f getVelocity() { - return myVelocity; - } - - /** - * Apply a new force to this object. - * @param force The force to apply. - */ - public void addForce(final Vector3f force) { - myForces.add(force); - } - - /** - * Update the state of the forceable object. - * - * @param duration The length of time that has passed. - * @return A list of new objects to add to the world. - */ - public List<PhysicalObject> updateState(final float duration) { - List<PhysicalObject> children = super.updateState(duration); - - // The force vector now becomes the acceleration vector. - myForces.scale(myInverseMass); - myPosition.scaleAdd(duration, myVelocity, myPosition); - myPosition.scaleAdd(duration * duration / 2, myForces, myPosition); - myVelocity.scaleAdd(duration, myForces, myVelocity); - - // The force vector is cleared. - myForces.x = 0; - myForces.y = 0; - myForces.z = 0; - - updateTransformGroup(); - - return children; - } - -} |