Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ui_players.c File Reference

#include "ui_local.h"

Include dependency graph for ui_players.c:

Include dependency graph

Go to the source code of this file.

Defines

#define COAST_TIME   1000
#define JUMP_HEIGHT   56
#define SPIN_SPEED   0.9f
#define SWINGSPEED   0.3f
#define UI_TIMER_ATTACK   500
#define UI_TIMER_GESTURE   2300
#define UI_TIMER_JUMP   1000
#define UI_TIMER_LAND   130
#define UI_TIMER_MUZZLE_FLASH   20
#define UI_TIMER_WEAPON_DELAY   250
#define UI_TIMER_WEAPON_SWITCH   300

Functions

void UI_DrawPlayer (float x, float y, float w, float h, playerInfo_t *pi, int time)
void UI_ForceLegsAnim (playerInfo_t *pi, int anim)
void UI_ForceTorsoAnim (playerInfo_t *pi, int anim)
void UI_LegsSequencing (playerInfo_t *pi)
float UI_MachinegunSpinAngle (playerInfo_t *pi)
float UI_MovedirAdjustment (playerInfo_t *pi)
qboolean UI_ParseAnimationFile (const char *filename, animation_t *animations)
void UI_PlayerAngles (playerInfo_t *pi, vec3_t legs[3], vec3_t torso[3], vec3_t head[3])
void UI_PlayerAnimation (playerInfo_t *pi, int *legsOld, int *legs, float *legsBackLerp, int *torsoOld, int *torso, float *torsoBackLerp)
void UI_PlayerFloatSprite (playerInfo_t *pi, vec3_t origin, qhandle_t shader)
void UI_PlayerInfo_SetInfo (playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNumber, qboolean chat)
void UI_PlayerInfo_SetModel (playerInfo_t *pi, const char *model)
void UI_PlayerInfo_SetWeapon (playerInfo_t *pi, weapon_t weaponNum)
void UI_PositionEntityOnTag (refEntity_t *entity, const refEntity_t *parent, clipHandle_t parentModel, char *tagName)
void UI_PositionRotatedEntityOnTag (refEntity_t *entity, const refEntity_t *parent, clipHandle_t parentModel, char *tagName)
qboolean UI_RegisterClientModelname (playerInfo_t *pi, const char *modelSkinName)
qboolean UI_RegisterClientSkin (playerInfo_t *pi, const char *modelName, const char *skinName)
void UI_RunLerpFrame (playerInfo_t *ci, lerpFrame_t *lf, int newAnimation)
void UI_SetLegsAnim (playerInfo_t *pi, int anim)
void UI_SetLerpFrameAnimation (playerInfo_t *ci, lerpFrame_t *lf, int newAnimation)
void UI_SetTorsoAnim (playerInfo_t *pi, int anim)
void UI_SwingAngles (float destination, float swingTolerance, float clampTolerance, float speed, float *angle, qboolean *swinging)
void UI_TorsoSequencing (playerInfo_t *pi)

Variables

int dp_realtime
float jumpHeight


Define Documentation

#define COAST_TIME   1000
 

Definition at line 41 of file ui_players.c.

#define JUMP_HEIGHT   56
 

Definition at line 36 of file ui_players.c.

Referenced by UI_LegsSequencing().

#define SPIN_SPEED   0.9f
 

Definition at line 40 of file ui_players.c.

#define SWINGSPEED   0.3f
 

Definition at line 38 of file ui_players.c.

Referenced by UI_PlayerAngles().

#define UI_TIMER_ATTACK   500
 

Definition at line 32 of file ui_players.c.

#define UI_TIMER_GESTURE   2300
 

Definition at line 28 of file ui_players.c.

#define UI_TIMER_JUMP   1000
 

Definition at line 29 of file ui_players.c.

Referenced by UI_LegsSequencing().

#define UI_TIMER_LAND   130
 

Definition at line 30 of file ui_players.c.

#define UI_TIMER_MUZZLE_FLASH   20
 

Definition at line 33 of file ui_players.c.

#define UI_TIMER_WEAPON_DELAY   250
 

Definition at line 34 of file ui_players.c.

#define UI_TIMER_WEAPON_SWITCH   300
 

Definition at line 31 of file ui_players.c.


Function Documentation

void UI_DrawPlayer float  x,
float  y,
float  w,
float  h,
playerInfo_t pi,
int  time
 

Definition at line 690 of file ui_players.c.

