From 41ed8265a84b6e00aff50f75640abc807b3ffc24 Mon Sep 17 00:00:00 2001 From: Frank v/d Haterd Date: Sun, 22 Dec 2013 16:52:55 +0100 Subject: Helicopter mode seems to be fixed, some changes to FPS view, but not working properly. --- src/Camera.java | 22 +++++++++++++++++----- 1 file 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; -- cgit v1.2.1