codemp/cgame/cg_ents.c File Reference

#include "cg_local.h"
#include "..\game\q_shared.h"
#include "..\ghoul2\g2.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Functions

qboolean CG_InFighter (void)
void CG_PositionEntityOnTag (refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName)
void CG_PositionRotatedEntityOnTag (refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName)
void CG_SetEntitySoundPosition (centity_t *cent)
void CG_S_AddLoopingSound (int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx)
void CG_S_AddRealLoopingSound (int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx)
void CG_S_StopLoopingSound (int entityNum, sfxHandle_t sfx)
void CG_S_UpdateLoopingSounds (int entityNum)
localEntity_tFX_AddOrientedLine (vec3_t start, vec3_t end, vec3_t normal, float stScale, float scale, float dscale, float startalpha, float endalpha, float killTime, qhandle_t shader)
void FX_DrawPortableShield (centity_t *cent)
void CG_Special (centity_t *cent)
void CG_SetGhoul2Info (refEntity_t *ent, centity_t *cent)
void CG_CreateBBRefEnts (entityState_t *s1, vec3_t origin)
void G2_BoltToGhoul2Model (centity_t *cent, refEntity_t *ent)
void ScaleModelAxis (refEntity_t *ent)
void CG_Disintegration (centity_t *cent, refEntity_t *ent)
void CG_AddRadarEnt (centity_t *cent)
void CG_AddBracketedEnt (centity_t *cent)
void CG_G2ServerBoneAngles (centity_t *cent)
qboolean BG_GetRootSurfNameWithVariant (void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize)
qboolean CG_GreyItem (int type, int tag, int plSide)
void CG_CreateDistortionTrailPart (centity_t *cent, float scale, vec3_t pos)
void CG_PlayDoorLoopSound (centity_t *cent)
void CG_PlayDoorSound (centity_t *cent, int type)
void CG_Beam (centity_t *cent)
void CG_AdjustPositionForMover (const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out)
void CG_CalcEntityLerpPositions (centity_t *cent)
void CG_G2Animated (centity_t *cent)
void CG_ManualEntityRender (centity_t *cent)
void CG_AddPacketEntities (qboolean isPortal)
void CG_ROFF_NotetrackCallback (centity_t *cent, const char *notetrack)
void CG_Cube (vec3_t mins, vec3_t maxs, vec3_t color, float alpha)

Variables

char * forceHolocronModels []
int cgSiegeEntityRender
int CG_BMS_START = 0
int CG_BMS_MID = 1
int CG_BMS_END = 2


Function Documentation

qboolean BG_GetRootSurfNameWithVariant void *  ghoul2,
const char *  rootSurfName,
char *  returnSurfName,
int  returnSize
 

Definition at line 101 of file bg_g2_utils.c.

00102 {
00103         if ( !ghoul2 || !trap_G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) )
00104         {//see if the basic name without variants is on
00105                 Q_strncpyz( returnSurfName, rootSurfName, returnSize );
00106                 return qtrue;
00107         }
00108         else
00109         {//check variants
00110                 int i;
00111                 for ( i = 0; i < MAX_VARIANTS; i++ )
00112                 {
00113                         Com_sprintf( returnSurfName, returnSize, "%s%c", rootSurfName, 'a'+i );
00114                         if ( !trap_G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) )
00115                         {
00116                                 return qtrue;
00117                         }
00118                 }
00119         }
00120         Q_strncpyz( returnSurfName, rootSurfName, returnSize );
00121         return qfalse;
00122 }

void CG_AddBracketedEnt centity_t cent  ) 
 

Definition at line 811 of file cg_ents.c.

References cg_t::bracketedEntities, cg_t::bracketedEntityCount, centity_t, cg, Com_Printf(), centity_s::currentState, entityState_s::number, and cg_t::radarEntities.

Referenced by CG_Player().

00812 {
00813         if (cg.bracketedEntityCount == sizeof(cg.bracketedEntities)/sizeof(cg.bracketedEntities[0]))
00814         {       
00815 #ifdef _DEBUG
00816                 Com_Printf("^3Warning: CG_AddBracketedEnt full. (%d max)\n", sizeof(cg.radarEntities)/sizeof(cg.bracketedEntities[0]));
00817 #endif
00818                 return;
00819         }
00820         cg.bracketedEntities[cg.bracketedEntityCount++] = cent->currentState.number;
00821 }

void CG_AddPacketEntities qboolean  isPortal  ) 
 

Definition at line 3412 of file cg_ents.c.

