codemp/cgame/cg_view.c File Reference

#include "cg_local.h"
#include "bg_saga.h"
#include "cg_lights.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Defines

#define MASK_CAMERACLIP   (MASK_SOLID|CONTENTS_PLAYERCLIP)
#define CAMERA_SIZE   4
#define CAMERA_DAMP_INTERVAL   50
#define WAVE_AMPLITUDE   1
#define WAVE_FREQUENCY   0.4
#define CAMERA_DEFAULT_FOV   90.0f
#define MAX_SHAKE_INTENSITY   16.0f
#define SIDEFRAME_WIDTH   16
#define SIDEFRAME_HEIGHT   32

Functions

void CG_TestModel_f (void)
void CG_TestGun_f (void)
void CG_TestModelNextFrame_f (void)
void CG_TestModelPrevFrame_f (void)
void CG_TestModelNextSkin_f (void)
void CG_TestModelPrevSkin_f (void)
void CG_CalcEntityLerpPositions (centity_t *cent)
qboolean BG_UnrestrainedPitchRoll (playerState_t *ps, Vehicle_t *pVeh)
void CG_GetVehicleCamPos (vec3_t camPos)
void CG_ZoomDown_f (void)
void CG_ZoomUp_f (void)
qboolean CG_CalcFOVFromX (float fov_x)
qboolean CG_CheckPassengerTurretView (void)
void CG_EmplacedView (vec3_t angles)
void CG_DrawSkyBoxPortal (const char *cstr)
void CG_AddBufferedSound (sfxHandle_t sfx)
void CG_UpdateSoundTrackers ()
void CG_SE_UpdateShake (vec3_t origin, vec3_t angles)
void CG_SE_UpdateMusic (void)
void CG_CalcScreenEffects (void)
void CGCam_Shake (float intensity, int duration)
void CG_DoCameraShake (vec3_t origin, float intensity, int radius, int time)
void CGCam_SetMusicMult (float multiplier, int duration)
int BG_EmplacedView (vec3_t baseAngles, vec3_t angles, float *newYaw, float constraint)
void CG_AddRadarAutomapEnts (void)
void CG_DrawAutoMap (void)
void BG_VehicleTurnRateForSpeed (Vehicle_t *pVeh, float speed, float *mPitchOverride, float *mYawOverride)
qboolean PM_InKnockDown (playerState_t *ps)
void CG_ActualLoadDeferredPlayers (void)
void CG_DrawActiveFrame (int serverTime, stereoFrame_t stereoView, qboolean demoPlayback)

Variables

vec3_t camerafwd
vec3_t cameraup
vec3_t cameraFocusAngles
vec3_t cameraFocusLoc
vec3_t cameraIdealTarget
vec3_t cameraIdealLoc
vec3_t cameraCurTarget = {0,0,0} cameraCurLoc={0,0,0}
vec3_t cameraOldLoc = {0,0,0} cameraNewLoc={0,0,0}
int cameraLastFrame = 0
float cameraLastYaw = 0
float cameraStiffFactor = 0.0f
qboolean gCGHasFallVector
vec3_t gCGFallVector
vmCvar_t cg_thirdPersonHorzOffset
float zoomFov
int cg_actionCamLastTime = 0
vec3_t cg_actionCamLastPos
vec3_t cg_lastTurretViewAngles = {0}
qboolean cg_skyOri
vec3_t cg_skyOriPos
float cg_skyOriScale
qboolean cg_noFogOutsidePortal
cgscreffects_t cgScreenEffects
float cg_autoMapZoom = 512.0f
float cg_autoMapZoomMainOffset = 0.0f
vec3_t cg_autoMapAngle = {90.0f, 0.0f, 0.0f}
autoMapInput_t cg_autoMapInput
int cg_autoMapInputTime = 0
float cg_linearFogOverride = 0.0f
qboolean cgQueueLoad


Define Documentation

#define CAMERA_DAMP_INTERVAL   50
 

Definition at line 219 of file cg_view.c.

#define CAMERA_DEFAULT_FOV   90.0f
 

Definition at line 1998 of file cg_view.c.

Referenced by CG_SE_UpdateShake().

#define CAMERA_SIZE   4
 

Definition at line 14 of file cg_view.c.

Referenced by G_EstimateCamPos().

#define MASK_CAMERACLIP   (MASK_SOLID|CONTENTS_PLAYERCLIP)
 

Definition at line 13 of file cg_view.c.

Referenced by G_EstimateCamPos().

#define MAX_SHAKE_INTENSITY   16.0f
 

Definition at line 1999 of file cg_view.c.

Referenced by CGCam_Shake().

#define SIDEFRAME_HEIGHT   32
 

Definition at line 2275 of file cg_view.c.

Referenced by CG_DrawAutoMap().

#define SIDEFRAME_WIDTH   16
 

Definition at line 2274 of file cg_view.c.

Referenced by CG_DrawAutoMap().

#define WAVE_AMPLITUDE   1
 

Definition at line 1187 of file cg_view.c.

#define WAVE_FREQUENCY   0.4
 

Definition at line 1188 of file cg_view.c.


