]> Dogcows Code - chaz/yoink/blobdiff - src/moof/camera.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / camera.cc
index 093b7d197d93658834b2c954aed5b38ec3f8b00b..95488dbc69bbab43afa1dcfeab0dc5a170f47e06 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "camera.hh"
 #include "opengl.hh"
@@ -30,23 +28,21 @@ void camera::look_at(const vector3& point)
 {
        // FIXME: this doesn't work as expected
        quaternion_rotation_aim_at(state_.orientation, state_.position, point,
-                                                          vector3(0.0, 1.0, 0.0));
+                       vector3(0.0, 1.0, 0.0));
 }
 
-
 void camera::projection(const matrix4& projection)
 {
        projection_ = projection;
 }
 
-void camera::projection(scalar fovy, scalar aspect, scalar abutting,
-                                                  scalar distant)
+void camera::projection(scalar fovy,
+               scalar aspect, scalar abutting, scalar distant)
 {
        matrix_perspective_yfov_RH(projection_, fovy, aspect, abutting,
-                                                                       distant, z_clip_neg_one);
+                       distant, z_clip_neg_one);
 }
 
-
 void camera::upload_to_gl(scalar alpha) const
 {
        calculate(alpha);
@@ -72,7 +68,6 @@ void camera::calculate(scalar alpha) const
        frustum_.init(modelview_, projection_);
 }
 
-
 void camera::update(scalar t, scalar dt)
 {
        rigid_body3::update(t, dt);
@@ -83,66 +78,58 @@ void camera::draw(scalar alpha) const
        sphere_.draw(alpha);
 }
 
-
 void camera::handle_event(const event& event)
 {
        const scalar ds = 50.0;
 
        switch (event.type)
        {
-               case SDL_KEYDOWN:
-                       if (event.key.keysym.sym == SDLK_RIGHT)
-                       {
-                               state_.position[0] -= ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_LEFT)
-                       {
-                               state_.position[0] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_UP)
-                       {
-                               state_.position[1] -= ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_DOWN)
-                       {
-                               state_.position[1] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEUP)
-                       {
-                               state_.position[2] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEDOWN)
-                       {
-                               state_.position[2] -= ds;
-                       }
+       case SDL_KEYDOWN:
+               switch (event.key.keysym.sym)
+               {
+               case SDLK_RIGHT:
+                       state_.position[0] -= ds; break;
+               case SDLK_LEFT:
+                       state_.position[0] += ds; break;
+               case SDLK_UP:
+                       state_.position[1] -= ds; break;
+               case SDLK_DOWN:
+                       state_.position[1] += ds; break;
+               case SDLK_PAGEUP:
+                       state_.position[2] += ds; break;
+               case SDLK_PAGEDOWN:
+                       state_.position[2] -= ds; break;
+               default:
                        break;
+               }
+               break;
 
-               case SDL_MOUSEMOTION:
-                       {
-                               scalar xrel = rad(scalar(event.motion.xrel) / 6.0);
-                               scalar yrel = rad(scalar(event.motion.yrel) / 6.0);
+       case SDL_MOUSEMOTION:
+       {
+               scalar xrel = rad(scalar(event.motion.xrel) / 6.0);
+               scalar yrel = rad(scalar(event.motion.yrel) / 6.0);
 
-                               quaternion rotation = state_.orientation;
+               quaternion rotation = state_.orientation;
 
-                               quaternion_rotate_about_world_x(rotation, yrel);
-                               //mRotation.normalize();
-                               quaternion_rotate_about_world_y(rotation, xrel);
+               quaternion_rotate_about_world_x(rotation, yrel);
+               //mRotation.normalize();
+               quaternion_rotate_about_world_y(rotation, xrel);
 
-                               rotation.normalize();
-                               state_.orientation = rotation;
-                       }
-                       break;
+               rotation.normalize();
+               state_.orientation = rotation;
+               break;
+       }
 
-               case SDL_MOUSEBUTTONDOWN:
-                       if (event.button.button == SDL_BUTTON_WHEELUP)
-                       {
-                               state_.position[2] -= ds;
-                       }
-                       else if (event.button.button == SDL_BUTTON_WHEELDOWN)
-                       {
-                               state_.position[2] -= ds;
-                       }
+       case SDL_MOUSEBUTTONDOWN:
+               switch (event.button.button)
+               {
+               case SDL_BUTTON_WHEELUP:
+                       state_.position[2] -= ds;
+                       break;
+               case SDL_BUTTON_WHEELDOWN:
+                       state_.position[2] += ds;
                        break;
+               }
        }
 }
 
This page took 0.026213 seconds and 4 git commands to generate.