00690                                                                                      {
00691     refdef_t        refdef;
00692     refEntity_t     legs;
00693     refEntity_t     torso;
00694     refEntity_t     head;
00695     refEntity_t     gun;
00696     refEntity_t     barrel;
00697     refEntity_t     flash;
00698     vec3_t          origin;
00699     int             renderfx;
00700     vec3_t          mins = {-16, -16, -24};
00701     vec3_t          maxs = {16, 16, 32};
00702     float           len;
00703     float           xx;
00704 
00705     if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) {
00706         return;
00707     }
00708 
00709     dp_realtime = time;
00710 
00711     if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) {
00712         pi->weapon = pi->pendingWeapon;
00713         pi->lastWeapon = pi->pendingWeapon;
00714         pi->pendingWeapon = -1;
00715         pi->weaponTimer = 0;
00716         if( pi->currentWeapon != pi->weapon ) {
00717             trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );
00718         }
00719     }
00720 
00721     UI_AdjustFrom640( &x, &y, &w, &h );
00722 
00723     y -= jumpHeight;
00724 
00725     memset( &refdef, 0, sizeof( refdef ) );
00726     memset( &legs, 0, sizeof(legs) );
00727     memset( &torso, 0, sizeof(torso) );
00728     memset( &head, 0, sizeof(head) );
00729 
00730     refdef.rdflags = RDF_NOWORLDMODEL;
00731 
00732     AxisClear( refdef.viewaxis );
00733 
00734     refdef.x = x;
00735     refdef.y = y;
00736     refdef.width = w;
00737     refdef.height = h;
00738 
00739     refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f);
00740     xx = refdef.width / tan( refdef.fov_x / 360 * M_PI );
00741     refdef.fov_y = atan2( refdef.height, xx );
00742     refdef.fov_y *= ( 360 / M_PI );
00743 
00744     // calculate distance so the player nearly fills the box
00745     len = 0.7 * ( maxs[2] - mins[2] );      
00746     origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 );
00747     origin[1] = 0.5 * ( mins[1] + maxs[1] );
00748     origin[2] = -0.5 * ( mins[2] + maxs[2] );
00749 
00750     refdef.time = dp_realtime;
00751 
00752     trap_R_ClearScene();
00753 
00754     // get the rotation information
00755     UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis );
00756     
00757     // get the animation state (after rotation, to allow feet shuffle)
00758     UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp,
00759          &torso.oldframe, &torso.frame, &torso.backlerp );
00760 
00761     renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
00762 
00763     //
00764     // add the legs
00765     //
00766     legs.hModel = pi->legsModel;
00767     legs.customSkin = pi->legsSkin;
00768 
00769     VectorCopy( origin, legs.origin );
00770 
00771     VectorCopy( origin, legs.lightingOrigin );
00772     legs.renderfx = renderfx;
00773     VectorCopy (legs.origin, legs.oldorigin);
00774 
00775     trap_R_AddRefEntityToScene( &legs );
00776 
00777     if (!legs.hModel) {
00778         return;
00779     }
00780 
00781     //
00782     // add the torso
00783     //
00784     torso.hModel = pi->torsoModel;
00785     if (!torso.hModel) {
00786         return;
00787     }
00788 
00789     torso.customSkin = pi->torsoSkin;
00790 
00791     VectorCopy( origin, torso.lightingOrigin );
00792 
00793     UI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, "tag_torso");
00794 
00795     torso.renderfx = renderfx;
00796 
00797     trap_R_AddRefEntityToScene( &torso );
00798 
00799     //
00800     // add the head
00801     //
00802     head.hModel = pi->headModel;
00803     if (!head.hModel) {
00804         return;
00805     }
00806     head.customSkin = pi->headSkin;
00807 
00808     VectorCopy( origin, head.lightingOrigin );
00809 
00810     UI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, "tag_head");
00811 
00812     head.renderfx = renderfx;
00813 
00814     trap_R_AddRefEntityToScene( &head );
00815 
00816     //
00817     // add the gun
00818     //
00819     if ( pi->currentWeapon != WP_NONE ) {
00820         memset( &gun, 0, sizeof(gun) );
00821         gun.hModel = pi->weaponModel;
00822         VectorCopy( origin, gun.lightingOrigin );
00823         UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon");
00824         gun.renderfx = renderfx;
00825         trap_R_AddRefEntityToScene( &gun );
00826     }
00827 
00828     //
00829     // add the spinning barrel
00830     //
00831     if ( pi->realWeapon == WP_MACHINEGUN || pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {
00832         vec3_t  angles;
00833 
00834         memset( &barrel, 0, sizeof(barrel) );
00835         VectorCopy( origin, barrel.lightingOrigin );
00836         barrel.renderfx = renderfx;
00837 
00838         barrel.hModel = pi->barrelModel;
00839         angles[YAW] = 0;
00840         angles[PITCH] = 0;
00841         angles[ROLL] = UI_MachinegunSpinAngle( pi );
00842         if( pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) {
00843             angles[PITCH] = angles[ROLL];
00844             angles[ROLL] = 0;
00845         }
00846         AnglesToAxis( angles, barrel.axis );
00847 
00848         UI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel");
00849 
00850         trap_R_AddRefEntityToScene( &barrel );
00851     }
00852 
00853     //
00854     // add muzzle flash
00855     //
00856     if ( dp_realtime <= pi->muzzleFlashTime ) {
00857         if ( pi->flashModel ) {
00858             memset( &flash, 0, sizeof(flash) );
00859             flash.hModel = pi->flashModel;
00860             VectorCopy( origin, flash.lightingOrigin );
00861             UI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, "tag_flash");
00862             flash.renderfx = renderfx;
00863             trap_R_AddRefEntityToScene( &flash );
00864         }
00865 
00866         // make a dlight for the flash
00867         if ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) {
00868             trap_R_AddLightToScene( flash.origin, 200 + (rand()&31), pi->flashDlightColor[0],
00869                 pi->flashDlightColor[1], pi->flashDlightColor[2] );
00870         }
00871     }
00872 
00873     //
00874     // add the chat icon
00875     //
00876     if ( pi->chat ) {
00877         UI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( "sprites/balloon3" ) );
00878     }
00879 
00880     //
00881     // add an accent light
00882     //
00883     origin[0] -= 100;   // + = behind, - = in front
00884     origin[1] += 100;   // + = left, - = right
00885     origin[2] += 100;   // + = above, - = below
00886     trap_R_AddLightToScene( origin, 500, 1.0, 1.0, 1.0 );
00887 
00888     origin[0] -= 100;
00889     origin[1] -= 100;
00890     origin[2] -= 100;
00891     trap_R_AddLightToScene( origin, 500, 1.0, 0.0, 0.0 );
00892 
00893     trap_R_RenderScene( &refdef );
00894 }

void UI_ForceLegsAnim playerInfo_t pi,
int  anim
[static]
 

Definition at line 155 of file ui_players.c.

References playerInfo_t::legsAnim, and playerInfo_t::legsAnimationTimer.