Function Documentation

int BG_EmplacedView vec3_t  baseAngles,
vec3_t  angles,
float *  newYaw,
float  constraint
 

Definition at line 2703 of file bg_misc.c.

02704 {
02705         float dif = AngleSubtract(baseAngles[YAW], angles[YAW]);
02706 
02707         if (dif > constraint ||
02708                 dif < -constraint)
02709         {
02710                 float amt;
02711 
02712                 if (dif > constraint)
02713                 {
02714                         amt = (dif-constraint);
02715                         dif = constraint;
02716                 }
02717                 else if (dif < -constraint)
02718                 {
02719                         amt = (dif+constraint);
02720                         dif = -constraint;
02721                 }
02722                 else
02723                 {
02724                         amt = 0.0f;
02725                 }
02726 
02727                 *newYaw = AngleSubtract(angles[YAW], -dif);
02728 
02729                 if (amt > 1.0f || amt < -1.0f)
02730                 { //significant, force the view
02731                         return 2;
02732                 }
02733                 else
02734                 { //just a little out of range
02735                         return 1;
02736                 }
02737         }
02738 
02739         return 0;
02740 }

qboolean BG_UnrestrainedPitchRoll playerState_t ps,
Vehicle_t pVeh
 

Definition at line 7785 of file bg_pmove.c.

07786 {
07787         if ( bg_fighterAltControl.integer
07788                 && ps->clientNum < MAX_CLIENTS //real client
07789                 && ps->m_iVehicleNum//in a vehicle
07790                 && pVeh //valid vehicle data pointer
07791                 && pVeh->m_pVehicleInfo//valid vehicle info
07792                 && pVeh->m_pVehicleInfo->type == VH_FIGHTER )//fighter
07793                 //FIXME: specify per vehicle instead of assuming true for all fighters
07794                 //FIXME: map/server setting?
07795         {//can roll and pitch without limitation!
07796                 return qtrue;
07797         }
07798         return qfalse;
07799 }

void BG_VehicleTurnRateForSpeed Vehicle_t pVeh,
float  speed,
float *  mPitchOverride,
float *  mYawOverride
 

Definition at line 676 of file bg_pmove.c.

00677 {
00678         if ( pVeh && pVeh->m_pVehicleInfo )
00679         {
00680                 float speedFrac = 1.0f;
00681                 if ( pVeh->m_pVehicleInfo->speedDependantTurning )
00682                 {
00683                         if ( pVeh->m_LandTrace.fraction >= 1.0f 
00684                                 || pVeh->m_LandTrace.plane.normal[2] < MIN_LANDING_SLOPE  )
00685                         {
00686                                 speedFrac = (speed/(pVeh->m_pVehicleInfo->speedMax*0.75f));
00687                                 if ( speedFrac < 0.25f )
00688                                 {
00689                                         speedFrac = 0.25f;
00690                                 }
00691                                 else if ( speedFrac > 1.0f )
00692                                 {
00693                                         speedFrac = 1.0f;
00694                                 }
00695                         }
00696                 }
00697                 if ( pVeh->m_pVehicleInfo->mousePitch )
00698                 {
00699                         *mPitchOverride = pVeh->m_pVehicleInfo->mousePitch*speedFrac;
00700                 }
00701                 if ( pVeh->m_pVehicleInfo->mouseYaw )
00702                 {
00703                         *mYawOverride = pVeh->m_pVehicleInfo->mouseYaw*speedFrac;
00704                 }
00705         }
00706 }

void CG_ActualLoadDeferredPlayers void   ) 
 

Definition at line 1953 of file cg_players.c.

References CG_LoadClientInfo(), cgs, cgs_t::clientinfo, and cgs_t::maxclients.

Referenced by CG_DrawActiveFrame().

01954 {
01955         int             i;
01956         clientInfo_t    *ci;
01957 
01958         // scan for a deferred player to load
01959         for ( i = 0, ci = cgs.clientinfo ; i < cgs.maxclients ; i++, ci++ ) {
01960                 if ( ci->infoValid && ci->deferred ) {
01961                         CG_LoadClientInfo( ci );
01962 //                      break;
01963                 }
01964         }
01965 }

void CG_AddBufferedSound sfxHandle_t  sfx  ) 
 

Definition at line 1934 of file cg_view.c.

References cg, MAX_SOUNDBUFFER, sfxHandle_t, cg_t::soundBuffer, cg_t::soundBufferIn, and cg_t::soundBufferOut.

Referenced by CG_CheckLocalSounds(), and CG_EntityEvent().

01934                                             {
01935         if ( !sfx )
01936                 return;
01937         cg.soundBuffer[cg.soundBufferIn] = sfx;
01938         cg.soundBufferIn = (cg.soundBufferIn + 1) % MAX_SOUNDBUFFER;
01939         if (cg.soundBufferIn == cg.soundBufferOut) {
01940                 cg.soundBufferOut++;
01941         }
01942 }

void CG_AddRadarAutomapEnts void   ) 
 

Definition at line 2248 of file cg_view.c.

