Ignore:
Timestamp:
May 16, 2008, 4:17:15 PM (16 years ago)
Author:
jack
Message:

Fixed frame controls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/events.c

    r5330 r5339  
    1919#include "height_quantity.h"
    2020
     21#define MIN(a, b) ((a) < (b) ? (a) : (b))
     22#define MAX(a, b) ((a) > (b) ? (a) : (b))
     23
    2124int AnugaVis_Step(void){
     25  static Uint32 ticks = 0;
     26  static Uint32 lastframe;
    2227  GLfloat lightpos[4];
    2328  int i;
     
    2530  int more = 1;
    2631  struct height_quantity_simple *height;
     32
     33  /* Animation. */
     34  /* FIXME needs to respect pause. */
     35  if(ticks == 0) lastframe = ticks = SDL_GetTicks();
     36  else ticks = SDL_GetTicks();
     37  if(ticks - lastframe >= FRAME_INTERVAL){
     38    lastframe = ticks;
     39    if(anugavis.current_frame < (signed int)anugavis.number_of_timesteps - 1){
     40      if(!anugavis.paused) anugavis.current_frame++;
     41    }else
     42      anugavis.paused = 1;
     43  }
    2744
    2845  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    3552  if(anugavis.keys[KEY_FORWARD]) camera_track(-CAMERA_TRACK_STEP);
    3653  if(anugavis.keys[KEY_BACKWARD]) camera_track(CAMERA_TRACK_STEP);
     54  if(anugavis.keys[KEY_STRAFE_LEFT]) camera_strafe(CAMERA_STRAFE_STEP);
     55  if(anugavis.keys[KEY_STRAFE_RIGHT]) camera_strafe(-CAMERA_STRAFE_STEP);
    3756  gluLookAt(anugavis.eye[0], anugavis.eye[1], anugavis.eye[2],
    3857            anugavis.focus[0], anugavis.focus[1], anugavis.focus[2],
     
    5776        }
    5877      else switch(event.key.keysym.sym){
    59         case SDLK_b:
     78        case SDLK_z:
     79          anugavis.current_frame = MAX(anugavis.current_frame - 10, 0);
     80          break;
     81        case SDLK_x:
    6082          if(anugavis.current_frame > 0) anugavis.current_frame--;
    6183          break;
    62         case SDLK_f:
    63           if(anugavis.current_frame < anugavis.number_of_timesteps - 1)
     84        case SDLK_c:
     85        case SDLK_SPACE: anugavis.paused = !anugavis.paused; break;
     86        case SDLK_v:
     87          if(anugavis.current_frame <
     88             (signed int)anugavis.number_of_timesteps - 1)
    6489            anugavis.current_frame++;
     90          break;
     91        case SDLK_b:
     92          anugavis.current_frame = MIN(anugavis.current_frame + 10,
     93                                       (signed int)anugavis.number_of_timesteps
     94                                       - 1);
    6595          break;
    6696        case SDLK_ESCAPE: more = 0; break;
Note: See TracChangeset for help on using the changeset viewer.