References AnglesToAxis(), cg_t::autoAngles, cg_t::autoAnglesFast, cg_t::autoAxis, cg_t::autoAxisFast, BG_PlayerStateToEntityState(), centity_s::bodyHeight, cg_t::bracketedEntityCount, centity_t, cg, CG_CheckPlayerG2Weapons(), cg_entities, cg_numpermanents, cg_permanents, playerState_s::clientNum, centity_s::currentState, centity_s::currentValid, snapshot_t::entities, ET_NPC, ET_PLAYER, entityState_s::eType, cg_t::frameInterpolation, entityState_s::isPortalEnt, playerState_s::m_iVehicleNum, entityState_s::m_iVehicleNum, cg_t::nextSnap, entityState_s::number, snapshot_t::numEntities, entityState_s::owner, playerState_t, entityState_s::pos, cg_t::predictedPlayerState, cg_t::predictedVehicleState, snapshot_t::ps, qfalse, cg_t::radarEntityCount, snapshot_t::serverTime, cg_t::snap, cg_t::time, TR_INTERPOLATE, and trajectory_t::trType.

Referenced by CG_DrawActiveFrame(), and CG_DrawSkyBoxPortal().

03412                                                {
03413         int                                     num;
03414         centity_t                       *cent;
03415         playerState_t           *ps;
03416 
03417         if (isPortal)
03418         {
03419                 for ( num = 0 ; num < cg.snap->numEntities ; num++ )
03420                 {
03421                         cent = &cg_entities[ cg.snap->entities[ num ].number ];
03422 
03423                         if (cent->currentState.isPortalEnt)
03424                         {
03425                                 CG_AddCEntity( cent );
03426                         }
03427                 }
03428                 return;
03429         }
03430 
03431         // set cg.frameInterpolation
03432         if ( cg.nextSnap ) {
03433                 int             delta;
03434 
03435                 delta = (cg.nextSnap->serverTime - cg.snap->serverTime);
03436                 if ( delta == 0 ) {
03437                         cg.frameInterpolation = 0;
03438                 } else {
03439                         cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta;
03440                 }
03441         } else {
03442                 cg.frameInterpolation = 0;      // actually, it should never be used, because 
03443                                                                         // no entities should be marked as interpolating
03444         }
03445 
03446         // the auto-rotating items will all have the same axis
03447         cg.autoAngles[0] = 0;
03448         cg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0;
03449         cg.autoAngles[2] = 0;
03450 
03451         cg.autoAnglesFast[0] = 0;
03452         cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f;
03453         cg.autoAnglesFast[2] = 0;
03454 
03455         AnglesToAxis( cg.autoAngles, cg.autoAxis );
03456         AnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast );
03457 
03458         // Reset radar entities
03459         cg.radarEntityCount = 0;
03460         cg.bracketedEntityCount = 0;
03461 
03462         // generate and add the entity from the playerstate
03463         ps = &cg.predictedPlayerState;
03464 
03465         CG_CheckPlayerG2Weapons(ps, &cg_entities[cg.predictedPlayerState.clientNum]);
03466         BG_PlayerStateToEntityState( ps, &cg_entities[cg.predictedPlayerState.clientNum].currentState, qfalse );
03467         
03468         if (cg.predictedPlayerState.m_iVehicleNum)
03469         { //add the vehicle I'm riding first
03470                 //BG_PlayerStateToEntityState( &cg.predictedVehicleState, &cg_entities[cg.predictedPlayerState.m_iVehicleNum].currentState, qfalse );
03471                 //cg_entities[cg.predictedPlayerState.m_iVehicleNum].currentState.eType = ET_NPC;
03472                 centity_t *veh = &cg_entities[cg.predictedPlayerState.m_iVehicleNum];
03473 
03474                 if (veh->currentState.owner == cg.predictedPlayerState.clientNum)
03475                 {
03476                         BG_PlayerStateToEntityState( &cg.predictedVehicleState, &veh->currentState, qfalse );
03477                         veh->currentState.eType = ET_NPC;
03478 
03479                         veh->currentState.pos.trType = TR_INTERPOLATE;
03480                 }
03481         CG_AddCEntity(veh);
03482                 veh->bodyHeight = cg.time; //indicate we have already been added
03483         }
03484 
03485         CG_AddCEntity( &cg_entities[cg.predictedPlayerState.clientNum] );
03486 
03487         /*
03488         // lerp the non-predicted value for lightning gun origins
03489         CG_CalcEntityLerpPositions( &cg_entities[ cg.snap->ps.clientNum ] );
03490         */
03491         //No longer have to do this.
03492 
03493         // add each entity sent over by the server
03494         for ( num = 0 ; num < cg.snap->numEntities ; num++ ) {
03495                 // Don't re-add ents that have been predicted.
03496                 if (cg.snap->entities[ num ].number != cg.snap->ps.clientNum)
03497                 {
03498                         cent = &cg_entities[ cg.snap->entities[ num ].number ];
03499                         if (cent->currentState.eType == ET_PLAYER &&
03500                                 cent->currentState.m_iVehicleNum)
03501                         { //add his veh first
03502                                 int j = 0;
03503 
03504                                 while (j < cg.snap->numEntities)
03505                                 {
03506                                         if (cg.snap->entities[j].number == cent->currentState.m_iVehicleNum)
03507                                         {
03508                                                 centity_t *veh = &cg_entities[cg.snap->entities[j].number];
03509 
03510                                                 CG_AddCEntity(veh);
03511                                                 veh->bodyHeight = cg.time; //indicate we have already been added
03512                                                 break;
03513                                         }
03514 
03515                                         j++;
03516                                 }
03517                         }
03518                         else if (cent->currentState.eType == ET_NPC &&
03519                                 cent->currentState.m_iVehicleNum &&
03520                                 cent->bodyHeight == cg.time)
03521                         { //never add a vehicle with a pilot, his pilot entity will get him added first.
03522                                 //if we were to add the vehicle after the pilot, the pilot's bolt would lag a frame behind.
03523                                 continue;
03524                         }
03525                         CG_AddCEntity( cent );
03526                 }
03527         }
03528 
03529         for(num=0;num<cg_numpermanents;num++)
03530         {
03531                 cent = cg_permanents[num];
03532                 if (cent->currentValid)
03533                 {
03534                         CG_AddCEntity( cent );
03535                 }
03536         }
03537 }