References cg, cg_entities, playerState_s::clientNum, cg_t::predictedPlayerState, cg_t::radarEntities, and cg_t::radarEntityCount.

Referenced by CG_DrawAutoMap().

02249 {
02250         int i = 0;
02251 
02252         //first add yourself
02253         CG_AddRefentForAutoMap(&cg_entities[cg.predictedPlayerState.clientNum]);
02254 
02255         while (i < cg.radarEntityCount)
02256         {
02257                 CG_AddRefentForAutoMap(&cg_entities[cg.radarEntities[i]]);
02258                 i++;
02259         }
02260 }

void CG_CalcEntityLerpPositions centity_t cent  ) 
 

Definition at line 3064 of file cg_ents.c.

References trace_t::allsolid, entityState_s::apos, BG_EvaluateTrajectory(), centity_t, cg, CG_AdjustPositionForMover(), cg_entities, cg_smoothClients, CG_Trace(), CLASS_VEHICLE, playerState_s::clientNum, centity_s::currentState, DEFAULT_MAXS_2, DEFAULT_MINS_2, EF_DEAD, EF_RAG, entityState_s::eFlags, ET_NPC, entityState_s::eType, trace_t::fraction, entityState_s::groundEntityNum, vmCvar_t::integer, centity_s::interpolate, centity_s::isRagging, centity_s::lerpAngles, centity_s::lerpOrigin, playerState_s::m_iVehicleNum, MASK_PLAYERSOLID, MAX_CLIENTS, centity_s::nextState, entityState_s::NPC_class, entityState_s::number, entityState_s::owner, playerMaxs, playerMins, entityState_s::pos, cg_t::predictedPlayerState, qboolean, qfalse, qtrue, snapshot_t::serverTime, cg_t::snap, trace_t::startsolid, cg_t::time, TR_INTERPOLATE, TR_LINEAR_STOP, trajectory_t::trType, vec3_t, VectorAdd, VectorClear, VectorCopy, VectorMA, and VectorNormalize().

Referenced by vmMain().

03064                                                    {
03065         qboolean goAway = qfalse;
03066 
03067         // if this player does not want to see extrapolated players
03068         if ( !cg_smoothClients.integer ) {
03069                 // make sure the clients use TR_INTERPOLATE
03070                 if ( cent->currentState.number < MAX_CLIENTS ) {
03071                         cent->currentState.pos.trType = TR_INTERPOLATE;
03072                         cent->nextState.pos.trType = TR_INTERPOLATE;
03073                 }
03074         }
03075 
03076         if (cg.predictedPlayerState.m_iVehicleNum &&
03077                 cg.predictedPlayerState.m_iVehicleNum == cent->currentState.number &&
03078                 cent->currentState.eType == ET_NPC && cent->currentState.NPC_class == CLASS_VEHICLE)
03079         { //special case for vehicle we are riding
03080                 centity_t *veh = &cg_entities[cg.predictedPlayerState.m_iVehicleNum];
03081 
03082                 if (veh->currentState.owner == cg.predictedPlayerState.clientNum)
03083                 { //only do this if the vehicle is pilotted by this client and predicting properly
03084                         BG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
03085                         BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
03086                         return;
03087                 }
03088         }
03089 
03090         if ( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) {
03091                 CG_InterpolateEntityPosition( cent );
03092                 return;
03093         }
03094 
03095         // first see if we can interpolate between two snaps for
03096         // linear extrapolated clients
03097         if ( cent->interpolate && cent->currentState.pos.trType == TR_LINEAR_STOP &&
03098                                                                                         cent->currentState.number < MAX_CLIENTS) {
03099                 CG_InterpolateEntityPosition( cent );
03100                 goAway = qtrue;
03101         }
03102         else if (cent->interpolate &&
03103                 cent->currentState.eType == ET_NPC && cent->currentState.NPC_class == CLASS_VEHICLE)
03104         {
03105                 CG_InterpolateEntityPosition( cent );
03106                 goAway = qtrue;
03107         }
03108         else
03109         {
03110                 // just use the current frame and evaluate as best we can
03111                 BG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
03112                 BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
03113         }
03114 
03115 #if 0
03116         if (cent->hasRagOffset && cent->ragOffsetTime < cg.time)
03117         { //take all of the offsets from last frame and normalize the total direction and add it in
03118                 vec3_t slideDir;
03119                 vec3_t preOffset;
03120                 vec3_t addedOffset;
03121                 vec3_t  playerMins = {-15, -15, DEFAULT_MINS_2};
03122                 vec3_t  playerMaxs = {15, 15, DEFAULT_MAXS_2};
03123                 trace_t tr;
03124 
03125                 //VectorSubtract(cent->lerpOrigin, callData->bonePos, slideDir);
03126                 VectorCopy(cent->ragOffsets, slideDir);
03127                 VectorNormalize(slideDir);
03128 
03129                 //Store it in case we want to go back
03130                 VectorCopy(cent->lerpOriginOffset, preOffset);
03131 
03132                 //just add a little at a time
03133                 VectorMA(cent->lerpOriginOffset, 0.4f, slideDir, cent->lerpOriginOffset);
03134 
03135                 if (VectorLength(cent->lerpOriginOffset) > 10.0f)
03136                 { //don't go too far away
03137                         VectorCopy(preOffset, cent->lerpOriginOffset);
03138                 }
03139                 else
03140                 {
03141                         //Let's trace there to make sure we can make it
03142                         VectorAdd(cent->lerpOrigin, cent->lerpOriginOffset, addedOffset);
03143                         CG_Trace(&tr, cent->lerpOrigin, playerMins, playerMaxs, addedOffset, cent->currentState.number, MASK_PLAYERSOLID);
03144 
03145                         if (tr.startsolid || tr.allsolid || tr.fraction != 1.0f)
03146                         { //can't get there
03147                                 VectorCopy(preOffset, cent->lerpOriginOffset);
03148                         }
03149                         else
03150                         {
03151                                 /*
03152                                 if (cent->lerpOriginOffset[2] > 4.0f)
03153                                 { //don't go too far off the ground
03154                                         cent->lerpOriginOffset[2] = 4.0f;
03155                                 }
03156                                 */
03157                                 //I guess I just don't want this happening.
03158                                 cent->lerpOriginOffset[2] = 0.0f;
03159                         }
03160                 }
03161 
03162                 //done with this bit
03163                 cent->hasRagOffset = qfalse;
03164                 VectorClear(cent->ragOffsets);
03165                 cent->ragOffsetTime = cg.time + 50;
03166         }
03167 
03168         //See if we should add in the offset for ragdoll
03169         if (cent->isRagging && ((cent->currentState.eFlags & EF_DEAD) || (cent->currentState.eFlags & EF_RAG)))
03170         {
03171                 VectorAdd(cent->lerpOrigin, cent->lerpOriginOffset, cent->lerpOrigin);
03172         }
03173 #endif
03174 
03175         if (goAway)
03176         {
03177                 return;
03178         }
03179 
03180         // adjust for riding a mover if it wasn't rolled into the predicted
03181         // player state
03182         if ( cent->currentState.number != cg.predictedPlayerState.clientNum ) {
03183                 CG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum, 
03184                 cg.snap->serverTime, cg.time, cent->lerpOrigin );
03185         }
03186 }