00155                                                            {
00156     pi->legsAnim = ( ( pi->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
00157 
00158     if ( anim == LEGS_JUMP ) {
00159         pi->legsAnimationTimer = UI_TIMER_JUMP;
00160     }
00161 }

void UI_ForceTorsoAnim playerInfo_t pi,
int  anim
[static]
 

Definition at line 183 of file ui_players.c.

References TORSO_ATTACK, playerInfo_t::torsoAnim, and playerInfo_t::torsoAnimationTimer.

00183                                                             {
00184     pi->torsoAnim = ( ( pi->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim;
00185 
00186     if ( anim == TORSO_GESTURE ) {
00187         pi->torsoAnimationTimer = UI_TIMER_GESTURE;
00188     }
00189 
00190     if ( anim == TORSO_ATTACK || anim == TORSO_ATTACK2 ) {
00191         pi->torsoAnimationTimer = UI_TIMER_ATTACK;
00192     }
00193 }

void UI_LegsSequencing playerInfo_t pi  )  [static]
 

Definition at line 261 of file ui_players.c.

References JUMP_HEIGHT, jumpHeight, LEGS_IDLE, LEGS_LAND, playerInfo_t::legsAnim, playerInfo_t::legsAnimationTimer, M_PI, sin(), UI_ForceLegsAnim(), UI_SetLegsAnim(), and UI_TIMER_JUMP.

00261                                                   {
00262     int     currentAnim;
00263 
00264     currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;
00265 
00266     if ( pi->legsAnimationTimer > 0 ) {
00267         if ( currentAnim == LEGS_JUMP ) {
00268             jumpHeight = JUMP_HEIGHT * sin( M_PI * ( UI_TIMER_JUMP - pi->legsAnimationTimer ) / UI_TIMER_JUMP );
00269         }
00270         return;
00271     }
00272 
00273     if ( currentAnim == LEGS_JUMP ) {
00274         UI_ForceLegsAnim( pi, LEGS_LAND );
00275         pi->legsAnimationTimer = UI_TIMER_LAND;
00276         jumpHeight = 0;
00277         return;
00278     }
00279 
00280     if ( currentAnim == LEGS_LAND ) {
00281         UI_SetLegsAnim( pi, LEGS_IDLE );
00282         return;
00283     }
00284 }

Here is the call graph for this function:

float UI_MachinegunSpinAngle playerInfo_t pi  ) 
 

Definition at line 653 of file ui_players.c.

References AngleMod(), playerInfo_t::barrelAngle, playerInfo_t::barrelSpinning, playerInfo_t::barrelTime, COAST_TIME, dp_realtime, SPIN_SPEED, and playerInfo_t::torsoAnim.

00653                                                    {
00654     int     delta;
00655     float   angle;
00656     float   speed;
00657     int     torsoAnim;
00658 
00659     delta = dp_realtime - pi->barrelTime;
00660     if ( pi->barrelSpinning ) {
00661         angle = pi->barrelAngle + delta * SPIN_SPEED;
00662     } else {
00663         if ( delta > COAST_TIME ) {
00664             delta = COAST_TIME;
00665         }
00666 
00667         speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );
00668         angle = pi->barrelAngle + delta * speed;
00669     }
00670 
00671     torsoAnim = pi->torsoAnim  & ~ANIM_TOGGLEBIT;
00672     if( torsoAnim == TORSO_ATTACK2 ) {
00673         torsoAnim = TORSO_ATTACK;
00674     }
00675     if ( pi->barrelSpinning == !(torsoAnim == TORSO_ATTACK) ) {
00676         pi->barrelTime = dp_realtime;
00677         pi->barrelAngle = AngleMod( angle );
00678         pi->barrelSpinning = !!(torsoAnim == TORSO_ATTACK);
00679     }
00680 
00681     return angle;
00682 }

Here is the call graph for this function:

float UI_MovedirAdjustment playerInfo_t pi  )  [static]
 

Definition at line 531 of file ui_players.c.

References AngleVectors(), playerInfo_t::moveAngles, NULL, Q_fabs(), vec3_t, VectorSubtract, and playerInfo_t::viewAngles.

00531                                                       {
00532     vec3_t      relativeAngles;
00533     vec3_t      moveVector;
00534 
00535     VectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles );
00536     AngleVectors( relativeAngles, moveVector, NULL, NULL );
00537     if ( Q_fabs( moveVector[0] ) < 0.01 ) {
00538         moveVector[0] = 0.0;
00539     }
00540     if ( Q_fabs( moveVector[1] ) < 0.01 ) {
00541         moveVector[1] = 0.0;
00542     }
00543 
00544     if ( moveVector[1] == 0 && moveVector[0] > 0 ) {
00545         return 0;
00546     }
00547     if ( moveVector[1] < 0 && moveVector[0] > 0 ) {
00548         return 22;
00549     }
00550     if ( moveVector[1] < 0 && moveVector[0] == 0 ) {
00551         return 45;
00552     }
00553     if ( moveVector[1] < 0 && moveVector[0] < 0 ) {
00554         return -22;
00555     }
00556     if ( moveVector[1] == 0 && moveVector[0] < 0 ) {
00557         return 0;
00558     }
00559     if ( moveVector[1] > 0 && moveVector[0] < 0 ) {
00560         return 22;
00561     }
00562     if ( moveVector[1] > 0 && moveVector[0] == 0 ) {
00563         return  -45;
00564     }
00565 
00566     return -22;
00567 }

Here is the call graph for this function:

qboolean UI_ParseAnimationFile const char *  filename,
animation_t animations
[static]
 

Definition at line 927 of file ui_players.c.

References animation_t, atof(), atoi, COM_Parse(), Com_Printf(), f, fileHandle_t, animation_s::firstFrame, animation_s::frameLerp, FS_READ, i, animation_s::initialLerp, animation_s::loopFrames, MAX_ANIMATIONS, memset(), animation_s::numFrames, Q_stricmp(), qboolean, token, trap_FS_FCloseFile(), trap_FS_FOpenFile(), and trap_FS_Read().

00927                                                                                        {
00928     char        *text_p, *prev;
00929     int         len;
00930     int         i;
00931     char        *token;
00932     float       fps;
00933     int         skip;
00934     char        text[20000];
00935     fileHandle_t    f;
00936 
00937     memset( animations, 0, sizeof( animation_t ) * MAX_ANIMATIONS );
00938 
00939     // load the file
00940     len = trap_FS_FOpenFile( filename, &f, FS_READ );
00941     if ( len <= 0 ) {
00942         return qfalse;
00943     }
00944     if ( len >= ( sizeof( text ) - 1 ) ) {
00945         Com_Printf( "File %s too long\n", filename );
00946         return qfalse;
00947     }
00948     trap_FS_Read( text, len, f );
00949     text[len] = 0;
00950     trap_FS_FCloseFile( f );
00951 
00952     // parse the text
00953     text_p = text;
00954     skip = 0;   // quite the compiler warning
00955 
00956     // read optional parameters
00957     while ( 1 ) {
00958         prev = text_p;  // so we can unget
00959         token = COM_Parse( &text_p );
00960         if ( !token ) {
00961             break;
00962         }
00963         if ( !Q_stricmp( token, "footsteps" ) ) {
00964             token = COM_Parse( &text_p );
00965             if ( !token ) {
00966                 break;
00967             }
00968             continue;
00969         } else if ( !Q_stricmp( token, "headoffset" ) ) {
00970             for ( i = 0 ; i < 3 ; i++ ) {
00971                 token = COM_Parse( &text_p );
00972                 if ( !token ) {
00973                     break;
00974                 }
00975             }
00976             continue;
00977         } else if ( !Q_stricmp( token, "sex" ) ) {
00978             token = COM_Parse( &text_p );
00979             if ( !token ) {
00980                 break;
00981             }
00982             continue;
00983         }
00984 
00985         // if it is a number, start parsing animations
00986         if ( token[0] >= '0' && token[0] <= '9' ) {
00987             text_p = prev;  // unget the token
00988             break;
00989         }
00990 
00991         Com_Printf( "unknown token '%s' is %s\n", token, filename );
00992     }
00993 
00994     // read information for each frame
00995     for ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) {
00996 
00997         token = COM_Parse( &text_p );
00998         if ( !token ) {
00999             break;
01000         }
01001         animations[i].firstFrame = atoi( token );
01002         // leg only frames are adjusted to not count the upper body only frames
01003         if ( i == LEGS_WALKCR ) {
01004             skip = animations[LEGS_WALKCR].firstFrame - animations[TORSO_GESTURE].firstFrame;
01005         }
01006         if ( i >= LEGS_WALKCR ) {
01007             animations[i].firstFrame -= skip;
01008         }
01009 
01010         token = COM_Parse( &text_p );
01011         if ( !token ) {
01012             break;
01013         }
01014         animations[i].numFrames = atoi( token );
01015 
01016         token = COM_Parse( &text_p );
01017         if ( !token ) {
01018             break;
01019         }
01020         animations[i].loopFrames = atoi( token );
01021 
01022         token = COM_Parse( &text_p );
01023         if ( !token ) {
01024             break;
01025         }
01026         fps = atof( token );
01027         if ( fps == 0 ) {
01028             fps = 1;
01029         }
01030         animations[i].frameLerp = 1000 / fps;
01031         animations[i].initialLerp = 1000 / fps;
01032     }
01033 
01034     if ( i != MAX_ANIMATIONS ) {
01035         Com_Printf( "Error parsing animation file: %s", filename );
01036         return qfalse;
01037     }
01038 
01039     return qtrue;
01040 }

