Changeset 5339


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

Fixed frame controls

Location:
anuga_work/development/anugavis/src
Files:
8 edited

Legend:

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

    r5292 r5339  
    1414    return 1;
    1515  }
    16 /*   if(AnugaVis_DefineHeightQuantity("elevation", 0.0, 1.0, 0.5, 0.5, 0.5) == -1){ */
    17 /*     printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError()); */
    18 /*     return 1; */
    19 /*   } */
    20   if(AnugaVis_DefineHeightQuantity("stage", -0.01, 1.0, 0.0, 0.0, 0.5) == -1){
     16  if(AnugaVis_DefineHeightQuantity("stage", 0.0, 1.0, 0.0, 0.0, 0.5) == -1){
     17    printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError());
     18    return 1;
     19  }
     20  if(AnugaVis_DefineHeightQuantity("elevation", 0.0, 1.0, 0.5, 0.5, 0.5) == -1){
    2121    printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError());
    2222    return 1;
  • anuga_work/development/anugavis/src/camera.c

    r5330 r5339  
    7070  vadd(anugavis.focus, dir, anugavis.focus);
    7171}
     72
     73void camera_strafe(float dist){
     74  vector releye;
     75  vector dir;
     76  vsub(anugavis.eye, anugavis.focus, releye);
     77  vcross(releye, up, dir);
     78  vscale(dir, dist/vlen(dir), dir);
     79  vadd(anugavis.eye, dir, anugavis.eye);
     80  vadd(anugavis.focus, dir, anugavis.focus);
     81}
  • anuga_work/development/anugavis/src/camera.h

    r5330 r5339  
    44#define CAMERA_YAW_STEP 0.1
    55#define CAMERA_PITCH_STEP 0.1
    6 #define CAMERA_TRACK_STEP 1.0
    7 #define CAMERA_STRAFE_STEP 0.1
     6#define CAMERA_TRACK_STEP 2.0
     7#define CAMERA_STRAFE_STEP 2.0
    88
    9 void camera_pitch(float theta);
    10 void camera_yaw(float theta);
    11 void camera_track(float dist);
     9extern void camera_pitch(float theta);
     10extern void camera_yaw(float theta);
     11extern void camera_track(float dist);
     12extern void camera_strafe(float dist);
    1213
    1314#endif
  • 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;
  • anuga_work/development/anugavis/src/events.h

    r5330 r5339  
    11#ifndef EVENTS_H
    22#define EVENTS_H
     3
     4#define FRAME_INTERVAL 100
    35
    46typedef enum {KEY_FORWARD = 0,
  • anuga_work/development/anugavis/src/globals.h

    r5330 r5339  
    2626  size_t number_of_volumes;
    2727  size_t number_of_timesteps;
    28   size_t current_frame;
     28  Sint32 current_frame;
     29  uint8_t paused;
    2930  float *x;
    3031  float *y;
  • anuga_work/development/anugavis/src/init.c

    r5330 r5339  
    2929  GLfloat lightDiffuse[] = {1.0, 1.0, 1.0, 1.0};
    3030  anugavis.current_frame = 0;
     31  anugavis.paused = 0;
    3132  anugavis.x = NULL;
    3233  anugavis.y = NULL;
  • anuga_work/development/anugavis/src/vector.h

    r5330 r5339  
    44typedef float vector[3];
    55/* Useful vector operations. */
    6 void vadd(const vector v1, const vector v2, vector result);
    7 float vlen(const vector v);
    8 void vscale(const vector v, const float scale, vector result);
    9 void vsub(const vector v1, const vector v2, vector result);
    10 float vdot(const vector v1, const vector v2);
    11 void vcross(const vector v1, const vector v2, vector result);
     6extern void vadd(const vector v1, const vector v2, vector result);
     7extern float vlen(const vector v);
     8extern void vscale(const vector v, const float scale, vector result);
     9extern void vsub(const vector v1, const vector v2, vector result);
     10extern float vdot(const vector v1, const vector v2);
     11extern void vcross(const vector v1, const vector v2, vector result);
    1212
    1313#endif
Note: See TracChangeset for help on using the changeset viewer.