qboolean CG_CalcFOVFromX float  fov_x  ) 
 

Definition at line 1130 of file cg_view.c.

References atan2(), cg, refdef_t::fov_x, refdef_t::fov_y, refdef_t::height, M_PI, qboolean, qfalse, cg_t::refdef, tan(), and refdef_t::width.

01131 {
01132         float   x;
01133 //      float   phase;
01134 //      float   v;
01135 //      int             contents;
01136         float   fov_y;
01137         qboolean        inwater;
01138 
01139         x = cg.refdef.width / tan( fov_x / 360 * M_PI );
01140         fov_y = atan2( cg.refdef.height, x );
01141         fov_y = fov_y * 360 / M_PI;
01142 
01143         // there's a problem with this, it only takes the leafbrushes into account, not the entity brushes,
01144         //      so if you give slime/water etc properties to a func_door area brush in order to move the whole water 
01145         //      level up/down this doesn't take into account the door position, so warps the view the whole time
01146         //      whether the water is up or not. Fortunately there's only one slime area in Trek that you can be under,
01147         //      so lose it...
01148 #if 0
01149 /*
01150         // warp if underwater
01151         contents = CG_PointContents( cg.refdef.vieworg, -1 );
01152         if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ){
01153                 phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
01154                 v = WAVE_AMPLITUDE * sin( phase );
01155                 fov_x += v;
01156                 fov_y -= v;
01157                 inwater = qtrue;
01158         }
01159         else {
01160                 inwater = qfalse;
01161         }
01162 */
01163 #else
01164         inwater = qfalse;
01165 #endif
01166 
01167 
01168         // set it
01169         cg.refdef.fov_x = fov_x;
01170         cg.refdef.fov_y = fov_y;
01171 
01172 #ifdef _XBOX
01173         if(cg.widescreen)
01174                 cg.refdef.fov_x *= 1.125f;
01175 #endif
01176 
01177         return (inwater);
01178 }

void CG_CalcScreenEffects void   ) 
 

Definition at line 2096 of file cg_view.c.

References cg, CG_SE_UpdateMusic(), CG_SE_UpdateShake(), cg_t::refdef, refdef_t::viewangles, and refdef_t::vieworg.

Referenced by CG_DrawActiveFrame().

qboolean CG_CheckPassengerTurretView void   ) 
 

Definition at line 1477 of file cg_view.c.

References AnglesSubtract(), centity_t, cg, cg_entities, cg_lastTurretViewAngles, cg_t::frametime, playerState_s::generic1, centity_s::ghoul2, turretStats_t::iAmmoMax, centity_s::lerpAngles, centity_s::lerpOrigin, Vehicle_s::m_iGunnerViewTag, playerState_s::m_iVehicleNum, centity_s::m_pVehicle, Vehicle_s::m_pVehicleInfo, MAX_VEHICLE_TURRETS, vehicleInfo_t::maxPassengers, centity_s::modelScale, NEGATIVE_X, NEGATIVE_Y, NULL, ORIGIN, turretStats_t::passengerNum, turretStats_t::pitchBone, cg_t::predictedPlayerState, qboolean, qfalse, qtrue, cg_t::refdef, cg_t::time, trap_G2API_AddBolt(), trap_G2API_GetBoltMatrix_NoRecNoRot(), vehicleInfo_t::turret, vec3_t, vectoangles(), VectorMA, refdef_t::viewangles, refdef_t::vieworg, and turretStats_t::yawBone.

