Changeset 5380


Ignore:
Timestamp:
May 29, 2008, 4:00:58 PM (16 years ago)
Author:
jack
Message:

Dynamic camera positioning.

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

Legend:

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

    r5379 r5380  
    1414
    1515static const vector up = {0.0, 0.0, 1.0};
    16 #include <stdio.h>
     16
    1717void camera_pitch(float theta){
    1818  float c = cos(theta);
  • anuga_work/development/anugavis/src/events.c

    r5379 r5380  
    1818#include "globals.h"
    1919#include "height_quantity.h"
    20 
    21 #define MIN(a, b) ((a) < (b) ? (a) : (b))
    22 #define MAX(a, b) ((a) > (b) ? (a) : (b))
    2320
    2421/* Called for each SDL_KEYDOWN or SDL_KEYUP event. Returns 1 if we're not stopping, else 0. */
  • anuga_work/development/anugavis/src/globals.h

    r5339 r5380  
    1818#include "height_quantity.h"
    1919
     20#define MIN(a, b) ((a) < (b) ? (a) : (b))
     21#define MAX(a, b) ((a) > (b) ? (a) : (b))
     22
    2023typedef struct{
    2124  SDL_Surface *screen;
     
    3235  int *volumes;
    3336
    34   GLfloat pitch;
    35   GLfloat yaw;
    36   /* track is forward/back motion, strafe is side/side motion */
    37   GLfloat track;
    38   GLfloat strafe;
     37  /* Extents */
     38  double minX;
     39  double maxX;
     40  double minY;
     41  double maxY;
     42
    3943  GLfloat eye[3];
    4044  GLfloat focus[3];
  • anuga_work/development/anugavis/src/init.c

    r5339 r5380  
    2222#include "init.h"
    2323#include "netcdf_util.h"
     24#include "vector.h"
    2425#include "xfunctions.h"
    2526
    2627int AnugaVis_Init(int width, int height, const char *swwFilePath){
    2728  int ncstatus;
     29  vector releye;
     30  unsigned int i;
    2831  GLfloat lightAmbient[] = {0.0, 0.0, 0.0, 1.0};
    2932  GLfloat lightDiffuse[] = {1.0, 1.0, 1.0, 1.0};
     
    3437  anugavis.volumes = NULL;
    3538
    36   anugavis.pitch = 0.0;
    37   anugavis.yaw = 0.0;
    38   anugavis.track = 0.0;
    39   anugavis.strafe = 0.0;
    40   /* FIXME derive this from the dataset? */
    41   anugavis.eye[0] = 1.0;
    42   anugavis.eye[1] = 1.0;
    43   anugavis.eye[2] = 40.0;
    44   anugavis.focus[0] = 0.0;
    45   anugavis.focus[1] = 0.0;
    46   anugavis.focus[2] = 0.0;
    4739  anugavis.heights = NULL;
    4840  if((SDL_Init(SDL_INIT_VIDEO) == -1) ||
     
    10496    return -1;
    10597  }
     98
     99  for(i = 0 ; i < anugavis.number_of_points ; i++){
     100    anugavis.minX = MIN(anugavis.minX, anugavis.x[i]);
     101    anugavis.maxX = MAX(anugavis.maxX, anugavis.x[i]);
     102    anugavis.minY = MIN(anugavis.minY, anugavis.y[i]);
     103    anugavis.maxY = MAX(anugavis.maxY, anugavis.y[i]);
     104  }
     105  anugavis.eye[0] = anugavis.minX;
     106  anugavis.eye[1] = anugavis.minY;
     107  anugavis.eye[2] = 0;
     108  anugavis.focus[0] = anugavis.minX + (anugavis.maxX - anugavis.minX) / 2;
     109  anugavis.focus[1] = anugavis.minY + (anugavis.maxY - anugavis.minY) / 2;
     110  anugavis.focus[2] = 0;
     111  vsub(anugavis.eye, anugavis.focus, releye);
     112  anugavis.eye[2] = vlen(releye);
    106113  return 0;
    107114}
Note: See TracChangeset for help on using the changeset viewer.