void CG_AddRadarEnt centity_t cent  ) 
 

Definition at line 799 of file cg_ents.c.

References centity_t, cg, Com_Printf(), centity_s::currentState, entityState_s::number, cg_t::radarEntities, and cg_t::radarEntityCount.

Referenced by CG_Player().

00800 {
00801         if (cg.radarEntityCount == sizeof(cg.radarEntities)/sizeof(cg.radarEntities[0]))
00802         {       
00803 #ifdef _DEBUG
00804                 Com_Printf("^3Warning: CG_AddRadarEnt full. (%d max)\n", sizeof(cg.radarEntities)/sizeof(cg.radarEntities[0]));
00805 #endif
00806                 return;
00807         }
00808         cg.radarEntities[cg.radarEntityCount++] = cent->currentState.number;
00809 }

void CG_AdjustPositionForMover const vec3_t  in,
int  moverNum,
int  fromTime,
int  toTime,
vec3_t  out
 

Definition at line 2994 of file cg_ents.c.

References entityState_s::apos, BG_EvaluateTrajectory(), centity_t, cg_entities, centity_s::currentState, ENTITYNUM_MAX_NORMAL, ET_MOVER, entityState_s::eType, entityState_s::pos, vec3_t, VectorAdd, VectorCopy, and VectorSubtract.

Referenced by CG_CalcEntityLerpPositions(), and CG_PredictPlayerState().

02994                                                                                                       {
02995         centity_t       *cent;
02996         vec3_t  oldOrigin, origin, deltaOrigin;
02997         vec3_t  oldAngles, angles, deltaAngles;
02998 
02999         if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {
03000                 VectorCopy( in, out );
03001                 return;
03002         }
03003 
03004         cent = &cg_entities[ moverNum ];
03005         if ( cent->currentState.eType != ET_MOVER ) {
03006                 VectorCopy( in, out );
03007                 return;
03008         }
03009 
03010         BG_EvaluateTrajectory( &cent->currentState.pos, fromTime, oldOrigin );
03011         BG_EvaluateTrajectory( &cent->currentState.apos, fromTime, oldAngles );
03012 
03013         BG_EvaluateTrajectory( &cent->currentState.pos, toTime, origin );
03014         BG_EvaluateTrajectory( &cent->currentState.apos, toTime, angles );
03015 
03016         VectorSubtract( origin, oldOrigin, deltaOrigin );
03017         VectorSubtract( angles, oldAngles, deltaAngles );
03018 
03019         VectorAdd( in, deltaOrigin, out );
03020 
03021         // FIXME: origin change when on a rotating object
03022 }

void CG_Beam centity_t cent  ) 
 

Definition at line 2921 of file cg_ents.c.

References refEntity_t::axis, AxisClear(), centity_t, CG_SetGhoul2Info(), centity_s::currentState, entityState_t, memset(), refEntity_t::oldorigin, refEntity_t::origin, entityState_s::origin2, entityState_s::pos, refEntity_t::renderfx, refEntity_t::reType, RF_NOSHADOW, RT_BEAM, trap_R_AddRefEntityToScene(), trajectory_t::trBase, and VectorCopy.

Referenced by CG_EntityEvent().

