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/alden/HalfSpace.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/alden/HalfSpace.java')
-rw-r--r-- | src/alden/HalfSpace.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/alden/HalfSpace.java b/src/alden/HalfSpace.java new file mode 100644 index 0000000..efab5ea --- /dev/null +++ b/src/alden/HalfSpace.java @@ -0,0 +1,28 @@ +package alden;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+
+@SuppressWarnings("restriction")
+public class HalfSpace extends CollidableObject {
+ protected Vector3f normal;
+ // Right-hand side of the plane equation: Ax + By + Cz = D
+ protected float intercept;
+
+ public HalfSpace(Vector3f position, Vector3f normal) {
+ super(Float.POSITIVE_INFINITY);
+ this.position.set(position);
+ this.normal = new Vector3f(normal);
+ this.normal.normalize();
+ intercept = this.normal.dot(position);
+ }
+
+/* public CollisionInfo calculateCollision(Particle particle) {
+ if (Math.signum(normal.dot(particle.getPosition()) - intercept) == Math.signum(normal.dot(particle.getPreviousPosition()) - intercept))
+ return null;
+
+ Vector3f projection = new Vector3f();
+ projection.scaleAdd(-1, position, particle.getPosition());
+ float penetration = -projection.dot(normal);
+ return new CollisionInfo(normal, penetration);
+ }*/
+}
|