Here is the call graph for this function:

void UI_PlayerAngles playerInfo_t pi,
vec3_t  legs[3],
vec3_t  torso[3],
vec3_t  head[3]
[static]
 

Definition at line 575 of file ui_players.c.

References AngleMod(), AnglesSubtract(), AnglesToAxis(), f, head, playerInfo_t::legs, LEGS_IDLE, playerInfo_t::legsAnim, lerpFrame_t::pitchAngle, lerpFrame_t::pitching, SWINGSPEED, playerInfo_t::torso, playerInfo_t::torsoAnim, UI_MovedirAdjustment(), UI_SwingAngles(), vec3_t, VectorClear, VectorCopy, playerInfo_t::viewAngles, YAW, lerpFrame_t::yawAngle, and lerpFrame_t::yawing.

00575                                                                                                  {
00576     vec3_t      legsAngles, torsoAngles, headAngles;
00577     float       dest;
00578     float       adjust;
00579 
00580     VectorCopy( pi->viewAngles, headAngles );
00581     headAngles[YAW] = AngleMod( headAngles[YAW] );
00582     VectorClear( legsAngles );
00583     VectorClear( torsoAngles );
00584 
00585     // --------- yaw -------------
00586 
00587     // allow yaw to drift a bit
00588     if ( ( pi->legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE 
00589         || ( pi->torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND  ) {
00590         // if not standing still, always point all in the same direction
00591         pi->torso.yawing = qtrue;   // always center
00592         pi->torso.pitching = qtrue; // always center
00593         pi->legs.yawing = qtrue;    // always center
00594     }
00595 
00596     // adjust legs for movement dir
00597     adjust = UI_MovedirAdjustment( pi );
00598     legsAngles[YAW] = headAngles[YAW] + adjust;
00599     torsoAngles[YAW] = headAngles[YAW] + 0.25 * adjust;
00600 
00601 
00602     // torso
00603     UI_SwingAngles( torsoAngles[YAW], 25, 90, SWINGSPEED, &pi->torso.yawAngle, &pi->torso.yawing );
00604     UI_SwingAngles( legsAngles[YAW], 40, 90, SWINGSPEED, &pi->legs.yawAngle, &pi->legs.yawing );
00605 
00606     torsoAngles[YAW] = pi->torso.yawAngle;
00607     legsAngles[YAW] = pi->legs.yawAngle;
00608 
00609     // --------- pitch -------------
00610 
00611     // only show a fraction of the pitch angle in the torso
00612     if ( headAngles[PITCH] > 180 ) {
00613         dest = (-360 + headAngles[PITCH]) * 0.75;
00614     } else {
00615         dest = headAngles[PITCH] * 0.75;
00616     }
00617     UI_SwingAngles( dest, 15, 30, 0.1f, &pi->torso.pitchAngle, &pi->torso.pitching );
00618     torsoAngles[PITCH] = pi->torso.pitchAngle;
00619 
00620     // pull the angles back out of the hierarchial chain
00621     AnglesSubtract( headAngles, torsoAngles, headAngles );
00622     AnglesSubtract( torsoAngles, legsAngles, torsoAngles );
00623     AnglesToAxis( legsAngles, legs );
00624     AnglesToAxis( torsoAngles, torso );
00625     AnglesToAxis( headAngles, head );
00626 }

Here is the call graph for this function:

void UI_PlayerAnimation playerInfo_t pi,
int *  legsOld,
int *  legs,
float *  legsBackLerp,
int *  torsoOld,
int *  torso,
float *  torsoBackLerp
[static]
 

Definition at line 429 of file ui_players.c.

References lerpFrame_t::backlerp, lerpFrame_t::frame, uiStatic_t::frametime, playerInfo_t::legs, LEGS_TURN, playerInfo_t::legsAnim, playerInfo_t::legsAnimationTimer, lerpFrame_t::oldFrame, playerInfo_t::torso, playerInfo_t::torsoAnim, playerInfo_t::torsoAnimationTimer, UI_LegsSequencing(), UI_RunLerpFrame(), UI_TorsoSequencing(), uis, and lerpFrame_t::yawing.

00430                                                                           {
00431 
00432     // legs animation
00433     pi->legsAnimationTimer -= uis.frametime;
00434     if ( pi->legsAnimationTimer < 0 ) {
00435         pi->legsAnimationTimer = 0;
00436     }
00437 
00438     UI_LegsSequencing( pi );
00439 
00440     if ( pi->legs.yawing && ( pi->legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) {
00441         UI_RunLerpFrame( pi, &pi->legs, LEGS_TURN );
00442     } else {
00443         UI_RunLerpFrame( pi, &pi->legs, pi->legsAnim );
00444     }
00445     *legsOld = pi->legs.oldFrame;
00446     *legs = pi->legs.frame;
00447     *legsBackLerp = pi->legs.backlerp;
00448 
00449     // torso animation
00450     pi->torsoAnimationTimer -= uis.frametime;
00451     if ( pi->torsoAnimationTimer < 0 ) {
00452         pi->torsoAnimationTimer = 0;
00453     }
00454 
00455     UI_TorsoSequencing( pi );
00456 
00457     UI_RunLerpFrame( pi, &pi->torso, pi->torsoAnim );
00458     *torsoOld = pi->torso.oldFrame;
00459     *torso = pi->torso.frame;
00460     *torsoBackLerp = pi->torso.backlerp;
00461 }

Here is the call graph for this function:

void UI_PlayerFloatSprite playerInfo_t pi,
vec3_t  origin,
qhandle_t  shader
[static]
 

Definition at line 634 of file ui_players.c.

References memset(), trap_R_AddRefEntityToScene(), and VectorCopy.

00634                                                                                       {
00635     refEntity_t     ent;
00636 
00637     memset( &ent, 0, sizeof( ent ) );
00638     VectorCopy( origin, ent.origin );
00639     ent.origin[2] += 48;
00640     ent.reType = RT_SPRITE;
00641     ent.customShader = shader;
00642     ent.radius = 10;
00643     ent.renderfx = 0;
00644     trap_R_AddRefEntityToScene( &ent );
00645 }

Here is the call graph for this function:

void UI_PlayerInfo_SetInfo playerInfo_t pi,
int  legsAnim,
int  torsoAnim,
vec3_t  viewAngles,
vec3_t  moveAngles,
weapon_t  weaponNumber,
qboolean  chat
 

Definition at line 1139 of file ui_players.c.

01139                                                                                                                                                         {
01140     int         currentAnim;
01141     weapon_t    weaponNum;
01142 
01143     pi->chat = chat;
01144 
01145     // view angles
01146     VectorCopy( viewAngles, pi->viewAngles );
01147 
01148     // move angles
01149     VectorCopy( moveAngles, pi->moveAngles );
01150 
01151     if ( pi->newModel ) {
01152         pi->newModel = qfalse;
01153 
01154         jumpHeight = 0;
01155         pi->pendingLegsAnim = 0;
01156         UI_ForceLegsAnim( pi, legsAnim );
01157         pi->legs.yawAngle = viewAngles[YAW];
01158         pi->legs.yawing = qfalse;
01159 
01160         pi->pendingTorsoAnim = 0;
01161         UI_ForceTorsoAnim( pi, torsoAnim );
01162         pi->torso.yawAngle = viewAngles[YAW];
01163         pi->torso.yawing = qfalse;
01164 
01165         if ( weaponNumber != -1 ) {
01166             pi->weapon = weaponNumber;
01167             pi->currentWeapon = weaponNumber;
01168             pi->lastWeapon = weaponNumber;
01169             pi->pendingWeapon = -1;
01170             pi->weaponTimer = 0;
01171             UI_PlayerInfo_SetWeapon( pi, pi->weapon );
01172         }
01173 
01174         return;
01175     }
01176 
01177     // weapon
01178     if ( weaponNumber == -1 ) {
01179         pi->pendingWeapon = -1;
01180         pi->weaponTimer = 0;
01181     }
01182     else if ( weaponNumber != WP_NONE ) {
01183         pi->pendingWeapon = weaponNumber;
01184         pi->weaponTimer = dp_realtime + UI_TIMER_WEAPON_DELAY;
01185     }
01186     weaponNum = pi->lastWeapon;
01187     pi->weapon = weaponNum;
01188 
01189     if ( torsoAnim == BOTH_DEATH1 || legsAnim == BOTH_DEATH1 ) {
01190         torsoAnim = legsAnim = BOTH_DEATH1;
01191         pi->weapon = pi->currentWeapon = WP_NONE;
01192         UI_PlayerInfo_SetWeapon( pi, pi->weapon );
01193 
01194         jumpHeight = 0;
01195         pi->pendingLegsAnim = 0;
01196         UI_ForceLegsAnim( pi, legsAnim );
01197 
01198         pi->pendingTorsoAnim = 0;
01199         UI_ForceTorsoAnim( pi, torsoAnim );
01200 
01201         return;
01202     }
01203 
01204     // leg animation
01205     currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT;
01206     if ( legsAnim != LEGS_JUMP && ( currentAnim == LEGS_JUMP || currentAnim == LEGS_LAND ) ) {
01207         pi->pendingLegsAnim = legsAnim;
01208     }
01209     else if ( legsAnim != currentAnim ) {
01210         jumpHeight = 0;
01211         pi->pendingLegsAnim = 0;
01212         UI_ForceLegsAnim( pi, legsAnim );
01213     }
01214 
01215     // torso animation
01216     if ( torsoAnim == TORSO_STAND || torsoAnim == TORSO_STAND2 ) {
01217         if ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {
01218             torsoAnim = TORSO_STAND2;
01219         }
01220         else {
01221             torsoAnim = TORSO_STAND;
01222         }
01223     }
01224 
01225     if ( torsoAnim == TORSO_ATTACK || torsoAnim == TORSO_ATTACK2 ) {
01226         if ( weaponNum == WP_NONE || weaponNum == WP_GAUNTLET ) {
01227             torsoAnim = TORSO_ATTACK2;
01228         }
01229         else {
01230             torsoAnim = TORSO_ATTACK;
01231         }
01232         pi->muzzleFlashTime = dp_realtime + UI_TIMER_MUZZLE_FLASH;
01233         //FIXME play firing sound here
01234     }
01235 
01236     currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;
01237 
01238     if ( weaponNum != pi->currentWeapon || currentAnim == TORSO_RAISE || currentAnim == TORSO_DROP ) {
01239         pi->pendingTorsoAnim = torsoAnim;
01240     }
01241     else if ( ( currentAnim == TORSO_GESTURE || currentAnim == TORSO_ATTACK ) && ( torsoAnim != currentAnim ) ) {
01242         pi->pendingTorsoAnim = torsoAnim;
01243     }
01244     else if ( torsoAnim != currentAnim ) {
01245         pi->pendingTorsoAnim = 0;
01246         UI_ForceTorsoAnim( pi, torsoAnim );
01247     }
01248 }

void UI_PlayerInfo_SetModel playerInfo_t pi,
const char *  model
 

Definition at line 1120 of file ui_players.c.

References playerInfo_t::chat, playerInfo_t::currentWeapon, playerInfo_t::lastWeapon, memset(), playerInfo_t::newModel, playerInfo_t::pendingWeapon, UI_PlayerInfo_SetWeapon(), UI_RegisterClientModelname(), playerInfo_t::weapon, and playerInfo_t::weaponTimer.

01120                                                                    {
01121     memset( pi, 0, sizeof(*pi) );
01122     UI_RegisterClientModelname( pi, model );
01123     pi->weapon = WP_MACHINEGUN;
01124     pi->currentWeapon = pi->weapon;
01125     pi->lastWeapon = pi->weapon;
01126     pi->pendingWeapon = -1;
01127     pi->weaponTimer = 0;
01128     pi->chat = qfalse;
01129     pi->newModel = qtrue;
01130     UI_PlayerInfo_SetWeapon( pi, pi->weapon );
01131 }

Here is the call graph for this function:

void UI_PlayerInfo_SetWeapon playerInfo_t pi,
weapon_t  weaponNum
[static]
 

Definition at line 53 of file ui_players.c.

References playerInfo_t::barrelModel, bg_itemlist, gitem_s::classname, COM_StripExtension(), playerInfo_t::currentWeapon, playerInfo_t::flashDlightColor, playerInfo_t::flashModel, gitem_s::giTag, gitem_t, gitem_s::giType, MAKERGB, playerInfo_t::realWeapon, strcat(), strcpy(), trap_R_RegisterModel(), playerInfo_t::weaponModel, gitem_s::world_model, WP_BFG, WP_GAUNTLET, WP_GRAPPLING_HOOK, WP_GRENADE_LAUNCHER, WP_LIGHTNING, WP_MACHINEGUN, WP_PLASMAGUN, WP_RAILGUN, WP_ROCKET_LAUNCHER, and WP_SHOTGUN.

00053                                                                             {
00054     gitem_t *   item;
00055     char        path[MAX_QPATH];
00056 
00057     pi->currentWeapon = weaponNum;
00058 tryagain:
00059     pi->realWeapon = weaponNum;
00060     pi->weaponModel = 0;
00061     pi->barrelModel = 0;
00062     pi->flashModel = 0;
00063 
00064     if ( weaponNum == WP_NONE ) {
00065         return;
00066     }
00067 
00068     for ( item = bg_itemlist + 1; item->classname ; item++ ) {
00069         if ( item->giType != IT_WEAPON ) {
00070             continue;
00071         }
00072         if ( item->giTag == weaponNum ) {
00073             break;
00074         }
00075     }
00076 
00077     if ( item->classname ) {
00078         pi->weaponModel = trap_R_RegisterModel( item->world_model[0] );
00079     }
00080 
00081     if( pi->weaponModel == 0 ) {
00082         if( weaponNum == WP_MACHINEGUN ) {
00083             weaponNum = WP_NONE;
00084             goto tryagain;
00085         }
00086         weaponNum = WP_MACHINEGUN;
00087         goto tryagain;
00088     }
00089 
00090     if ( weaponNum == WP_MACHINEGUN || weaponNum == WP_GAUNTLET || weaponNum == WP_BFG ) {
00091         strcpy( path, item->world_model[0] );
00092         COM_StripExtension( path, path );
00093         strcat( path, "_barrel.md3" );
00094         pi->barrelModel = trap_R_RegisterModel( path );
00095     }
00096 
00097     strcpy( path, item->world_model[0] );
00098     COM_StripExtension( path, path );
00099     strcat( path, "_flash.md3" );
00100     pi->flashModel = trap_R_RegisterModel( path );
00101 
00102     switch( weaponNum ) {
00103     case WP_GAUNTLET:
00104         MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
00105         break;
00106 
00107     case WP_MACHINEGUN:
00108         MAKERGB( pi->flashDlightColor, 1, 1, 0 );
00109         break;
00110 
00111     case WP_SHOTGUN:
00112         MAKERGB( pi->flashDlightColor, 1, 1, 0 );
00113         break;
00114 
00115     case WP_GRENADE_LAUNCHER:
00116         MAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f );
00117         break;
00118 
00119     case WP_ROCKET_LAUNCHER:
00120         MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 );
00121         break;
00122 
00123     case WP_LIGHTNING:
00124         MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
00125         break;
00126 
00127     case WP_RAILGUN:
00128         MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );
00129         break;
00130 
00131     case WP_PLASMAGUN:
00132         MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
00133         break;
00134 
00135     case WP_BFG:
00136         MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );
00137         break;
00138 
00139     case WP_GRAPPLING_HOOK:
00140         MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
00141         break;
00142 
00143     default:
00144         MAKERGB( pi->flashDlightColor, 1, 1, 1 );
00145         break;
00146     }
00147 }