02921                                 {
02922         refEntity_t                     ent;
02923         entityState_t           *s1;
02924 
02925         s1 = &cent->currentState;
02926 
02927         // create the render entity
02928         memset (&ent, 0, sizeof(ent));
02929         VectorCopy( s1->pos.trBase, ent.origin );
02930         VectorCopy( s1->origin2, ent.oldorigin );
02931         AxisClear( ent.axis );
02932         ent.reType = RT_BEAM;
02933 
02934         ent.renderfx = RF_NOSHADOW;
02935 /*
02936 Ghoul2 Insert Start
02937 */
02938         CG_SetGhoul2Info(&ent, cent);  
02939 
02940 /*
02941 Ghoul2 Insert End
02942 */
02943         // add to refresh list
02944         trap_R_AddRefEntityToScene(&ent);
02945 }

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 }

void CG_CreateBBRefEnts entityState_t s1,
vec3_t  origin
 

Definition at line 502 of file cg_ents.c.

References entityState_t, and vec3_t.

00503 {
00504 /* 
00505 //g2r
00506 #if _DEBUG
00507         refEntity_t             point[8];
00508         int                             i;
00509         vec3_t                  angles = {0,0,0};
00510 
00511         for (i=0; i<8; i++)
00512         {
00513                 memset (&point[i], 0, sizeof(refEntity_t));
00514                 point[i].reType = RT_SPRITE;
00515                 point[i].radius = 1;
00516                 point[i].customShader = trap_R_RegisterShader("textures/tests/circle");
00517                 point[i].shaderRGBA[0] = 255;
00518                 point[i].shaderRGBA[1] = 255;
00519                 point[i].shaderRGBA[2] = 255;
00520                 point[i].shaderRGBA[3] = 255;
00521 
00522                 AnglesToAxis( angles, point[i].axis );
00523 
00524                 // now, we need to put the correct origins into each origin from the mins and max's
00525                 switch(i)
00526                 {
00527                 case 0:
00528                         VectorCopy(s1->mins, point[i].origin);
00529                         break;
00530                 case 1:
00531                         VectorCopy(s1->mins, point[i].origin);
00532                         point[i].origin[0] = s1->maxs[0];
00533                         break;
00534                 case 2:
00535                         VectorCopy(s1->mins, point[i].origin);
00536                         point[i].origin[1] = s1->maxs[1];
00537                         break;
00538                 case 3:
00539                         VectorCopy(s1->mins, point[i].origin);
00540                         point[i].origin[0] = s1->maxs[0];
00541                         point[i].origin[1] = s1->maxs[1];
00542                         break;
00543                 case 4:
00544                         VectorCopy(s1->maxs, point[i].origin);
00545                         break;
00546                 case 5:
00547                         VectorCopy(s1->maxs, point[i].origin);
00548                         point[i].origin[0] = s1->mins[0];
00549                         break;
00550                 case 6:
00551                         VectorCopy(s1->maxs, point[i].origin);
00552                         point[i].origin[1] = s1->mins[1];
00553                         break;
00554                 case 7:
00555                         VectorCopy(s1->maxs, point[i].origin);
00556                         point[i].origin[0] = s1->mins[0];
00557                         point[i].origin[1] = s1->mins[1];
00558                         break;
00559                 }
00560 
00561                 // add the original origin to each point and then stuff them out there
00562                 VectorAdd(point[i].origin, origin, point[i].origin);
00563 
00564                 trap_R_AddRefEntityToScene (&point[i]);
00565         }
00566 #endif
00567         */
00568 }

void CG_CreateDistortionTrailPart centity_t cent,
float  scale,
vec3_t  pos
 

Definition at line 2324 of file cg_ents.c.

References AnglesToAxis(), refEntity_t::axis, centity_t, cg, cg_renderToTextureFX, cgs, refEntity_t::customShader, refEntity_t::hModel, vmCvar_t::integer, cgMedia_t::itemRespawningRezOut, centity_s::lerpAngles, cgs_t::media, memset(), refEntity_t::modelScale, refEntity_t::origin, PITCH, refEntity_t::radius, cg_t::refdef, refEntity_t::renderfx, RF_DISTORTION, RF_FORCE_ENT_ALPHA, ScaleModelAxis(), refEntity_t::shaderRGBA, trap_R_AddRefEntityToScene(), trap_R_RegisterModel(), vec3_t, VectorCopy, VectorNormalize(), VectorSubtract, and refdef_t::vieworg.

