[Tuxracer-checkins] CVS: tuxracer/src course_load.c,1.14,1.15 course_load.h,1.6,1.7
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@us...> - 2000-08-31 15:29:37
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv32483 Modified Files: course_load.c course_load.h Log Message: Added routines to find the minimum and maximum height of the terrain at a specified distance down the course. Index: course_load.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/course_load.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** course_load.c 2000/08/27 20:16:42 1.14 --- course_load.c 2000/08/31 15:29:34 1.15 *************** *** 107,110 **** --- 107,151 ---- } + /*! + Returns the base (minimum) height of the terrain at \c distance + \pre A course has been loaded + \arg \c distance the (non-negative) distance down the course + + \return Minimum height (y-coord) of terrain + \author jfpatry + \date Created: 2000-08-30 + \date Modified: 2000-08-30 + */ + scalar_t get_terrain_base_height( scalar_t distance ) + { + scalar_t slope = tan( course_angle * M_PI/180.0 ); + scalar_t base_height; + + check_assertion( distance > -EPS, + "distance should be positive" ); + + /* This will need to be fixed once we add variably-sloped terrain */ + + base_height = -slope * distance - + base_height_value / 255.0 * elev_scale; + + return base_height; + } + + /*! + Returns the maximum height of the terrain at \c distance + \pre A course has been loaded + \arg \c distance the (non-negative) distance down the course + + \return Maximum height (y-coord) of terrain + \author jfpatry + \date Created: 2000-08-30 + \date Modified: 2000-08-30 + */ + scalar_t get_terrain_max_height( scalar_t distance ) + { + return get_terrain_base_height( distance ) + elev_scale; + } + void get_course_divisions( int *x, int *y ) { *************** *** 411,418 **** - base_height_value ) / 255.0 ) * elev_scale - (scalar_t) (ny-1.-y)/ny * course_length * slope; - - /* if ( x == 0 || x == nx-1 ) { - ELEV(nx-1-x, ny-1-y) += 0.5 * elev_scale; - } */ } pad += (nx*elev_img->sizeZ) % 4; --- 452,455 ---- Index: course_load.h =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/course_load.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** course_load.h 2000/08/27 20:16:42 1.6 --- course_load.h 2000/08/31 15:29:34 1.7 *************** *** 38,41 **** --- 38,43 ---- void get_course_dimensions( scalar_t *width, scalar_t *length ); void get_play_dimensions( scalar_t *width, scalar_t *length ); + scalar_t get_terrain_base_height( scalar_t distance ); + scalar_t get_terrain_max_height( scalar_t distance ); void get_course_divisions( int *nx, int *ny ); tree_t *get_tree_locs(); |