summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-22 16:52:55 +0100
committerFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-22 16:52:55 +0100
commit41ed8265a84b6e00aff50f75640abc807b3ffc24 (patch)
tree1b188b815fbc4a07117f6f2746f7001a237adfc2
parent043b180cdcd033725c48a9fb5a0829236044da07 (diff)
download2iv60-robots-41ed8265a84b6e00aff50f75640abc807b3ffc24.tar.gz
Helicopter mode seems to be fixed, some changes to FPS view, but not working properly.
-rw-r--r--src/Camera.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/Camera.java b/src/Camera.java
index 23c5c8b..d2e4c4f 100644
--- a/src/Camera.java
+++ b/src/Camera.java
@@ -110,9 +110,15 @@ class Camera {
// center at the chosen robot.
center = track.getPointForLane(focus.getTimePos(), focus.getLane());
- // look in the direction where the robots walks, namely the tangent
- // FIXME: getTangent() is broken, or this snippet is wrong.
- up = track.getTangent(focus.getTimePos());
+ /* look in the direction where the robots walks, namely the tangent
+ Add the actual robot position to the tangent vector, and calculate
+ the normal vector based on the resulting vector. This is the up vector. */
+ Vector robotPos = track.getPointForLane(focus.getTimePos(),
+ focus.getLane());
+ Vector robotTangent = track.getTangent(focus.getTimePos());
+ Vector totalVector = robotTangent.add(robotPos);
+
+ up = new Vector(-totalVector.y(), totalVector.x(), 0);
// "above" is 10 meters.
eye = center.add(new Vector(0, 0, 10f));
@@ -154,12 +160,18 @@ class Camera {
// trivial: looks from the robot POV.
eye = track.getPointForLane(focus.getTimePos(), focus.getLane());
// robots are two meter, look from head.
- eye.add(new Vector(0, 0, 2));
+ eye.add(new Vector(0, 0, 3f));
// The question is similar to question 2b of the intermediate test
// http://www.win.tue.nl/~vanwijk/2IV60/2IV60_test_exam_161213_answers.pdf
// C(t) = E(t) + P'(t) (P'(t) is the tangent vector).
- center = center.add(track.getTangent(focus.getTimePos()));
+ Vector robotTangent = track.getTangent(focus.getTimePos());
+ Vector robotPos = track.getPointForLane(focus.getTimePos(),
+ focus.getLane());
+
+ Vector centerPoint = robotPos.add(robotTangent);
+
+ center = new Vector(-centerPoint.y(), centerPoint.x(), 3f);
// trivial: look forward, so up vector points up.
up = Vector.Z;