01478 {
01479         if ( cg.predictedPlayerState.m_iVehicleNum //in a vehicle
01480                 && cg.predictedPlayerState.generic1 )//as a passenger
01481         {//passenger in a vehicle
01482                 centity_t *vehCent = &cg_entities[cg.predictedPlayerState.m_iVehicleNum];
01483                 if ( vehCent->m_pVehicle
01484                         && vehCent->m_pVehicle->m_pVehicleInfo 
01485                         && vehCent->m_pVehicle->m_pVehicleInfo->maxPassengers )
01486                 {//a vehicle capable of carrying passengers
01487                         int turretNum;
01488                         for ( turretNum = 0; turretNum < MAX_VEHICLE_TURRETS; turretNum++ )
01489                         {
01490                                 if ( vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].iAmmoMax )
01491                                 {// valid turret
01492                                         if ( vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].passengerNum == cg.predictedPlayerState.generic1 )
01493                                         {//I control this turret
01494                                                 int boltIndex = -1;
01495                                                 qboolean hackPosAndAngle = qfalse;
01496                                                 if ( vehCent->m_pVehicle->m_iGunnerViewTag[turretNum] != -1 )
01497                                                 {
01498                                                         boltIndex = vehCent->m_pVehicle->m_iGunnerViewTag[turretNum];
01499                                                 }
01500                                                 else
01501                                                 {//crap... guess?
01502                                                         hackPosAndAngle = qtrue;
01503                                                         if ( vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].yawBone )
01504                                                         {
01505                                                                 boltIndex = trap_G2API_AddBolt( vehCent->ghoul2, 0, vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].yawBone );
01506                                                         }
01507                                                         else if ( vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].pitchBone )
01508                                                         {
01509                                                                 boltIndex = trap_G2API_AddBolt( vehCent->ghoul2, 0, vehCent->m_pVehicle->m_pVehicleInfo->turret[turretNum].pitchBone );
01510                                                         }
01511                                                         else
01512                                                         {//well, no way of knowing, so screw it
01513                                                                 return qfalse;
01514                                                         }
01515                                                 }
01516                                                 if ( boltIndex != -1 )
01517                                                 {
01518                                                         mdxaBone_t boltMatrix;
01519                                                         vec3_t fwd, up;
01520                                                         trap_G2API_GetBoltMatrix_NoRecNoRot(vehCent->ghoul2, 0, boltIndex, &boltMatrix, vehCent->lerpAngles,
01521                                                                 vehCent->lerpOrigin, cg.time, NULL, vehCent->modelScale);
01522                                                         BG_GiveMeVectorFromMatrix(&boltMatrix, ORIGIN, cg.refdef.vieworg);
01523                                                         if ( hackPosAndAngle )
01524                                                         {
01525                                                                 //FIXME: these are assumptions, externalize?  BETTER YET: give me a controller view bolt/tag for each turret
01526                                                                 BG_GiveMeVectorFromMatrix(&boltMatrix, NEGATIVE_X, fwd);
01527                                                                 BG_GiveMeVectorFromMatrix(&boltMatrix, NEGATIVE_Y, up);
01528                                                                 VectorMA( cg.refdef.vieworg, 8.0f, fwd, cg.refdef.vieworg );
01529                                                                 VectorMA( cg.refdef.vieworg, 4.0f, up, cg.refdef.vieworg );
01530                                                         }
01531                                                         else
01532                                                         {
01533                                                                 BG_GiveMeVectorFromMatrix(&boltMatrix, NEGATIVE_Y, fwd);
01534                                                         }
01535                                                         {
01536                                                                 vec3_t  newAngles, deltaAngles;
01537                                                                 vectoangles( fwd, newAngles );
01538                                                                 AnglesSubtract( newAngles, cg_lastTurretViewAngles, deltaAngles );
01539                                                                 VectorMA( cg_lastTurretViewAngles, 0.5f*(float)cg.frametime/100.0f, deltaAngles, cg.refdef.viewangles );
01540                                                         }
01541                                                         return qtrue;
01542                                                 }
01543                                         }
01544                                 }
01545                         }
01546                 }
01547         }
01548         return qfalse;
01549 }

void CG_DoCameraShake vec3_t  origin,
float  intensity,
int  radius,
int  time
 

Definition at line 2121 of file cg_view.c.

References cg, CGCam_Shake(), cg_t::refdef, vec3_t, VectorNormalize(), VectorSubtract, and refdef_t::vieworg.

Referenced by vmMain().