Here is the call graph for this function:

void UI_PositionEntityOnTag refEntity_t entity,
const refEntity_t parent,
clipHandle_t  parentModel,
char *  tagName
[static]
 

Definition at line 292 of file ui_players.c.

References orientation_t::axis, refEntity_t::axis, refEntity_t::backlerp, refEntity_t::frame, i, MatrixMultiply(), refEntity_t::oldframe, orientation_t::origin, refEntity_t::origin, trap_CM_LerpTag(), VectorCopy, and VectorMA.

00293                                                                       {
00294     int             i;
00295     orientation_t   lerped;
00296     
00297     // lerp the tag
00298     trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
00299         1.0 - parent->backlerp, tagName );
00300 
00301     // FIXME: allow origin offsets along tag?
00302     VectorCopy( parent->origin, entity->origin );
00303     for ( i = 0 ; i < 3 ; i++ ) {
00304         VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
00305     }
00306 
00307     // cast away const because of compiler problems
00308     MatrixMultiply( lerped.axis, ((refEntity_t*)parent)->axis, entity->axis );
00309     entity->backlerp = parent->backlerp;
00310 }

Here is the call graph for this function:

void UI_PositionRotatedEntityOnTag refEntity_t entity,
const refEntity_t parent,
clipHandle_t  parentModel,
char *  tagName
[static]
 

