diff --git a/reaction/cgame/cg_ents.c b/reaction/cgame/cg_ents.c index 47c80840..b3e13caa 100644 --- a/reaction/cgame/cg_ents.c +++ b/reaction/cgame/cg_ents.c @@ -33,6 +33,33 @@ void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, entity->backlerp = parent->backlerp; } +/* [QUARANTINE] - CG_PositionWeaponOnTag +====================== +CG_PositionWeaponOnTag + +Changed from CG_PositionEntityOnTag function to prevent backlerp change in animations +====================== +*/ +void CG_PositionWeaponOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ) { +int i; +orientation_t lerped; + +// lerp the tag +trap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, +1.0 - parent->backlerp, tagName ); + +// FIXME: allow origin offsets along tag? +VectorCopy( parent->origin, entity->origin ); +for ( i = 0 ; i < 3 ; i++ ) { +VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); +} + +// had to cast away the const to avoid compiler problems... +MatrixMultiply( lerped.axis, ((refEntity_t *)parent)->axis, entity->axis ); +// entity->backlerp = parent->backlerp; +} + + /* ====================== diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index ff759fce..c00b6f88 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -144,6 +144,8 @@ typedef struct { float barrelAngle; int barrelTime; qboolean barrelSpinning; + //Blaze: for weapon animations + lerpFrame_t weapon; } playerEntity_t; //================================================= @@ -372,6 +374,10 @@ typedef struct weaponInfo_s { qhandle_t flashModel; //Elder: added third person model to weaponInfo structure qhandle_t firstModel; + //Blaze: for animations + qhandle_t animHandModel; + animation_t animations[MAX_WEAPON_ANIMATIONS]; + vec3_t weaponMidpoint; // so it will rotate centered instead of by tag @@ -1391,7 +1397,8 @@ 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 ); - +//Blaze: for weapon animations +void CG_PositionWeaponOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); // @@ -1499,6 +1506,11 @@ void CG_DrawInformation( void ); qboolean CG_DrawOldScoreboard( void ); void CG_DrawOldTourneyScoreboard( void ); +// +// cg_players.c +// +void CG_WeaponAnimation( centity_t *cent, int *weaponOld, int *weapon, float *weaponBackLerp ); + // // cg_consolecmds.c // diff --git a/reaction/cgame/cg_main.c b/reaction/cgame/cg_main.c index 9f85bc1c..319c1b02 100644 --- a/reaction/cgame/cg_main.c +++ b/reaction/cgame/cg_main.c @@ -230,6 +230,8 @@ cvarTable_t cvarTable[] = { { &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT }, { &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT }, { &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT }, + //Blaze: to test the gun frames + { &cg_gun_frame, "cg_gun_frame", "0", CVAR_CHEAT }, { &cg_centertime, "cg_centertime", "3", CVAR_CHEAT }, { &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE}, { &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE }, diff --git a/reaction/cgame/cg_players.c b/reaction/cgame/cg_players.c index 283c9413..eed8a4d1 100644 --- a/reaction/cgame/cg_players.c +++ b/reaction/cgame/cg_players.c @@ -866,6 +866,33 @@ PLAYER ANIMATION ============================================================================= */ +/* [QUARANTINE] - Weapon Animations +=============== +CG_SetWeaponLerpFrame + +may include ANIM_TOGGLEBIT +=============== +*/ +static void CG_SetWeaponLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation ) +{ + animation_t *anim; + + lf->animationNumber = newAnimation; + newAnimation &= ~ANIM_TOGGLEBIT; + + if ( newAnimation < 0 || newAnimation >= MAX_WEAPON_ANIMATIONS ) { + CG_Error( "Bad weapon animation number: %i", newAnimation ); + } + + anim = &cg_weapons[cg.snap->ps.weapon].animations[ newAnimation ]; + + lf->animation = anim; + lf->animationTime = lf->frameTime + anim->initialLerp; + + if ( cg_debugAnim.integer ) { + CG_Printf( "Weapon Anim: %i\n", newAnimation ); + } +} /* @@ -903,7 +930,7 @@ Sets cg.snap, cg.oldFrame, and cg.backlerp cg.time should be between oldFrameTime and frameTime after exit =============== */ -static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale ) { +static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale, qboolean weaponAnim ) { int f, numFrames; animation_t *anim; @@ -915,7 +942,11 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation // see if the animation sequence is switching if ( newAnimation != lf->animationNumber || !lf->animation ) { - CG_SetLerpFrameAnimation( ci, lf, newAnimation ); + if (weaponAnim) { + CG_SetWeaponLerpFrame( ci, lf, newAnimation ); + } else { + CG_SetLerpFrameAnimation( ci, lf, newAnimation ); + } } // if we have passed the current frame, move it to @@ -997,6 +1028,43 @@ static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationN lf->oldFrame = lf->frame = lf->animation->firstFrame; } +/* [QUARANTINE] - Weapon Animations +=============== +CG_WeaponAnimation + +This is called from cg_weapons.c +=============== +*/ +void CG_WeaponAnimation( centity_t *cent, int *weaponOld, int *weapon, float *weaponBackLerp ) +{ + clientInfo_t *ci; + int clientNum; + + clientNum = cent->currentState.clientNum; + + if ( cg_noPlayerAnims.integer ) { + *weaponOld = *weapon = 0; + return; + } + + ci = &cgs.clientinfo[ clientNum ]; + + CG_RunLerpFrame( ci, ¢->pe.weapon, cent->currentState.generic1, 1, qtrue ); + + // QUARANTINE - Debug - Animations + #if 0 + if(cent->pe.weapon.oldFrame || cent->pe.weapon.frame || cent->pe.weapon.backlerp) { + CG_Printf("weaponOld: %i weaponFrame: %i weaponBack: %i\n", + cent->pe.weapon.oldFrame, cent->pe.weapon.frame, cent->pe.weapon.backlerp); + } + #endif + + *weaponOld = cent->pe.weapon.oldFrame; + *weapon = cent->pe.weapon.frame; + *weaponBackLerp = cent->pe.weapon.backlerp; + +} +// END /* =============== @@ -1026,16 +1094,16 @@ static void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float // do the shuffle turn frames locally if ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) { - CG_RunLerpFrame( ci, ¢->pe.legs, LEGS_TURN, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.legs, LEGS_TURN, speedScale, qfalse ); } else { - CG_RunLerpFrame( ci, ¢->pe.legs, cent->currentState.legsAnim, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.legs, cent->currentState.legsAnim, speedScale, qfalse ); } *legsOld = cent->pe.legs.oldFrame; *legs = cent->pe.legs.frame; *legsBackLerp = cent->pe.legs.backlerp; - CG_RunLerpFrame( ci, ¢->pe.torso, cent->currentState.torsoAnim, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.torso, cent->currentState.torsoAnim, speedScale, qfalse ); *torsoOld = cent->pe.torso.oldFrame; *torso = cent->pe.torso.frame; @@ -1496,7 +1564,7 @@ static void CG_PlayerFlag( centity_t *cent, qhandle_t hSkin, refEntity_t *torso angles[YAW] = cent->pe.flag.yawAngle; // lerp the flag animation frames ci = &cgs.clientinfo[ cent->currentState.clientNum ]; - CG_RunLerpFrame( ci, ¢->pe.flag, flagAnim, 1 ); + CG_RunLerpFrame( ci, ¢->pe.flag, flagAnim, 1, qfalse ); flag.oldframe = cent->pe.flag.oldFrame; flag.frame = cent->pe.flag.frame; flag.backlerp = cent->pe.flag.backlerp; diff --git a/reaction/cgame/cgame.plg b/reaction/cgame/cgame.plg index b0ce55bb..1bf045b6 100644 --- a/reaction/cgame/cgame.plg +++ b/reaction/cgame/cgame.plg @@ -6,13 +6,37 @@ --------------------Configuration: cgame - Win32 Debug--------------------