/* * CG_DemoCam_FreeFly */ int CG_DemoCam_FreeFly( void ) { usercmd_t cmd; const float SPEED = 500; if( cgs.demoPlaying && CamIsFree ) { vec3_t wishvel, wishdir, forward, right, up, moveangles; float fmove, smove, upmove, wishspeed, maxspeed; int i; maxspeed = 250; // run frame trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); cmd.msec = cg.realFrameTime * 1000; cmd.forwardfrac = ( (float)cmd.forwardmove/(float)cmd.msec ); cmd.sidefrac = ( (float)cmd.sidemove/(float)cmd.msec ); cmd.upfrac = ( (float)cmd.upmove/(float)cmd.msec ); for( i = 0; i < 3; i++ ) moveangles[i] = SHORT2ANGLE( cmd.angles[i] ) + SHORT2ANGLE( freecam_delta_angles[i] ); AngleVectors( moveangles, forward, right, up ); VectorCopy( moveangles, cam_angles ); fmove = cmd.forwardfrac * SPEED; smove = cmd.sidefrac * SPEED; upmove = cmd.upfrac * SPEED; if( cmd.buttons & BUTTON_SPECIAL ) maxspeed *= 2; for( i = 0; i < 3; i++ ) wishvel[i] = forward[i] * fmove + right[i] * smove; wishvel[2] += upmove; wishspeed = VectorNormalize2( wishvel, wishdir ); if( wishspeed > maxspeed ) { wishspeed = maxspeed/wishspeed; VectorScale( wishvel, wishspeed, wishvel ); wishspeed = maxspeed; } VectorMA( cam_origin, cg.realFrameTime, wishvel, cam_origin ); cam_POVent = 0; cam_3dPerson = false; return VIEWDEF_CAMERA; } return VIEWDEF_PLAYERVIEW; }
static void CG_Democam_SetCameraPositionFromView( void ) { if( cg.view.type == VIEWDEF_PLAYERVIEW ) { VectorCopy( cg.view.origin, cam_origin ); VectorCopy( cg.view.angles, cam_angles ); VectorCopy( cg.view.velocity, cam_velocity ); cam_fov = cg.view.fov_y; cam_orbital_radius = 0; } if( !CamIsFree ) { int i; usercmd_t cmd; trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); for( i = 0; i < 3; i++ ) freecam_delta_angles[i] = ANGLE2SHORT( cam_angles[i] ) - cmd.angles[i]; } else { cam_orbital_radius = 0; } }
/* * CG_ChaseCamButtons */ static void CG_ChaseCamButtons( void ) { #define CHASECAMBUTTONSDELAY ( cg.time + 250 ) usercmd_t cmd; bool chasecam = ( cg.frame.playerState.pmove.pm_type == PM_CHASECAM ) && ( cg.frame.playerState.POVnum != (unsigned)( cgs.playerNum + 1 ) ); bool realSpec = cgs.demoPlaying || ISREALSPECTATOR(); if( (cg.frame.multipov || chasecam) && !CG_DemoCam_IsFree() ) { if( cg.time <= chaseCam.cmd_mode_delay ) return; trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); if( ( cmd.buttons & BUTTON_ATTACK ) ) { if( chasecam ) { if( realSpec ) { if( ++chaseCam.mode >= CAM_MODES ) { // if exceeds the cycle, start free fly trap_Cmd_ExecuteText( EXEC_NOW, "camswitch" ); chaseCam.mode = 0; // smallest, to start the new cycle } chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } else { chaseCam.mode = ( chaseCam.mode != CAM_THIRDPERSON ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } if( cg.frame.multipov || chasecam ) { int step = 0; if( cmd.upmove > 0 || cmd.buttons & BUTTON_SPECIAL ) step = 1; else if( cmd.upmove < 0 ) step = -1; if( step ) { CG_ChaseStep( step ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } } else if( CG_DemoCam_IsFree() || cg.frame.playerState.pmove.pm_type == PM_SPECTATOR ) { chaseCam.mode = CAM_INEYES; if( realSpec ) { trap_NET_GetUserCmd( trap_NET_GetCurrentUserCmdNum() - 1, &cmd ); if( ( cmd.buttons & BUTTON_ATTACK ) && cg.time > chaseCam.cmd_mode_delay ) { trap_Cmd_ExecuteText( EXEC_NOW, "camswitch" ); chaseCam.cmd_mode_delay = CHASECAMBUTTONSDELAY; } } } else { chaseCam.mode = CAM_INEYES; } #undef CHASECAMBUTTONSDELAY }