Definition at line 318 of file ui_players.c.

References orientation_t::axis, refEntity_t::axis, refEntity_t::backlerp, refEntity_t::frame, i, MatrixMultiply(), refEntity_t::oldframe, orientation_t::origin, refEntity_t::origin, trap_CM_LerpTag(), vec3_t, VectorCopy, and VectorMA.

00319                                                                       {
00320     int             i;
00321     orientation_t   lerped;
00322     vec3_t          tempAxis[3];
00323 
00324     // lerp the tag
00325     trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
00326         1.0 - parent->backlerp, tagName );
00327 
00328     // FIXME: allow origin offsets along tag?
00329     VectorCopy( parent->origin, entity->origin );
00330     for ( i = 0 ; i < 3 ; i++ ) {
00331         VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
00332     }
00333 
00334     // cast away const because of compiler problems
00335     MatrixMultiply( entity->axis, ((refEntity_t *)parent)->axis, tempAxis );
00336     MatrixMultiply( lerped.axis, tempAxis, entity->axis );
00337 }

Here is the call graph for this function:

qboolean UI_RegisterClientModelname playerInfo_t pi,
const char *  modelSkinName
 

Definition at line 1048 of file ui_players.c.

References playerInfo_t::animations, Com_Printf(), Com_sprintf(), playerInfo_t::headModel, playerInfo_t::legsModel, Q_strncpyz(), qboolean, strchr(), playerInfo_t::torsoModel, trap_R_RegisterModel(), UI_ParseAnimationFile(), and UI_RegisterClientSkin().