02122 {
02123         //FIXME: When exactly is the vieworg calculated in relation to the rest of the frame?s
02124 
02125         vec3_t  dir;
02126         float   dist, intensityScale;
02127         float   realIntensity;
02128 
02129         VectorSubtract( cg.refdef.vieworg, origin, dir );
02130         dist = VectorNormalize( dir );
02131 
02132         //Use the dir to add kick to the explosion
02133 
02134         if ( dist > radius )
02135                 return;
02136 
02137         intensityScale = 1 - ( dist / (float) radius );
02138         realIntensity = intensity * intensityScale;
02139 
02140         CGCam_Shake( realIntensity, time );
02141 }

void CG_DrawActiveFrame int  serverTime,
stereoFrame_t  stereoView,
qboolean  demoPlayback
 

Definition at line 2439 of file cg_view.c.

References AnglesToAxis(), snapshot_t::areamask, refdef_t::areamask, bg_fighterAltControl, BG_InGrappleMove(), BG_VehicleTurnRateForSpeed(), bgSiegeClasses, centity_t, cg, CG_ActualLoadDeferredPlayers(), CG_AddLagometerFrameInfo(), CG_AddLocalEntities(), CG_AddMarks(), CG_AddPacketEntities(), CG_AddParticles(), CG_AddViewWeapon(), CG_CalcScreenEffects(), CG_ConfigString(), CG_DrawActive(), CG_DrawAutoMap(), CG_DrawInformation(), CG_DrawMiscEnts(), CG_DrawSkyBoxPortal(), cg_entities, cg_fpls, CG_GetStringEdString(), cg_linearFogOverride, CG_PredictPlayerState(), CG_Printf(), CG_ProcessSnapshots(), CG_RunLightStyles(), cg_snapshotTimeout, cg_stats, cg_thirdPerson, cg_timescale, cg_timescaleFadeEnd, cg_timescaleFadeSpeed, CG_UpdateCvars(), CG_UpdateSoundTrackers(), cgQueueLoad, cgs, CLASS_VEHICLE, cg_t::clientFrame, cgs_t::clientinfo, playerState_s::clientNum, Com_Error(), CS_GLOBAL_AMBIENT_SET, CS_SKYBOXORG, centity_s::currentState, cg_t::demoPlayback, playerState_s::emplacedIndex, ERR_DROP, ET_NPC, entityState_s::eType, playerState_s::fallingToDeath, playerState_s::forceHandExtend, cg_t::forceSelect, refdef_t::fov_x, cg_t::frametime, cgs_t::gametype, gCGFallVector, gCGHasFallVector, playerState_s::generic1, GT_SIEGE, HANDEXTEND_KNOCKDOWN, refEntity_t::hModel, cg_t::hyperspace, cg_t::infoScreenText, vmCvar_t::integer, cg_t::itemSelect, playerState_s::legsAnim, playerState_s::m_iVehicleNum, centity_s::m_pVehicle, Vehicle_s::m_pVehicleInfo, memcpy(), name, entityState_s::NPC_class, NULL, cg_t::oldTime, playerState_s::origin, PERS_TEAM, playerState_s::persistant, PM_InKnockDown(), PM_SPECTATOR, playerState_s::pm_type, cg_t::predictedPlayerState, snapshot_t::ps, qboolean, qfalse, qtrue, cg_t::refdef, cg_t::renderingThirdPerson, playerState_s::saberLockTime, cg_t::snap, SNAPFLAG_NOT_ACTIVE, snapshot_t::snapFlags, entityState_s::speed, STAT_HEALTH, playerState_s::stats, STEREO_RIGHT, stereoFrame_t, TEAM_SPECTATOR, cg_t::testModelEntity, refdef_t::time, cg_t::time, playerState_s::torsoAnim, trap_Cvar_Set(), trap_FX_AddScheduledEffects(), trap_FX_AdjustTime(), trap_Milliseconds(), trap_R_ClearScene(), trap_R_SetRangeFog(), trap_ROFF_UpdateEntities(), trap_S_ClearLoopingSounds(), trap_S_Respatialize(), trap_S_UpdateAmbientSet(), trap_SetUserCmdValue(), vehicleInfo_t::type, ui_myteam, va(), vmCvar_t::value, vec3_t, vectoangles(), VectorCopy, VectorNormalize(), VectorSubtract, VH_FIGHTER, refdef_t::viewaxis, refdef_t::vieworg, playerState_s::weapon, cg_t::weaponSelect, WP_EMPLACED_GUN, WP_MELEE, WP_SABER, playerState_s::zoomMode, and cg_t::zoomSensitivity.

Referenced by vmMain().