02325 {
02326         refEntity_t ent;
02327         vec3_t ang;
02328         float vLen;
02329 
02330         if (!cg_renderToTextureFX.integer)
02331         {
02332                 return;
02333         }
02334         memset( &ent, 0, sizeof( ent ) );
02335 
02336         VectorCopy( pos, ent.origin );
02337 
02338         VectorSubtract(ent.origin, cg.refdef.vieworg, ent.axis[0]);
02339         vLen = VectorLength(ent.axis[0]);
02340         if (VectorNormalize(ent.axis[0]) <= 0.1f)
02341         {       // Entity is right on vieworg.  quit.
02342                 return;
02343         }
02344 
02345         VectorCopy(cent->lerpAngles, ang);
02346         ang[PITCH] += 90.0f;
02347         AnglesToAxis(ang, ent.axis);
02348 
02349         //radius must be a power of 2, and is the actual captured texture size
02350         if (vLen < 512)
02351         {
02352                 ent.radius = 256;
02353         }
02354         else if (vLen < 1024)
02355         {
02356                 ent.radius = 128;
02357         }
02358         else if (vLen < 2048)
02359         {
02360                 ent.radius = 64;
02361         }
02362         else
02363         {
02364                 ent.radius = 32;
02365         }
02366 
02367         ent.modelScale[0] = scale;
02368         ent.modelScale[1] = scale;
02369         ent.modelScale[2] = scale*16.0f;
02370         ScaleModelAxis(&ent);
02371 
02372         ent.hModel = trap_R_RegisterModel("models/weapons2/merr_sonn/trailmodel.md3");
02373         ent.customShader = cgs.media.itemRespawningRezOut;//cgs.media.cloakedShader;//cgs.media.halfShieldShader;       
02374 
02375 #if 1
02376         ent.renderfx = (RF_DISTORTION|RF_FORCE_ENT_ALPHA);
02377         ent.shaderRGBA[0] = 255.0f;
02378         ent.shaderRGBA[1] = 255.0f;
02379         ent.shaderRGBA[2] = 255.0f;
02380         ent.shaderRGBA[3] = 100.0f;
02381 #else //no alpha
02382         ent.renderfx = RF_DISTORTION;
02383 #endif
02384 
02385         trap_R_AddRefEntityToScene( &ent );
02386 }

void CG_Cube vec3_t  mins,
vec3_t  maxs,
vec3_t  color,
float  alpha
 

Definition at line 3744 of file cg_ents.c.

References addpolyArgStruct_t, addpolyArgStruct_s::alpha1, addpolyArgStruct_s::alpha2, cg, cgs, cg_t::frametime, addpolyArgStruct_s::killTime, cgs_t::media, memset(), addpolyArgStruct_s::numVerts, addpolyArgStruct_s::p, addpolyArgStruct_s::rgb1, addpolyArgStruct_s::rgb2, addpolyArgStruct_s::rotationDelta, addpolyArgStruct_s::shader, cgMedia_t::solidWhite, trap_FX_AddPoly(), vec3_t, and VectorCopy.

Referenced by CG_PredictPlayerState().

03745 {
03746         vec3_t  rot={0,0,0};
03747         int             vec[3];
03748         int             axis, i;
03749         addpolyArgStruct_t apArgs;
03750 
03751         memset (&apArgs, 0, sizeof(apArgs));
03752 
03753         for ( axis = 0, vec[0] = 0, vec[1] = 1, vec[2] = 2; axis < 3; axis++, vec[0]++, vec[1]++, vec[2]++ )
03754         {
03755                 for ( i = 0; i < 3; i++ )
03756                 {
03757                         if ( vec[i] > 2 )
03758                         {
03759                                 vec[i] = 0;
03760                         }
03761                 }
03762 
03763                 apArgs.p[0][vec[1]] = mins[vec[1]];
03764                 apArgs.p[0][vec[2]] = mins[vec[2]];
03765 
03766                 apArgs.p[1][vec[1]] = mins[vec[1]];
03767                 apArgs.p[1][vec[2]] = maxs[vec[2]];
03768 
03769                 apArgs.p[2][vec[1]] = maxs[vec[1]];
03770                 apArgs.p[2][vec[2]] = maxs[vec[2]];
03771                 
03772                 apArgs.p[3][vec[1]] = maxs[vec[1]];
03773                 apArgs.p[3][vec[2]] = mins[vec[2]];
03774 
03775                 //- face
03776                 apArgs.p[0][vec[0]] = apArgs.p[1][vec[0]] = apArgs.p[2][vec[0]] = apArgs.p[3][vec[0]] = mins[vec[0]];
03777 
03778                 apArgs.numVerts = 4;
03779                 apArgs.alpha1 = apArgs.alpha2 = alpha;
03780                 VectorCopy( color, apArgs.rgb1 );
03781                 VectorCopy( color, apArgs.rgb2 );
03782                 VectorCopy( rot, apArgs.rotationDelta );
03783                 apArgs.killTime = cg.frametime;
03784                 apArgs.shader = cgs.media.solidWhite;
03785 
03786                 trap_FX_AddPoly( &apArgs );
03787 
03788                 //+ face
03789                 apArgs.p[0][vec[0]] = apArgs.p[1][vec[0]] = apArgs.p[2][vec[0]] = apArgs.p[3][vec[0]] = maxs[vec[0]];
03790 
03791                 trap_FX_AddPoly( &apArgs );
03792         }
03793 }