01048                                                                                    {
01049     char        modelName[MAX_QPATH];
01050     char        skinName[MAX_QPATH];
01051     char        filename[MAX_QPATH];
01052     char        *slash;
01053 
01054     pi->torsoModel = 0;
01055     pi->headModel = 0;
01056 
01057     if ( !modelSkinName[0] ) {
01058         return qfalse;
01059     }
01060 
01061     Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );
01062 
01063     slash = strchr( modelName, '/' );
01064     if ( !slash ) {
01065         // modelName did not include a skin name
01066         Q_strncpyz( skinName, "default", sizeof( skinName ) );
01067     } else {
01068         Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
01069         // truncate modelName
01070         *slash = 0;
01071     }
01072 
01073     // load cmodels before models so filecache works
01074 
01075     Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
01076     pi->legsModel = trap_R_RegisterModel( filename );
01077     if ( !pi->legsModel ) {
01078         Com_Printf( "Failed to load model file %s\n", filename );
01079         return qfalse;
01080     }
01081 
01082     Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
01083     pi->torsoModel = trap_R_RegisterModel( filename );
01084     if ( !pi->torsoModel ) {
01085         Com_Printf( "Failed to load model file %s\n", filename );
01086         return qfalse;
01087     }
01088 
01089     Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", modelName );
01090     pi->headModel = trap_R_RegisterModel( filename );
01091     if ( !pi->headModel ) {
01092         Com_Printf( "Failed to load model file %s\n", filename );
01093         return qfalse;
01094     }
01095 
01096     // if any skins failed to load, fall back to default
01097     if ( !UI_RegisterClientSkin( pi, modelName, skinName ) ) {
01098         if ( !UI_RegisterClientSkin( pi, modelName, "default" ) ) {
01099             Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
01100             return qfalse;
01101         }
01102     }
01103 
01104     // load the animations
01105     Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
01106     if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
01107         Com_Printf( "Failed to load animation file %s\n", filename );
01108         return qfalse;
01109     }
01110 
01111     return qtrue;
01112 }

Here is the call graph for this function:

qboolean UI_RegisterClientSkin playerInfo_t pi,
const char *  modelName,
const char *  skinName
[static]
 

Definition at line 902 of file ui_players.c.

References Com_sprintf(), playerInfo_t::headSkin, playerInfo_t::legsSkin, qboolean, playerInfo_t::torsoSkin, and trap_R_RegisterSkin().

00902                                                                                                        {
00903     char        filename[MAX_QPATH];
00904 
00905     Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower_%s.skin", modelName, skinName );
00906     pi->legsSkin = trap_R_RegisterSkin( filename );
00907 
00908     Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper_%s.skin", modelName, skinName );
00909     pi->torsoSkin = trap_R_RegisterSkin( filename );
00910 
00911     Com_sprintf( filename, sizeof( filename ), "models/players/%s/head_%s.skin", modelName, skinName );
00912     pi->headSkin = trap_R_RegisterSkin( filename );
00913 
00914     if ( !pi->legsSkin || !pi->torsoSkin || !pi->headSkin ) {
00915         return qfalse;
00916     }
00917 
00918     return qtrue;
00919 }

Here is the call graph for this function:

void UI_RunLerpFrame playerInfo_t ci,
lerpFrame_t lf,
int  newAnimation
[static]
 

Definition at line 367 of file ui_players.c.

References lerpFrame_t::animation, animation_t, lerpFrame_t::animationNumber, lerpFrame_t::animationTime, lerpFrame_t::backlerp, dp_realtime, f, animation_s::firstFrame, lerpFrame_t::frame, animation_s::frameLerp, lerpFrame_t::frameTime, animation_s::loopFrames, animation_s::numFrames, lerpFrame_t::oldFrame, lerpFrame_t::oldFrameTime, and UI_SetLerpFrameAnimation().

00367                                                                                    {
00368     int         f;
00369     animation_t *anim;
00370 
00371     // see if the animation sequence is switching
00372     if ( newAnimation != lf->animationNumber || !lf->animation ) {
00373         UI_SetLerpFrameAnimation( ci, lf, newAnimation );
00374     }
00375 
00376     // if we have passed the current frame, move it to
00377     // oldFrame and calculate a new frame
00378     if ( dp_realtime >= lf->frameTime ) {
00379         lf->oldFrame = lf->frame;
00380         lf->oldFrameTime = lf->frameTime;
00381 
00382         // get the next frame based on the animation
00383         anim = lf->animation;
00384         if ( dp_realtime < lf->animationTime ) {
00385             lf->frameTime = lf->animationTime;      // initial lerp
00386         } else {
00387             lf->frameTime = lf->oldFrameTime + anim->frameLerp;
00388         }
00389         f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
00390         if ( f >= anim->numFrames ) {
00391             f -= anim->numFrames;
00392             if ( anim->loopFrames ) {
00393                 f %= anim->loopFrames;
00394                 f += anim->numFrames - anim->loopFrames;
00395             } else {
00396                 f = anim->numFrames - 1;
00397                 // the animation is stuck at the end, so it
00398                 // can immediately transition to another sequence
00399                 lf->frameTime = dp_realtime;
00400             }
00401         }
00402         lf->frame = anim->firstFrame + f;
00403         if ( dp_realtime > lf->frameTime ) {
00404             lf->frameTime = dp_realtime;
00405         }
00406     }
00407 
00408     if ( lf->frameTime > dp_realtime + 200 ) {
00409         lf->frameTime = dp_realtime;
00410     }
00411 
00412     if ( lf->oldFrameTime > dp_realtime ) {
00413         lf->oldFrameTime = dp_realtime;
00414     }
00415     // calculate current lerp value
00416     if ( lf->frameTime == lf->oldFrameTime ) {
00417         lf->backlerp = 0;
00418     } else {
00419         lf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
00420     }
00421 }

Here is the call graph for this function:

