Changeset 5636 for anuga_work/development/anugavis/src
- Timestamp:
- Aug 11, 2008, 12:11:33 PM (17 years ago)
- Location:
- anuga_work/development/anugavis/src
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anugavis/src/Makefile.am
r5502 r5636 23 23 xfunctions.h 24 24 libanugavis_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 25 libanugavis_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 33 30 libanugavis_cxx_a_LIBADD = $(LIBOBJS) 34 31 -
anuga_work/development/anugavis/src/anugavis.cc
r5600 r5636 3 3 #endif 4 4 5 #include < iostream>5 #include <algorithm> 6 6 #include <string> 7 7 #include <boost/shared_ptr.hpp> … … 22 22 23 23 using boost::shared_ptr; 24 using std::for_each; 24 25 using std::string; 25 26 26 27 AnugaVis::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(); 28 30 init_SDL(width, height); 29 31 init_OpenGL(width, height); … … 40 42 41 43 void AnugaVis::run(void){ 44 while(this->step()); 45 } 42 46 47 void 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(); 43 55 } 44 56 … … 73 85 glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse); 74 86 } 87 88 static const Uint32 TARGET_TICK_RATE = 50; 89 bool 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 10 10 #include "height_quantity.hh" 11 11 #include "sww_file.hh" 12 #include "vector.hh" 12 13 13 14 using boost::shared_ptr; … … 22 23 void run(void); 23 24 private: 25 void init_camera(void); 24 26 void init_SDL(int width, int height); 25 27 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; 26 34 SDL_Surface *screen; 27 35 shared_ptr<SWWFile> sww_file; 28 list<shared_ptr<HeightQuantity> > heights;29 36 }; 30 37 -
anuga_work/development/anugavis/src/height_quantity.cc
r5605 r5636 63 63 size_t span_2[2] = {1, 0}; 64 64 int ncstatus; 65 int volume; 66 int vertex; 67 int vertIndex; 65 68 if(this->dynamic){ 69 start_2[0] = frame; 66 70 span_2[1] = this->sww_file->number_of_points; 67 71 ncstatus = nc_get_vara_float(this->sww_file->netcdf_id, this->varid, … … 73 77 } 74 78 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(); 76 96 } -
anuga_work/development/anugavis/src/sww_file.hh
r5600 r5636 18 18 19 19 class SWWFile{ 20 friend class AnugaVis; 20 21 friend class HeightQuantity; 21 22 public:
Note: See TracChangeset
for help on using the changeset viewer.