void CG_Disintegration centity_t cent,
refEntity_t ent
 

Definition at line 653 of file cg_ents.c.

References AngleVectors(), centity_t, cg, cg_timescale, cgs, crandom, centity_s::currentState, refEntity_t::customShader, cgMedia_t::disruptorShader, centity_s::dustTrailTime, cgs_t::effects, refEntity_t::endTime, cgs_t::gameModels, centity_s::ghoul2, centity_s::lerpAngles, centity_s::lerpOrigin, cgEffects_t::mDisruptorDeathSmoke, cgs_t::media, centity_s::modelScale, NULL, refEntity_t::oldorigin, refEntity_t::origin, ORIGIN, entityState_s::origin2, random, cg_t::refdef, refEntity_t::renderfx, RF_DISINTEGRATE1, RF_DISINTEGRATE2, cg_t::time, trap_FX_PlayEffectID(), trap_G2API_AddBolt(), trap_G2API_GetBoltMatrix(), trap_R_AddRefEntityToScene(), vmCvar_t::value, vec3_t, vectoangles(), VectorCopy, VectorMA, VectorNormalize(), VectorScale, VectorSet, VectorSubtract, refdef_t::viewaxis, and YAW.

Referenced by CG_Player().

00654 {
00655         vec3_t tempAng, hitLoc;
00656         float tempLength;
00657 
00658         VectorCopy(cent->currentState.origin2, hitLoc);
00659 
00660         VectorSubtract( hitLoc, ent->origin, ent->oldorigin );
00661         
00662         tempLength = VectorNormalize( ent->oldorigin );
00663         vectoangles( ent->oldorigin, tempAng );
00664         tempAng[YAW] -= cent->lerpAngles[YAW];
00665         AngleVectors( tempAng, ent->oldorigin, NULL, NULL );
00666         VectorScale( ent->oldorigin, tempLength, ent->oldorigin );
00667 
00668         ent->endTime = cent->dustTrailTime;
00669 
00670         ent->renderfx |= RF_DISINTEGRATE2;
00671         ent->customShader = cgs.media.disruptorShader;
00672         trap_R_AddRefEntityToScene( ent );
00673 
00674         ent->renderfx &= ~(RF_DISINTEGRATE2);
00675         ent->renderfx |= (RF_DISINTEGRATE1);
00676         ent->customShader = 0;
00677         trap_R_AddRefEntityToScene( ent );
00678 
00679         if ( cg.time - ent->endTime < 1000 && (cg_timescale.value * cg_timescale.value * random()) > 0.05f )
00680         {
00681                 vec3_t fxOrg, fxDir;
00682                 mdxaBone_t      boltMatrix;
00683                 int torsoBolt = trap_G2API_AddBolt(cent->ghoul2, 0, "lower_lumbar");
00684 
00685                 VectorSet(fxDir, 0, 1, 0);
00686 
00687                 trap_G2API_GetBoltMatrix( cent->ghoul2, 0, torsoBolt, &boltMatrix, cent->lerpAngles, cent->lerpOrigin, cg.time, 
00688                                 cgs.gameModels, cent->modelScale);
00689                                 BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, fxOrg );
00690 
00691                 VectorMA( fxOrg, -18, cg.refdef.viewaxis[0], fxOrg );
00692                 fxOrg[2] += crandom() * 20;
00693                 trap_FX_PlayEffectID( cgs.effects.mDisruptorDeathSmoke, fxOrg, fxDir, -1, -1 );
00694 
00695                 if ( random() > 0.5f )
00696                 {
00697                         trap_FX_PlayEffectID( cgs.effects.mDisruptorDeathSmoke, fxOrg, fxDir, -1, -1 );
00698                 }
00699         }
00700 }

void CG_G2Animated centity_t cent  ) 
 

Definition at line 7454 of file cg_players.c.