void UI_SetLegsAnim playerInfo_t pi,
int  anim
[static]
 

Definition at line 169 of file ui_players.c.

References playerInfo_t::pendingLegsAnim, and UI_ForceLegsAnim().

00169                                                          {
00170     if ( pi->pendingLegsAnim ) {
00171         anim = pi->pendingLegsAnim;
00172         pi->pendingLegsAnim = 0;
00173     }
00174     UI_ForceLegsAnim( pi, anim );
00175 }

Here is the call graph for this function:

void UI_SetLerpFrameAnimation playerInfo_t ci,
lerpFrame_t lf,
int  newAnimation
[static]
 

Definition at line 345 of file ui_players.c.

References lerpFrame_t::animation, animation_t, lerpFrame_t::animationNumber, playerInfo_t::animations, lerpFrame_t::animationTime, lerpFrame_t::frameTime, animation_s::initialLerp, trap_Error(), and va().

00345                                                                                             {
00346     animation_t *anim;
00347 
00348     lf->animationNumber = newAnimation;
00349     newAnimation &= ~ANIM_TOGGLEBIT;
00350 
00351     if ( newAnimation < 0 || newAnimation >= MAX_ANIMATIONS ) {
00352         trap_Error( va("Bad animation number: %i", newAnimation) );
00353     }
00354 
00355     anim = &ci->animations[ newAnimation ];
00356 
00357     lf->animation = anim;
00358     lf->animationTime = lf->frameTime + anim->initialLerp;
00359 }

Here is the call graph for this function:

void UI_SetTorsoAnim playerInfo_t pi,
int  anim
[static]
 

Definition at line 201 of file ui_players.c.

References playerInfo_t::pendingTorsoAnim, and UI_ForceTorsoAnim().

00201                                                           {
00202     if ( pi->pendingTorsoAnim ) {
00203         anim = pi->pendingTorsoAnim;
00204         pi->pendingTorsoAnim = 0;
00205     }
00206 
00207     UI_ForceTorsoAnim( pi, anim );
00208 }

Here is the call graph for this function:

void UI_SwingAngles float  destination,
float  swingTolerance,
float  clampTolerance,
float  speed,
float *  angle,
qboolean swinging
[static]
 

Definition at line 469 of file ui_players.c.

References AngleMod(), AngleSubtract(), fabs(), uiStatic_t::frametime, move(), and uis.

00470                                                                     {
00471     float   swing;
00472     float   move;
00473     float   scale;
00474 
00475     if ( !*swinging ) {
00476         // see if a swing should be started
00477         swing = AngleSubtract( *angle, destination );
00478         if ( swing > swingTolerance || swing < -swingTolerance ) {
00479             *swinging = qtrue;
00480         }
00481     }
00482 
00483     if ( !*swinging ) {
00484         return;
00485     }
00486     
00487     // modify the speed depending on the delta
00488     // so it doesn't seem so linear
00489     swing = AngleSubtract( destination, *angle );
00490     scale = fabs( swing );
00491     if ( scale < swingTolerance * 0.5 ) {
00492         scale = 0.5;
00493     } else if ( scale < swingTolerance ) {
00494         scale = 1.0;
00495     } else {
00496         scale = 2.0;
00497     }
00498 
00499     // swing towards the destination angle
00500     if ( swing >= 0 ) {
00501         move = uis.frametime * scale * speed;
00502         if ( move >= swing ) {
00503             move = swing;
00504             *swinging = qfalse;
00505         }
00506         *angle = AngleMod( *angle + move );
00507     } else if ( swing < 0 ) {
00508         move = uis.frametime * scale * -speed;
00509         if ( move <= swing ) {
00510             move = swing;
00511             *swinging = qfalse;
00512         }
00513         *angle = AngleMod( *angle + move );
00514     }
00515 
00516     // clamp to no more than tolerance
00517     swing = AngleSubtract( destination, *angle );
00518     if ( swing > clampTolerance ) {
00519         *angle = AngleMod( destination - (clampTolerance - 1) );
00520     } else if ( swing < -clampTolerance ) {
00521         *angle = AngleMod( destination + (clampTolerance - 1) );
00522     }
00523 }

Here is the call graph for this function:

void UI_TorsoSequencing playerInfo_t pi  )  [static]
 

Definition at line 216 of file ui_players.c.

References playerInfo_t::currentWeapon, TORSO_ATTACK, TORSO_DROP, TORSO_RAISE, TORSO_STAND, playerInfo_t::torsoAnim, playerInfo_t::torsoAnimationTimer, UI_ForceTorsoAnim(), UI_PlayerInfo_SetWeapon(), UI_SetTorsoAnim(), and playerInfo_t::weapon.

00216                                                    {
00217     int     currentAnim;
00218 
00219     currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT;
00220 
00221     if ( pi->weapon != pi->currentWeapon ) {
00222         if ( currentAnim != TORSO_DROP ) {
00223             pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;
00224             UI_ForceTorsoAnim( pi, TORSO_DROP );
00225         }
00226     }
00227 
00228     if ( pi->torsoAnimationTimer > 0 ) {
00229         return;
00230     }
00231 
00232     if( currentAnim == TORSO_GESTURE ) {
00233         UI_SetTorsoAnim( pi, TORSO_STAND );
00234         return;
00235     }
00236 
00237     if( currentAnim == TORSO_ATTACK || currentAnim == TORSO_ATTACK2 ) {
00238         UI_SetTorsoAnim( pi, TORSO_STAND );
00239         return;
00240     }
00241 
00242     if ( currentAnim == TORSO_DROP ) {
00243         UI_PlayerInfo_SetWeapon( pi, pi->weapon );
00244         pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH;
00245         UI_ForceTorsoAnim( pi, TORSO_RAISE );
00246         return;
00247     }
00248 
00249     if ( currentAnim == TORSO_RAISE ) {
00250         UI_SetTorsoAnim( pi, TORSO_STAND );
00251         return;
00252     }
00253 }

Here is the call graph for this function:


Variable Documentation

int dp_realtime [static]
 

Definition at line 44 of file ui_players.c.

Referenced by UI_DrawPlayer(), UI_MachinegunSpinAngle(), UI_PlayerInfo_SetInfo(), and UI_RunLerpFrame().

float jumpHeight [static]
 

Definition at line 45 of file ui_players.c.

Referenced by UI_LegsSequencing(), and UI_PlayerInfo_SetInfo().


Generated on Thu Aug 25 14:33:22 2005 for Quake III Arena by  doxygen 1.3.9.1