summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-19 17:15:44 +0100
committerFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-19 17:15:44 +0100
commit0b52e0bc22639cba23b35e025c1459d33ea7c2fb (patch)
tree75232f9cfd3cdd7ab3c597bba6efa381cb721ac9
parent358d62d2b2a86e40add139b621e47715eb582251 (diff)
download2iv60-robots-0b52e0bc22639cba23b35e025c1459d33ea7c2fb.tar.gz
Camera helicopter WIP works part
-rw-r--r--src/Camera.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/Camera.java b/src/Camera.java
index 2ebdaa6..fb6df32 100644
--- a/src/Camera.java
+++ b/src/Camera.java
@@ -16,14 +16,23 @@ class Camera {
/** The up vector. */
public Vector up = Vector.Z;
+
+ /** The array with robot positions. */
+ private double[] robotPositions;
+
+ /** Race track used. */
+ private RaceTrack track;
/**
* A reference to the global game state from RobotRace.
*/
private final GlobalState gs;
- public Camera(GlobalState gs) {
+ public Camera(GlobalState gs, double[] positions, RaceTrack track) {
+ // Set the global state and the robot positions and track
this.gs = gs;
+ this.robotPositions = positions;
+ this.track = track;
}
/**
@@ -88,7 +97,29 @@ class Camera {
* on the helicopter mode.
*/
private void setHelicopterMode() {
- // code goes here ...
+ // Choose a robot to view
+ int robot = 0;
+
+ /*
+ * First get the inner track position of a robot, then multiply this
+ * vector so that we have the actual position on the track.
+ *
+ * Add this lane position to the start position and we have the actual
+ * robot position.
+ */
+ Vector startPosition = track.getPoint(robotPositions[robot]);
+ Vector lanePosition = new Vector(startPosition.x(), startPosition.y(), 0)
+ .normalized().scale(robot + 1);
+ Vector robotPosition = startPosition.add(lanePosition);
+
+ // Set the up vector to equal the tangent of the robot
+ up = track.getTangent(robotPositions[robot]);
+
+ // Set the center point to the actual robot position.
+ center = robotPosition;
+
+ // Set the eye point to the center point, then increased height
+ eye = new Vector(center.x(), center.y(), 10f);
}
/**