Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
committerStijn Buys <ingar@osirion.org>2008-02-09 17:48:16 +0000
commit48aa068b036f565d6b94d4207242066ba655afe4 (patch)
tree4b68cf169c7fcd4bc6f2eecc7c072830d91830f8 /src/client/camera.cc
parent23aee34002facf39b56d209320817375db3b6189 (diff)
entities, step 1
Diffstat (limited to 'src/client/camera.cc')
-rw-r--r--src/client/camera.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index c1ceaa9..45cd65a 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -22,8 +22,9 @@ namespace camera
// public variables
-// camera target
+// gameworld coordinates of the camera target
math::Vector3f target;
+
// target yaw, angle in XZ plane, positive is looking left
float yaw_target;
// target pitch, angle in XZ plane, positive is looking left
@@ -71,7 +72,7 @@ void draw(float elapsed)
{
// TODO camera needs to get this from selected core entity
if (mode == Track) {
- yaw_target = game.ship.yaw();
+ yaw_target = game.ship->yaw();
}
// adjust yaw
@@ -87,37 +88,40 @@ void draw(float elapsed)
gl::translate(1.0f+distance, -distance/2, 0.0f);
gl::rotate(-pitch_current, 0, 0, 1.0f);
gl::rotate(-yaw_current, 0, 1.0f, 0);
+ gl::translate(-1*target);
break;
case Track:
gl::translate(1.0f+distance, -distance , 0.0f);
gl::rotate(-pitch_current, 0, 0, 1.0f);
gl::rotate(-yaw_current, 0, 1.0f, 0);
+ gl::translate(-1*target);
break;
case Overview:
gl::translate(-distance/2, -distance, 0.0f);
gl::rotate(-pitch_current, 0, 0, 1.0f);
gl::rotate(-yaw_current, 0, 1.0f, 0);
+ gl::translate(-1*target);
break;
default:
break;
}
}
-void rotate_right()
+void key_right()
{
if (mode == Free || mode == Overview) {
yaw_target = degrees360f( yaw_target + offset_inc);
}
}
-void rotate_left()
+void key_left()
{
if (mode == Free || mode == Overview) {
yaw_target = degrees360f( yaw_target - offset_inc);
}
}
-void rotate_up()
+void key_up()
{
if (mode == Free) {
pitch_target = pitch_target - offset_inc;
@@ -125,7 +129,7 @@ void rotate_up()
}
}
-void rotate_down()
+void key_down()
{
if (mode == Free) {
pitch_target = pitch_target + offset_inc;
@@ -133,12 +137,12 @@ void rotate_down()
}
}
-void nextmode() {
+void next_mode() {
switch(mode) {
case Overview:
// switch camera to Track mode
mode = Track;
- yaw_target = game.ship.yaw();
+ yaw_target = game.ship->yaw();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;
@@ -147,7 +151,7 @@ void nextmode() {
case Track:
// switch camera to Free mode
mode = Free;
- yaw_target = game.ship.yaw();
+ yaw_target = game.ship->yaw();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;