Changeset 5292
- Timestamp:
- May 8, 2008, 3:19:26 PM (17 years ago)
- Location:
- anuga_work/development/anugavis
- Files:
-
- 2 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anugavis/Makefile.am
r5255 r5292 1 1 ## Process this file with automake to generate Makefile.in 2 2 ACLOCAL_AMFLAGS = -I m4 3 SUBDIRS = m4 src 3 EXTRA_DIST = m4 4 SUBDIRS = src 5 6 dist-hook: 7 rm -rf `find $(distdir)/m4 -name .svn` -
anuga_work/development/anugavis/configure.ac
r5272 r5292 10 10 # Checks for programs. 11 11 AC_PROG_CC 12 AM_PROG_CC_C_O 12 13 AC_PROG_RANLIB 13 14 … … 17 18 AC_SEARCH_LIBS([nc_open], [netcdf], [], 18 19 [AC_MSG_ERROR([Can't link the NetCDF library. (LDFLAGS?)])]) 20 AC_SEARCH_LIBS([sqrt], [m], [], 21 [AC_MSG_ERROR([Can't find sqrt.])]) 22 19 23 # Checks for header files. 20 24 AC_CHECK_HEADER([netcdf.h], [], … … 23 27 # Checks for typedefs, structures, and compiler characteristics. 24 28 AC_C_CONST 25 AM_PROG_CC_C_O26 29 AC_TYPE_SIZE_T 27 30 28 31 # Checks for library functions. 29 32 AC_FUNC_MALLOC 30 AC_CHECK_FUNCS([strdup ])33 AC_CHECK_FUNCS([strdup sqrt]) 31 34 32 35 AC_CONFIG_FILES([Makefile 33 m4/Makefile34 36 src/Makefile]) 35 37 AC_OUTPUT -
anuga_work/development/anugavis/src/Makefile.am
r5272 r5292 3 3 # Convenience library for the core visualiser code. 4 4 noinst_LIBRARIES = libanugavis.a 5 libanugavis_a_SOURCES = error.c \ 5 libanugavis_a_SOURCES = camera.c \ 6 camera.h \ 7 error.c \ 6 8 error.h \ 7 9 events.c \ -
anuga_work/development/anugavis/src/anugavis_simple.c
r5271 r5292 14 14 return 1; 15 15 } 16 if(AnugaVis_DefineHeightQuantity("elevation", 0, 1, 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, 1, 0.0, 0.0, 0.5) == -1){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){ 21 21 printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError()); 22 22 return 1; -
anuga_work/development/anugavis/src/events.c
r5273 r5292 14 14 #endif 15 15 #include <SDL.h> 16 #include "camera.h" 16 17 #include "events.h" 17 18 #include "globals.h" … … 19 20 20 21 int AnugaVis_Step(void){ 22 GLfloat lightpos[4]; 23 int i; 21 24 SDL_Event event; 22 25 int more = 1; … … 26 29 glMatrixMode(GL_MODELVIEW); 27 30 glLoadIdentity(); 31 if(anugavis.keys[KEY_ROTATE_LEFT]) camera_rotate_yaw(CAMERA_DEFAULT_THETA); 32 if(anugavis.keys[KEY_ROTATE_RIGHT]) camera_rotate_yaw(-CAMERA_DEFAULT_THETA); 28 33 gluLookAt(anugavis.eye[0], anugavis.eye[1], anugavis.eye[2], 29 34 anugavis.focus[0], anugavis.focus[1], anugavis.focus[2], 30 35 0, 0, 1); 36 for(i = 0 ; i < 3 ; i++) lightpos[i] = anugavis.eye[i]; 37 lightpos[3] = 1.0; 38 glLightfv(GL_LIGHT0, GL_POSITION, lightpos); 31 39 for(height = anugavis.heights ; height != NULL ; height = height->next) 32 40 AnugaVis_DrawHeightQuantity(height); … … 37 45 case SDL_KEYDOWN: 38 46 switch(event.key.keysym.sym){ 47 case SDLK_b: 48 if(anugavis.current_frame > 0) anugavis.current_frame--; 49 break; 50 case SDLK_f: 51 if(anugavis.current_frame < anugavis.number_of_timesteps - 1) 52 anugavis.current_frame++; 53 break; 39 54 case SDLK_ESCAPE: 40 55 more = 0; 56 break; 57 case SDLK_DOWN: 58 anugavis.eye[2] += 1; 59 break; 60 case SDLK_LEFT: 61 anugavis.keys[KEY_ROTATE_LEFT] = 1; 62 break; 63 case SDLK_RIGHT: 64 anugavis.keys[KEY_ROTATE_RIGHT] = 1; 41 65 break; 42 66 default: … … 46 70 case SDL_KEYUP: 47 71 switch(event.key.keysym.sym){ 72 case SDLK_LEFT: 73 anugavis.keys[KEY_ROTATE_LEFT] = 0; 74 break; 75 case SDLK_RIGHT: 76 anugavis.keys[KEY_ROTATE_RIGHT] = 0; 77 break; 48 78 default: 49 79 break; -
anuga_work/development/anugavis/src/events.h
r5271 r5292 6 6 KEY_STRAFE_LEFT, 7 7 KEY_STRAFE_RIGHT, 8 KEY_ROTATE_LEFT, 9 KEY_ROTATE_RIGHT, 8 10 KEY_MAX} KEYS; 9 11 -
anuga_work/development/anugavis/src/globals.h
r5271 r5292 26 26 size_t number_of_volumes; 27 27 size_t number_of_timesteps; 28 size_t current_frame; 28 29 float *x; 29 30 float *y; -
anuga_work/development/anugavis/src/height_quantity.c
r5273 r5292 32 32 vector v2; 33 33 vector normal; 34 vector flippedNormal; 35 vector up = {0.0, 0.0, 1.0}; 34 36 float *heights = xmalloc(sizeof(float) 35 37 * anugavis.number_of_points … … 51 53 vs[vertex][0] = anugavis.x[vertIndex]; 52 54 vs[vertex][1] = anugavis.y[vertIndex]; 53 vs[vertex][2] = heights[frame*anugavis.number_of_ timesteps + vertIndex];55 vs[vertex][2] = heights[frame*anugavis.number_of_points + vertIndex]; 54 56 } 55 57 vsub(vs[1], vs[0], v1); 56 58 vsub(vs[2], vs[0], v2); 57 59 vcross(v1, v2, normal); 58 /* FIXME: Need to ensure that normal is pointing upward. */ 59 glNormal3fv(normal); 60 if(vdot(normal, up) / vlen(normal) < 0){ 61 vscale(normal, -1.0, flippedNormal); 62 glNormal3fv(flippedNormal); 63 }else glNormal3fv(normal); 60 64 for(vertex = 0 ; vertex < anugavis.number_of_vertices ; vertex++){ 61 65 vertIndex = anugavis.volumes[vol*anugavis.number_of_vertices + vertex]; 62 66 glVertex3f(anugavis.x[vertIndex], anugavis.y[vertIndex], 63 heights[frame * anugavis.number_of_ timesteps + vertIndex]);67 heights[frame * anugavis.number_of_points + vertIndex]); 64 68 } 65 69 glEnd(); … … 146 150 void AnugaVis_DrawHeightQuantity(struct height_quantity_simple *height){ 147 151 glPushMatrix(); 148 /* glScalef(0, 0, height->scale);149 glTranslatef(0, 0, height->offset);*/152 glScalef(1, 1, height->scale); 153 glTranslatef(0, 0, height->offset); 150 154 glColor3f(height->red, height->green, height->blue); 151 glCallList(height->displayLists); 155 glCallList(height->displayLists + (height->frames == 1 ? 0 : 156 anugavis.current_frame)); 152 157 glPopMatrix(); 153 158 } -
anuga_work/development/anugavis/src/init.c
r5271 r5292 26 26 int AnugaVis_Init(int width, int height, const char *swwFilePath){ 27 27 int ncstatus; 28 int ncdimid; 29 int ncvarid; 28 GLfloat lightAmbient[] = {0.0, 0.0, 0.0, 1.0}; 29 GLfloat lightDiffuse[] = {1.0, 1.0, 1.0, 1.0}; 30 anugavis.current_frame = 0; 30 31 anugavis.x = NULL; 31 32 anugavis.y = NULL; 32 33 anugavis.volumes = NULL; 33 34 /* FIXME derive this from the dataset? */ 34 anugavis.eye[0] = 5.0;35 anugavis.eye[1] = 5.0;36 anugavis.eye[2] = 20.0;35 anugavis.eye[0] = 1.0; 36 anugavis.eye[1] = 1.0; 37 anugavis.eye[2] = 40.0; 37 38 anugavis.focus[0] = 0.0; 38 39 anugavis.focus[1] = 0.0; … … 59 60 glMatrixMode(GL_MODELVIEW); 60 61 glLoadIdentity(); 61 62 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 63 glEnable(GL_COLOR_MATERIAL); 64 glEnable(GL_LIGHTING); 65 glEnable(GL_LIGHT0); 66 glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient); 67 glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse); 68 62 69 if((ncstatus = nc_open(swwFilePath, NC_SHARE, 63 70 &anugavis.netcdfId)) != NC_NOERR){ -
anuga_work/development/anugavis/src/vector.c
r5272 r5292 6 6 } 7 7 8 void vscale(vector v, float scale, vector result){ 9 int i; 10 for(i = 0 ; i < 3 ; i++) result[i] = scale * v[i]; 11 } 12 8 13 void vsub(vector v1, vector v2, vector result){ 9 14 int i; … … 11 16 } 12 17 13 void vnormalise(vector v, vector result){ 14 float len = vlen(v); 18 float vdot(vector v1, vector v2){ 15 19 int i; 16 for(i = 0 ; i < 3 ; i++) result[i] = v[i] / len; 20 float rv = 0; 21 for(i = 0 ; i < 3 ; i++) rv += v1[i] * v2[i]; 22 return rv; 17 23 } 18 24 -
anuga_work/development/anugavis/src/vector.h
r5272 r5292 5 5 /* Useful vector operations. */ 6 6 float vlen(vector v); 7 void vscale(vector v, float scale, vector result); 7 8 void vsub(vector v1, vector v2, vector result); 8 void vnormalise(vector v, vector result);9 float vdot(vector v1, vector v2); 9 10 void vcross(vector v1, vector v2, vector result); 10 11
Note: See TracChangeset
for help on using the changeset viewer.