Changeset 5636


Ignore:
Timestamp:
Aug 11, 2008, 12:11:33 PM (16 years ago)
Author:
jack
Message:

Almost ready to run.

Location:
anuga_work/development/anugavis/src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/Makefile.am

    r5502 r5636  
    2323                        xfunctions.h
    2424libanugavis_a_LIBADD = $(LIBOBJS)
    25 libanugavis_cxx_a_SOURCES = anugavis.cc \
    26                             anugavis.hh \
    27                             height_quantity.cc \
    28                             height_quantity.hh \
    29                             output.cc \
    30                             output.hh \
    31                             sww_file.cc \
    32                             sww_file.hh
     25libanugavis_cxx_a_SOURCES = anugavis.cc         anugavis.hh             \
     26                            height_quantity.cc  height_quantity.hh      \
     27                            output.cc           output.hh               \
     28                            sww_file.cc         sww_file.hh             \
     29                            vector.cc           vector.hh
    3330libanugavis_cxx_a_LIBADD = $(LIBOBJS)
    3431
  • anuga_work/development/anugavis/src/anugavis.cc

    r5600 r5636  
    33#endif
    44
    5 #include <iostream>
     5#include <algorithm>
    66#include <string>
    77#include <boost/shared_ptr.hpp>
     
    2222
    2323using boost::shared_ptr;
     24using std::for_each;
    2425using std::string;
    2526
    2627AnugaVis::AnugaVis(const string &file_name, int width, int height):
    27   screen(NULL), sww_file(new SWWFile(file_name)){
     28  frame(0), paused(false), screen(NULL), sww_file(new SWWFile(file_name)){
     29  init_camera();
    2830  init_SDL(width, height);
    2931  init_OpenGL(width, height);
     
    4042
    4143void AnugaVis::run(void){
     44  while(this->step());
     45}
    4246
     47void AnugaVis::init_camera(void){
     48  this->eye = Vector(this->sww_file->minX, this->sww_file->minY, 0);
     49  this->focus = Vector(this->sww_file->minX +
     50                       (this->sww_file->maxX - this->sww_file->minX) / 2,
     51                       this->sww_file->minY +
     52                       (this->sww_file->maxY - this->sww_file->minY) / 2,
     53                       0);
     54  this->eye.z = (eye - focus).magnitude();
    4355}
    4456
     
    7385  glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse);
    7486}
     87
     88static const Uint32 TARGET_TICK_RATE = 50;
     89bool AnugaVis::step(void){
     90  static Uint32 ticks = 0;
     91  static Uint32 lastframe;
     92  bool more = true;
     93
     94  if(ticks == 0) lastframe = ticks = SDL_GetTicks();
     95  else ticks = SDL_GetTicks();
     96  if(ticks - lastframe < TARGET_TICK_RATE) return more;
     97 
     98  lastframe = ticks;
     99  if(this->frame < this->sww_file->number_of_timesteps - 1){
     100    if(!this->paused) this->frame++;
     101  }else
     102    this->paused = 1;
     103
     104  return false;
     105}
  • anuga_work/development/anugavis/src/anugavis.hh

    r5600 r5636  
    1010#include "height_quantity.hh"
    1111#include "sww_file.hh"
     12#include "vector.hh"
    1213
    1314using boost::shared_ptr;
     
    2223  void run(void);
    2324private:
     25  void init_camera(void);
    2426  void init_SDL(int width, int height);
    2527  void init_OpenGL(int width, int height);
     28  bool step(void);
     29  Vector eye;
     30  Vector focus;
     31  int frame;
     32  list<shared_ptr<HeightQuantity> > heights;
     33  bool paused;
    2634  SDL_Surface *screen;
    2735  shared_ptr<SWWFile> sww_file;
    28   list<shared_ptr<HeightQuantity> > heights;
    2936};
    3037
  • anuga_work/development/anugavis/src/height_quantity.cc

    r5605 r5636  
    6363  size_t span_2[2] = {1, 0};
    6464  int ncstatus;
     65  int volume;
     66  int vertex;
     67  int vertIndex;
    6568  if(this->dynamic){
     69    start_2[0] = frame;
    6670    span_2[1] = this->sww_file->number_of_points;
    6771    ncstatus = nc_get_vara_float(this->sww_file->netcdf_id, this->varid,
     
    7377  }
    7478  if(ncstatus != NC_NOERR) throw nc_strerror(ncstatus);
    75   /* TODO: Compile the triangles into an OGL displaylist. */
     79  glNewList(this->display_list, GL_COMPILE);
     80  glBegin(GL_TRIANGLES);
     81  {
     82   
     83    for(volume = 0 ; volume = this->sww_file->number_of_volumes ; ++volume){
     84      for(vertex = 0 ; vertex < 3 ; ++vertex){
     85        vertIndex = this->sww_file->volumes[volume *
     86                                            this->sww_file->number_of_vertices +
     87                                            vertex];
     88        glVertex3f(this->sww_file->x[vertIndex],
     89                   this->sww_file->y[vertIndex],
     90                   this->points[vertIndex]);
     91      }
     92    }
     93  }
     94  glEnd();
     95  glEndList();
    7696}
  • anuga_work/development/anugavis/src/sww_file.hh

    r5600 r5636  
    1818
    1919class SWWFile{
     20  friend class AnugaVis;
    2021  friend class HeightQuantity;
    2122public:
Note: See TracChangeset for help on using the changeset viewer.