References BG_NUM_TOGGLEABLE_SURFACES, bgToggleableSurfaceDebris, bgToggleableSurfaces, centity_t, CG_G2AnimEntModelLoad(), CG_Player(), CG_RagDoll(), CG_ReattachLimb(), cgs, centity_s::currentState, EF_DEAD, EF_RAG, cgs_t::effects, entityState_s::eFlags, centity_s::ghoul2, centity_s::lerpAngles, centity_s::localAnimIndex, cgEffects_t::mShipDestDestroyed, centity_s::npcLocalSurfOff, centity_s::npcLocalSurfOn, qtrue, centity_s::smoothYaw, entityState_s::surfacesOff, entityState_s::surfacesOn, centity_s::torsoBolt, trap_G2API_SetSurfaceOnOff(), TURN_OFF, TURN_ON, vec3_t, VectorClear, and YAW.

07455 {
07456 #ifdef SMOOTH_G2ANIM_LERPANGLES
07457         float angSmoothFactor = 0.7f;
07458 #endif
07459 
07460 
07461         if (!cent->ghoul2)
07462         { //Initialize this g2 anim ent, then return (will start rendering next frame)
07463                 CG_G2AnimEntModelLoad(cent);
07464                 cent->npcLocalSurfOff = 0;
07465                 cent->npcLocalSurfOn = 0;
07466                 return;
07467         }
07468 
07469         if (cent->npcLocalSurfOff != cent->currentState.surfacesOff ||
07470                 cent->npcLocalSurfOn != cent->currentState.surfacesOn)
07471         { //looks like it's time for an update.
07472                 int i = 0;
07473 
07474                 while (i < BG_NUM_TOGGLEABLE_SURFACES && bgToggleableSurfaces[i])
07475                 {
07476                         if (!(cent->npcLocalSurfOff & (1 << i)) &&
07477                                 (cent->currentState.surfacesOff & (1 << i)))
07478                         { //it wasn't off before but it's off now, so reflect this change in the g2 instance.
07479                                 if (bgToggleableSurfaceDebris[i] > 0)
07480                                 { //make some local debris of this thing?
07481                                         //FIXME: throw off the proper model effect, too
07482                                         CG_CreateSurfaceDebris(cent, i, cgs.effects.mShipDestDestroyed, qtrue);
07483                                 }
07484 
07485                                 trap_G2API_SetSurfaceOnOff(cent->ghoul2, bgToggleableSurfaces[i], TURN_OFF);
07486                         }
07487 
07488                         if (!(cent->npcLocalSurfOn & (1 << i)) &&
07489                                 (cent->currentState.surfacesOn & (1 << i)))
07490                         { //same as above, but on instead of off.
07491                                 trap_G2API_SetSurfaceOnOff(cent->ghoul2, bgToggleableSurfaces[i], TURN_ON);
07492                         }
07493 
07494                         i++;
07495                 }
07496 
07497                 cent->npcLocalSurfOff = cent->currentState.surfacesOff;
07498                 cent->npcLocalSurfOn = cent->currentState.surfacesOn;
07499         }
07500 
07501 
07502         /*
07503         if (cent->currentState.weapon &&
07504                 !trap_G2API_HasGhoul2ModelOnIndex(&(cent->ghoul2), 1) &&
07505                 !(cent->currentState.eFlags & EF_DEAD))
07506         { //if the server says we have a weapon and we haven't copied one onto ourselves yet, then do so.
07507                 trap_G2API_CopySpecificGhoul2Model(g2WeaponInstances[cent->currentState.weapon], 0, cent->ghoul2, 1);
07508 
07509                 if (cent->currentState.weapon == WP_SABER)
07510                 {
07511                         trap_S_StartSound(cent->lerpOrigin, cent->currentState.number, CHAN_AUTO, trap_S_RegisterSound( "sound/weapons/saber/saberon.wav" ));
07512                 }
07513         }
07514         */
07515 
07516         if (cent->torsoBolt && !(cent->currentState.eFlags & EF_DEAD))
07517         { //he's alive and has a limb missing still, reattach it and reset the weapon
07518                 CG_ReattachLimb(cent);
07519         }
07520 
07521         if (((cent->currentState.eFlags & EF_DEAD) || (cent->currentState.eFlags & EF_RAG)) && !cent->localAnimIndex)
07522         {
07523                 vec3_t forcedAngles;
07524 
07525                 VectorClear(forcedAngles);
07526                 forcedAngles[YAW] = cent->lerpAngles[YAW];
07527 
07528                 CG_RagDoll(cent, forcedAngles);
07529         }
07530 
07531 #ifdef SMOOTH_G2ANIM_LERPANGLES
07532         if ((cent->lerpAngles[YAW] > 0 && cent->smoothYaw < 0) ||
07533                 (cent->lerpAngles[YAW] < 0 && cent->smoothYaw > 0))
07534         { //keep it from snapping around on the threshold
07535                 cent->smoothYaw = -cent->smoothYaw;
07536         }
07537         cent->lerpAngles[YAW] = cent->smoothYaw+(cent->lerpAngles[YAW]-cent->smoothYaw)*angSmoothFactor;
07538         cent->smoothYaw = cent->lerpAngles[YAW];
07539 #endif
07540 
07541         //now just render as a player
07542         CG_Player(cent);
07543 
07544         /*
07545         if ( cg_showVehBounds.integer )
07546         {//show vehicle bboxes
07547                 if ( cent->currentState.clientNum >= MAX_CLIENTS
07548                         && cent->currentState.NPC_class == CLASS_VEHICLE 
07549                         && cent->m_pVehicle
07550                         && cent->m_pVehicle->m_pVehicleInfo 
07551                         && cent->currentState.clientNum != cg.predictedVehicleState.clientNum )
07552                 {//not the predicted vehicle
07553                         vec3_t NPCDEBUG_RED = {1.0, 0.0, 0.0};
07554                         vec3_t absmin, absmax;
07555                         vec3_t bmins, bmaxs;
07556                         float *old = cent->m_pVehicle->m_vOrientation;
07557                         cent->m_pVehicle->m_vOrientation = &cent->lerpAngles[0];
07558 
07559                         BG_VehicleAdjustBBoxForOrientation( cent->m_pVehicle, cent->lerpOrigin, bmins, bmaxs,
07560                                                                                 cent->currentState.number, MASK_PLAYERSOLID, NULL );
07561                         cent->m_pVehicle->m_vOrientation = old;
07562 
07563                         VectorAdd( cent->lerpOrigin, bmins, absmin );
07564                         VectorAdd( cent->lerpOrigin, bmaxs, absmax );
07565                         CG_Cube( absmin, absmax, NPCDEBUG_RED, 0.25 );
07566                 }
07567         }
07568         */
07569 }

