[Tuxracer-checkins] CVS: tuxracer/src view.c,1.3,1.4
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@us...> - 2000-08-28 03:48:31
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv778 Modified Files: view.c Log Message: Camera position interpolation is now slowed down (or stopped) when player is moving slowly. This helps to prevent the camera from swinging erratically when Tux hits a tree, etc. Index: view.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/view.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** view.c 2000/08/26 23:44:38 1.3 --- view.c 2000/08/28 03:48:28 1.4 *************** *** 42,46 **** /* Maximum downward pitch of camera (deg) */ ! #define MAX_CAMERA_PITCH 45 /* Time constant for interpolation of camera position in "behind" mode (s) */ --- 42,46 ---- /* Maximum downward pitch of camera (deg) */ ! #define MAX_CAMERA_PITCH 40 /* Time constant for interpolation of camera position in "behind" mode (s) */ *************** *** 58,61 **** --- 58,67 ---- #define FOLLOW_ORIENT_TIME_CONSTANT 0.08 + /* Speed above which interpolation is "normal" (m/s) */ + #define BASELINE_INTERPOLATION_SPEED 4.5 + + /* Speed below which no camera position interpolation occurs (m/s) */ + #define NO_INTERPOLATION_SPEED 2.0 + static point_t tux_eye_pts[2]; static point_t tux_view_pt; *************** *** 287,290 **** --- 293,308 ---- vector_t vel_proj; quaternion_t rot_quat; + scalar_t speed; + vector_t vel_cpy; + scalar_t time_constant_mult; + + vel_cpy = plyr->vel; + speed = normalize_vector( &vel_cpy ); + + time_constant_mult = 1.0 / + min( 1.0, + max( 0.0, + ( speed - NO_INTERPOLATION_SPEED ) / + ( BASELINE_INTERPOLATION_SPEED - NO_INTERPOLATION_SPEED ))); up_dir = make_vector( 0, 1, 0 ); *************** *** 303,308 **** /* Camera-on-a-string mode */ - up_dir = make_vector( 0, 1, 0 ); - /* Construct vector from player to camera */ view_vec = make_vector( 0, --- 321,324 ---- *************** *** 333,337 **** view_pt = move_point( plyr->pos, view_vec ); - /* Make sure view point is above terrain */ ycoord = find_y_coord( view_pt.x, view_pt.z ); --- 349,352 ---- *************** *** 350,354 **** MAX_CAMERA_PITCH, plyr->view.pos, view_pt, CAMERA_DISTANCE, dt, ! BEHIND_ORBIT_TIME_CONSTANT ); } } --- 365,370 ---- MAX_CAMERA_PITCH, plyr->view.pos, view_pt, CAMERA_DISTANCE, dt, ! BEHIND_ORBIT_TIME_CONSTANT * ! time_constant_mult ); } } *************** *** 364,368 **** view_vec = subtract_points( view_pt, plyr->pos ); ! axis = cross_product( vel_proj, y_vec ); normalize_vector( &axis ); --- 380,384 ---- view_vec = subtract_points( view_pt, plyr->pos ); ! axis = cross_product( y_vec, view_vec ); normalize_vector( &axis ); *************** *** 380,383 **** --- 396,400 ---- &up_dir, &view_dir, dt, BEHIND_ORIENT_TIME_CONSTANT ); + up_dir = make_vector( 0.0, 1.0, 0.0 ); } } *************** *** 392,396 **** up_dir = make_vector( 0, 1, 0 ); - /* Construct vector from player to camera */ view_vec = make_vector( 0, --- 409,412 ---- *************** *** 437,441 **** MAX_CAMERA_PITCH, plyr->view.pos, view_pt, CAMERA_DISTANCE, dt, ! FOLLOW_ORBIT_TIME_CONSTANT ); } } --- 453,458 ---- MAX_CAMERA_PITCH, plyr->view.pos, view_pt, CAMERA_DISTANCE, dt, ! FOLLOW_ORBIT_TIME_CONSTANT * ! time_constant_mult ); } } *************** *** 451,455 **** view_vec = subtract_points( view_pt, plyr->pos ); ! axis = cross_product( vel_proj, y_vec ); normalize_vector( &axis ); --- 468,472 ---- view_vec = subtract_points( view_pt, plyr->pos ); ! axis = cross_product( y_vec, view_vec ); normalize_vector( &axis ); *************** *** 467,470 **** --- 484,488 ---- &up_dir, &view_dir, dt, FOLLOW_ORIENT_TIME_CONSTANT ); + up_dir = make_vector( 0.0, 1.0, 0.0 ); } } |