Permalink
Browse files

enable up and down

  • Loading branch information...
1 parent f062157 commit 4f35054ef0f8d715ff842873771376a756713298 @shiryehoshua committed Mar 14, 2012
Showing with 26 additions and 42 deletions.
  1. +2 −18 callbacks.c
  2. +24 −24 matrixFunctions.c
View
20 callbacks.c
@@ -118,28 +118,12 @@ void callbackKeyboard(int key, int action)
// Rotate around the U-axis of the viewport
case UP:
- v = 0.125;
- if (gctx->modelMode) {
- rotate_model_U(0.05);
- } else if (gctx->lightMode) {
- rotate_spotlight_U(v);
- } else {
- rotate_view_U(v);
- rotate_spotlight_U(v);
- }
+ updateScene(gctx->time, 1);
break;
// Rotate around the U-axis of the viewport
case DOWN:
- v= -0.125;
- if (gctx->modelMode) {
- rotate_model_U(-0.05);
- } else if (gctx->lightMode) {
- rotate_spotlight_U(v);
- } else {
- rotate_view_U(v);
- rotate_spotlight_U(v);
- }
+ updateScene(gctx->time, -1);
break;
// Rotate around the V-axis of the viewport
View
48 matrixFunctions.c
@@ -672,30 +672,30 @@ void updateScene(GLfloat time, GLfloat dt)
gctx->time += dt;
if (gctx->time >= 5.0) { gctx->time = 0.0f; }
- GLfloat s=-1.25;
- GLfloat r=2 * M_PI;
- // SPLINE from keyframe 0 => 2
- if (floor(time)>=0 && ceil(time)<=2) {
- GLfloat t=0.5*s;
- translate_view_N(gctx->camera.uvn, &t, 0); // 1x dist. w/ 2x time
- }
- // LINEAR RAMP from keyframe 1 => 2
- if (floor(time)>=1 && ceil(time)<=2) {
- rotate_view_U(r); // 360*
- }
- // LINEAR RAMP from keyframe 2 => 4
- if (floor(time)>=2 && ceil(time)<=4) {
- rotate_view_V(r); // 360*
- }
- // SPLINE from keyframe 3 => 4
- if (floor(time)>=3 && ceil(time)<=4) {
- GLfloat t=(-2) * s;
- translate_view_N(gctx->camera.uvn, &t, 0); // 2x dist. w/ 1x time
- }
- // LINEAR RAMP from keyfram 4 => 5
- if (floor(time)>=4 && ceil(time)<=5) {
- translate_view_N(gctx->camera.uvn, &s, 0); // 1x dist. w/ 1x time
- }
+ GLfloat s=-1.25;
+ GLfloat r=2 * M_PI;
+ // SPLINE from keyframe 0 => 2
+ if (floor(time)>=0 && ceil(time)<=2) {
+ GLfloat t=0.5*s;
+ translate_view_N(gctx->camera.uvn, &t, 0); // 1x dist. w/ 2x time
+ }
+ // LINEAR RAMP from keyframe 1 => 2
+ if (floor(time)>=1 && ceil(time)<=2) {
+ rotate_view_U(r); // 360*
+ }
+ // LINEAR RAMP from keyframe 2 => 4
+ if (floor(time)>=2 && ceil(time)<=4) {
+ rotate_view_V(r); // 360*
+ }
+ // SPLINE from keyframe 3 => 4
+ if (floor(time)>=3 && ceil(time)<=4) {
+ GLfloat t=(-2) * s;
+ translate_view_N(gctx->camera.uvn, &t, 0); // 2x dist. w/ 1x time
+ }
+ // LINEAR RAMP from keyfram 4 => 5
+ if (floor(time)>=4 && ceil(time)<=5) {
+ translate_view_N(gctx->camera.uvn, &s, 0); // 1x dist. w/ 1x time
+ }
}
/* Normalize homogenous coordinates */

0 comments on commit 4f35054

Please sign in to comment.