02439                                                                                            {
02440         int             inwater;
02441         const char *cstr;
02442         float mSensitivity = cg.zoomSensitivity;
02443         float mPitchOverride = 0.0f;
02444         float mYawOverride = 0.0f;
02445         static centity_t *veh = NULL;
02446 #ifdef VEH_CONTROL_SCHEME_4
02447         float mSensitivityOverride = 0.0f;
02448         qboolean bUseFighterPitch = qfalse;
02449         qboolean        isFighter = qfalse;
02450 #endif
02451 
02452         if (cgQueueLoad)
02453         { //do this before you start messing around with adding ghoul2 refents and crap
02454                 CG_ActualLoadDeferredPlayers();
02455                 cgQueueLoad = qfalse;
02456         }
02457 
02458         cg.time = serverTime;
02459         cg.demoPlayback = demoPlayback;
02460 
02461         if (cg.snap && ui_myteam.integer != cg.snap->ps.persistant[PERS_TEAM])
02462         {
02463                 trap_Cvar_Set ( "ui_myteam", va("%i", cg.snap->ps.persistant[PERS_TEAM]) );
02464         }
02465         if (cgs.gametype == GT_SIEGE &&
02466                 cg.snap &&
02467                 cg_siegeClassIndex != cgs.clientinfo[cg.snap->ps.clientNum].siegeIndex)
02468         {
02469                 cg_siegeClassIndex = cgs.clientinfo[cg.snap->ps.clientNum].siegeIndex;
02470                 if (cg_siegeClassIndex == -1)
02471                 {
02472                         trap_Cvar_Set("ui_mySiegeClass", "<none>");
02473                 }
02474                 else
02475                 {
02476                         trap_Cvar_Set("ui_mySiegeClass", bgSiegeClasses[cg_siegeClassIndex].name);
02477                 }
02478         }
02479 
02480         // update cvars
02481         CG_UpdateCvars();
02482 
02483         // if we are only updating the screen as a loading
02484         // pacifier, don't even try to read snapshots
02485         if ( cg.infoScreenText[0] != 0 ) {
02486                 CG_DrawInformation();
02487                 return;
02488         }
02489 
02490         trap_FX_AdjustTime( cg.time );
02491 
02492         CG_RunLightStyles();
02493 
02494         // any looped sounds will be respecified as entities
02495         // are added to the render list
02496         trap_S_ClearLoopingSounds();
02497 
02498         // clear all the render lists
02499         trap_R_ClearScene();
02500 
02501         // set up cg.snap and possibly cg.nextSnap
02502         CG_ProcessSnapshots();
02503 
02504         trap_ROFF_UpdateEntities();
02505 
02506         // if we haven't received any snapshots yet, all
02507         // we can draw is the information screen
02508         if ( !cg.snap || ( cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) )
02509         {
02510 #if 0   
02511                 // Transition from zero to negative one on the snapshot timeout.
02512                 // The reason we do this is because the first client frame is responsible for
02513                 // some farily slow processing (such as weather) and we dont want to include
02514                 // that processing time into our calculations
02515                 if ( !cg.snapshotTimeoutTime )
02516                 {
02517                         cg.snapshotTimeoutTime = -1;
02518                 }
02519                 // Transition the snapshot timeout time from -1 to the current time in 
02520                 // milliseconds which will start the timeout.
02521                 else if ( cg.snapshotTimeoutTime == -1 )
02522                 {               
02523                         cg.snapshotTimeoutTime = trap_Milliseconds ( );
02524                 }
02525 
02526                 // If we have been waiting too long then just error out
02527                 if ( cg.snapshotTimeoutTime > 0 && (trap_Milliseconds ( ) - cg.snapshotTimeoutTime > cg_snapshotTimeout.integer * 1000) )
02528                 {
02529                         Com_Error ( ERR_DROP, CG_GetStringEdString("MP_SVGAME", "SNAPSHOT_TIMEOUT"));
02530                         return;
02531                 }
02532 #endif  
02533                 CG_DrawInformation();
02534                 return;
02535         }
02536 
02537         // let the client system know what our weapon and zoom settings are
02538         if (cg.snap && cg.snap->ps.saberLockTime > cg.time)
02539         {
02540                 mSensitivity = 0.01f;
02541         }
02542         else if (cg.predictedPlayerState.weapon == WP_EMPLACED_GUN)
02543         { //lower sens for emplaced guns and vehicles
02544                 mSensitivity = 0.2f;
02545         }
02546 #ifdef VEH_CONTROL_SCHEME_4
02547         else if (cg.predictedPlayerState.m_iVehicleNum//in a vehicle
02548                 && !cg.predictedPlayerState.generic1 )//not as a passenger
02549         {
02550                 centity_t *cent = &cg_entities[cg.predictedPlayerState.m_iVehicleNum];
02551                 if ( cent->m_pVehicle
02552                         && cent->m_pVehicle->m_pVehicleInfo
02553                         && cent->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER )
02554                 {
02555                         BG_VehicleTurnRateForSpeed( cent->m_pVehicle, cent->currentState.speed, &mPitchOverride, &mYawOverride );
02556                         //mSensitivityOverride = 5.0f;//old default value
02557                         mSensitivityOverride = 0.0f;
02558                         bUseFighterPitch = qtrue;
02559                         trap_SetUserCmdValue( cg.weaponSelect, mSensitivity, mPitchOverride, mYawOverride, mSensitivityOverride, cg.forceSelect, cg.itemSelect, bUseFighterPitch );
02560                         isFighter = qtrue;
02561                 }
02562         } 
02563 
02564         if ( !isFighter )
02565 #endif //VEH_CONTROL_SCHEME_4
02566         {
02567                 if (cg.predictedPlayerState.m_iVehicleNum)
02568                 {
02569                         veh = &cg_entities[cg.predictedPlayerState.m_iVehicleNum];
02570                 }
02571                 if (veh &&
02572                         veh->currentState.eType == ET_NPC &&
02573                         veh->currentState.NPC_class == CLASS_VEHICLE &&
02574                         veh->m_pVehicle &&
02575                         veh->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER &&
02576                         bg_fighterAltControl.integer)
02577                 {
02578                         trap_SetUserCmdValue( cg.weaponSelect, mSensitivity, mPitchOverride, mYawOverride, 0.0f, cg.forceSelect, cg.itemSelect, qtrue );
02579                         veh = NULL; //this is done because I don't want an extra assign each frame because I am so perfect and super efficient.
02580                 }
02581                 else
02582                 {
02583                         trap_SetUserCmdValue( cg.weaponSelect, mSensitivity, mPitchOverride, mYawOverride, 0.0f, cg.forceSelect, cg.itemSelect, qfalse );
02584                 }
02585         }
02586 
02587         // this counter will be bumped for every valid scene we generate
02588         cg.clientFrame++;
02589 
02590         // update cg.predictedPlayerState
02591         CG_PredictPlayerState();
02592 
02593         // decide on third person view
02594         cg.renderingThirdPerson = cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0);
02595 
02596         if (cg.snap->ps.stats[STAT_HEALTH] > 0)
02597         {
02598                 if (cg.predictedPlayerState.weapon == WP_EMPLACED_GUN && cg.predictedPlayerState.emplacedIndex /*&&
02599                         cg_entities[cg.predictedPlayerState.emplacedIndex].currentState.weapon == WP_NONE*/)
02600                 { //force third person for e-web and emplaced use
02601                         cg.renderingThirdPerson = 1;
02602                 }
02603                 else if (cg.predictedPlayerState.weapon == WP_SABER || cg.predictedPlayerState.weapon == WP_MELEE ||
02604                         BG_InGrappleMove(cg.predictedPlayerState.torsoAnim) || BG_InGrappleMove(cg.predictedPlayerState.legsAnim) ||
02605                         cg.predictedPlayerState.forceHandExtend == HANDEXTEND_KNOCKDOWN || cg.predictedPlayerState.fallingToDeath ||
02606                         cg.predictedPlayerState.m_iVehicleNum || PM_InKnockDown(&cg.predictedPlayerState))
02607                 {
02608                         if (cg_fpls.integer && cg.predictedPlayerState.weapon == WP_SABER)
02609                         { //force to first person for fpls
02610                                 cg.renderingThirdPerson = 0;
02611                         }
02612                         else
02613                         {
02614                                 cg.renderingThirdPerson = 1;
02615                         }
02616                 }
02617                 else if (cg.snap->ps.zoomMode)
02618                 { //always force first person when zoomed
02619                         cg.renderingThirdPerson = 0;
02620                 }
02621         }
02622         
02623         if (cg.predictedPlayerState.pm_type == PM_SPECTATOR)
02624         { //always first person for spec
02625                 cg.renderingThirdPerson = 0;
02626         }
02627 
02628 
02629         if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR)
02630         {
02631                 cg.renderingThirdPerson = 0;
02632         }
02633 
02634         // build cg.refdef
02635         inwater = CG_CalcViewValues();
02636 
02637         if (cg_linearFogOverride)
02638         {
02639                 trap_R_SetRangeFog(-cg_linearFogOverride);
02640         }
02641         else if (cg.predictedPlayerState.zoomMode)
02642         { //zooming with binoculars or sniper, set the fog range based on the zoom level -rww
02643                 cg_rangedFogging = qtrue;
02644                 //smaller the fov the less fog we have between the view and cull dist
02645                 trap_R_SetRangeFog(cg.refdef.fov_x*64.0f);
02646         }
02647         else if (cg_rangedFogging)
02648         { //disable it
02649                 cg_rangedFogging = qfalse;
02650                 trap_R_SetRangeFog(0.0f);
02651         }
02652 
02653         cstr = CG_ConfigString(CS_SKYBOXORG);
02654 
02655         if (cstr && cstr[0])
02656         { //we have a skyportal
02657                 CG_DrawSkyBoxPortal(cstr);
02658         }
02659 
02660         CG_CalcScreenEffects();
02661 
02662         // first person blend blobs, done after AnglesToAxis
02663         if ( !cg.renderingThirdPerson && cg.predictedPlayerState.pm_type != PM_SPECTATOR ) {
02664                 CG_DamageBlendBlob();
02665         }
02666 
02667         // build the render lists
02668         if ( !cg.hyperspace ) {
02669                 CG_AddPacketEntities(qfalse);                   // adter calcViewValues, so predicted player state is correct
02670                 CG_AddMarks();
02671                 CG_AddParticles ();
02672                 CG_AddLocalEntities();
02673                 CG_DrawMiscEnts();
02674         }
02675         CG_AddViewWeapon( &cg.predictedPlayerState );
02676 
02677         if ( !cg.hyperspace) 
02678