void CG_G2ServerBoneAngles centity_t cent  ) 
 

Definition at line 3914 of file cg_players.c.

References BONE_ANGLES_POSTMULT, entityState_s::boneAngles1, entityState_s::boneAngles2, entityState_s::boneAngles3, entityState_s::boneAngles4, entityState_s::boneIndex1, entityState_s::boneIndex2, entityState_s::boneIndex3, entityState_s::boneIndex4, entityState_s::boneOrient, centity_t, cg, CG_ConfigString(), cgs, CS_G2BONES, centity_s::currentState, cgs_t::gameModels, centity_s::ghoul2, cg_t::time, trap_G2API_SetBoneAngles(), vec3_t, and VectorCopy.

03915 {
03916         int i = 0;
03917         int bone = cent->currentState.boneIndex1;
03918         int flags, up, right, forward;
03919         vec3_t boneAngles;
03920 
03921         VectorCopy(cent->currentState.boneAngles1, boneAngles);
03922 
03923         while (i < 4)
03924         { //cycle through the 4 bone index values on the entstate
03925                 if (bone)
03926                 { //if it's non-0 then it could have something in it.
03927                         const char *boneName = CG_ConfigString(CS_G2BONES+bone);
03928 
03929                         if (boneName && boneName[0])
03930                         { //got the bone, now set the angles from the corresponding entitystate boneangles value.
03931                                 flags = BONE_ANGLES_POSTMULT;
03932 
03933                                 //get the orientation out of our bit field
03934                                 forward = (cent->currentState.boneOrient)&7; //3 bits from bit 0
03935                                 right = (cent->currentState.boneOrient>>3)&7; //3 bits from bit 3
03936                                 up = (cent->currentState.boneOrient>>6)&7; //3 bits from bit 6
03937 
03938                                 trap_G2API_SetBoneAngles(cent->ghoul2, 0, boneName, boneAngles, flags, up, right, forward, cgs.gameModels, 100, cg.time);
03939                         }
03940                 }
03941 
03942                 switch (i)
03943                 {
03944                 case 0:
03945                         bone = cent->currentState.boneIndex2;
03946                         VectorCopy(cent->currentState.boneAngles2, boneAngles);
03947                         break;
03948                 case 1:
03949                         bone = cent->currentState.boneIndex3;
03950                         VectorCopy(cent->currentState.boneAngles3, boneAngles);
03951                         break;
03952                 case 2:
03953                         bone = cent->currentState.boneIndex4;
03954                         VectorCopy(cent->currentState.boneAngles4, boneAngles);
03955                         break;
03956                 default:
03957                         break;
03958                 }
03959 
03960                 i++;
03961         }
03962 }

qboolean CG_GreyItem int  type,
int  tag,
int  plSide
 

Definition at line 1849 of file cg_ents.c.

References FORCE_DARKSIDE, FORCE_LIGHTSIDE, IT_POWERUP, PW_FORCE_ENLIGHTENED_DARK, PW_FORCE_ENLIGHTENED_LIGHT, qboolean, qfalse, and qtrue.