diff options
author | Tim Angus <tim@ngus.net> | 2002-08-21 16:29:19 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2002-08-21 16:29:19 +0000 |
commit | 27363e40aed5f65658c6c48d2b2eea22fa136b3a (patch) | |
tree | 3b94b08bdebe1ffbe1d87ea64b47ec6dc431d831 /src/cgame | |
parent | a394af3d268a7909ecff77c2ef277705d40b0a69 (diff) |
* Model scale implemented for classes
* Vastly improved rendering of player models on walls
* Minor alterations to third person camera
* Removed some redundant EF_ flags
* Removed red alien dlight
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_ents.c | 2 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 160 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 58 |
3 files changed, 104 insertions, 116 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 615727cc..6d1dac68 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -805,7 +805,7 @@ static void CG_AddCEntity( centity_t *cent ) { if ( cent->currentState.eType >= ET_EVENTS ) { return; } - + // calculate the current origin CG_CalcEntityLerpPositions( cent ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index 5d465616..7f9dc88d 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -907,7 +907,7 @@ static void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int new animation_t *anim; lf->animationNumber = newAnimation; - newAnimation &= ~( ANIM_TOGGLEBIT | ANIM_WALLCLIMBING ); + newAnimation &= ~ANIM_TOGGLEBIT; if ( newAnimation < 0 || newAnimation >= MAX_PLAYER_TOTALANIMATIONS ) { CG_Error( "Bad animation number: %i", newAnimation ); @@ -1052,7 +1052,7 @@ static void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float ci = &cgs.clientinfo[ clientNum ]; // do the shuffle turn frames locally - if ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~( ANIM_TOGGLEBIT | ANIM_WALLCLIMBING ) ) == LEGS_IDLE ) { + if ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) { CG_RunLerpFrame( ci, ¢->pe.legs, LEGS_TURN, speedScale ); } else { CG_RunLerpFrame( ci, ¢->pe.legs, cent->currentState.legsAnim, speedScale ); @@ -1176,7 +1176,8 @@ Handles seperate torso motion if < 45 degrees, also show in torso =============== */ -static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) { +static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) +{ vec3_t legsAngles, torsoAngles, headAngles; float dest; static int movementOffsets[8] = { 0, 22, 45, -22, 0, 22, -45, -22 }; @@ -1185,7 +1186,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v int dir, clientNum; clientInfo_t *ci; - VectorCopy( cent->lerpAngles, headAngles ); + VectorCopy( srcAngles, headAngles ); headAngles[YAW] = AngleMod( headAngles[YAW] ); VectorClear( legsAngles ); VectorClear( torsoAngles ); @@ -1193,8 +1194,8 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v // --------- yaw ------------- // allow yaw to drift a bit - if ( ( cent->currentState.legsAnim & ~( ANIM_TOGGLEBIT | ANIM_WALLCLIMBING ) ) != LEGS_IDLE - || ( cent->currentState.torsoAnim & ~(ANIM_TOGGLEBIT | ANIM_WALLCLIMBING ) ) != TORSO_STAND ) { + if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE + || ( cent->currentState.torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND ) { // if not standing still, always point all in the same direction cent->pe.torso.yawing = qtrue; // always center cent->pe.torso.pitching = qtrue; // always center @@ -1312,7 +1313,7 @@ static void CG_HasteTrail( centity_t *cent ) { if ( cent->trailTime > cg.time ) { return; } - anim = cent->pe.legs.animationNumber & ~( ANIM_TOGGLEBIT | ANIM_WALLCLIMBING ); + anim = cent->pe.legs.animationNumber & ~ANIM_TOGGLEBIT; if ( anim != LEGS_RUN && anim != LEGS_BACK ) { return; } @@ -1392,24 +1393,28 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) if( held & ( 1 << UP_JETPACK ) ) { //FIXME: add model to back + //CG_PositionRotatedEntityOnTag( &head, &torso, ci->torsoModel, "tag_back" ); if( active & ( 1 << UP_JETPACK ) ) { if( cent->currentState.pos.trDelta[ 2 ] > 10.0f ) { - trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackAscendSound ); + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + vec3_origin, cgs.media.jetpackAscendSound ); addTime = 80; vel[ 2 ] = -60.0f; } else if( cent->currentState.pos.trDelta[ 2 ] < -10.0f ) { - trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackDescendSound ); + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + vec3_origin, cgs.media.jetpackDescendSound ); addTime = 110; vel[ 2 ] = -45.0f; } else { - trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackIdleSound ); + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + vec3_origin, cgs.media.jetpackIdleSound ); addTime = 100; vel[ 2 ] = -50.0f; } @@ -1528,21 +1533,6 @@ static void CG_PlayerSprites( centity_t *cent ) { return; } - if ( cent->currentState.eFlags & EF_AWARD_IMPRESSIVE ) { - CG_PlayerFloatSprite( cent, cgs.media.medalImpressive ); - return; - } - - if ( cent->currentState.eFlags & EF_AWARD_EXCELLENT ) { - CG_PlayerFloatSprite( cent, cgs.media.medalExcellent ); - return; - } - - if ( cent->currentState.eFlags & EF_AWARD_GAUNTLET ) { - CG_PlayerFloatSprite( cent, cgs.media.medalGauntlet ); - return; - } - team = cgs.clientinfo[ cent->currentState.clientNum ].team; if ( !(cent->currentState.eFlags & EF_DEAD) && cg.snap->ps.persistant[PERS_TEAM] == team && @@ -1868,40 +1858,58 @@ void CG_Player( centity_t *cent ) qboolean shadow; float shadowPlane; entityState_t *es = ¢->currentState; + int class = ( es->powerups >> 8 ) & 0xFF; + float scale; + vec3_t tempAxis[ 3 ], tempAxis2[ 3 ]; + vec3_t angles; // the client number is stored in clientNum. It can't be derived // from the entity number, because a single client may have // multiple corpses on the level using the same clientinfo clientNum = cent->currentState.clientNum; - if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) { - CG_Error( "Bad clientNum on player entity"); - } + if( clientNum < 0 || clientNum >= MAX_CLIENTS ) + CG_Error( "Bad clientNum on player entity" ); + ci = &cgs.clientinfo[ clientNum ]; // it is possible to see corpses from disconnected players that may // not have valid clientinfo - if ( !ci->infoValid ) { + if( !ci->infoValid ) return; - } // get the player model information renderfx = 0; - if ( cent->currentState.number == cg.snap->ps.clientNum) { - if (!cg.renderingThirdPerson) { + if( cent->currentState.number == cg.snap->ps.clientNum ) + { + if( !cg.renderingThirdPerson ) renderfx = RF_THIRD_PERSON; // only draw in mirrors - } else { - if (cg_cameraMode.integer) { - return; - } - } + else if( cg_cameraMode.integer ) + return; } - memset( &legs, 0, sizeof(legs) ); - memset( &torso, 0, sizeof(torso) ); - memset( &head, 0, sizeof(head) ); + memset( &legs, 0, sizeof( legs ) ); + memset( &torso, 0, sizeof( torso ) ); + memset( &head, 0, sizeof( head ) ); + + VectorCopy( cent->lerpAngles, angles ); + AnglesToAxis( cent->lerpAngles, tempAxis ); + + //rotate lerpAngles to floor + if( BG_rotateAxis( es->angles2, tempAxis, tempAxis2, qtrue, es->eFlags & EF_WALLCLIMBCEILING ) ) + AxisToAngles( tempAxis2, angles ); + else + VectorCopy( cent->lerpAngles, angles ); + + //normalise the pitch + if( angles[ PITCH ] < -180.0f ) + angles[ PITCH ] += 360.0f; // get the rotation information - CG_PlayerAngles( cent, legs.axis, torso.axis, head.axis ); + CG_PlayerAngles( cent, angles, legs.axis, torso.axis, head.axis ); + + //rotate the legs axis to back to the wall + if( BG_rotateAxis( es->angles2, legs.axis, tempAxis, qfalse, es->eFlags & EF_WALLCLIMBCEILING ) ) + AxisCopy( tempAxis, legs.axis ); // get the animation state (after rotation, to allow feet shuffle) CG_PlayerAnimation( cent, &legs.oldframe, &legs.frame, &legs.backlerp, @@ -1918,9 +1926,9 @@ void CG_Player( centity_t *cent ) // add a water splash if partially in and out of water CG_PlayerSplash( cent ); - if ( cg_shadows.integer == 3 && shadow ) { + if( cg_shadows.integer == 3 && shadow ) renderfx |= RF_SHADOW_PLANE; - } + renderfx |= RF_LIGHTING_ORIGIN; // use the same origin for all // @@ -1934,32 +1942,20 @@ void CG_Player( centity_t *cent ) VectorCopy( cent->lerpOrigin, legs.lightingOrigin ); legs.shadowPlane = shadowPlane; legs.renderfx = renderfx; - VectorCopy (legs.origin, legs.oldorigin); // don't positionally lerp at all + VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all - //TA: rotate the model so it sits on a wall - if( cent->currentState.legsAnim & ANIM_WALLCLIMBING && - !( cent->currentState.eFlags & EF_DEAD ) && - !( cg.intermissionStarted ) ) + //move the origin closer into the wall with a CapTrace + if( es->eFlags & EF_WALLCLIMB && !( es->eFlags & EF_DEAD ) && !( cg.intermissionStarted ) ) { - vec3_t forward, surfNormal, start, end, mins, maxs; + vec3_t surfNormal, start, end, mins, maxs; trace_t tr; - VectorCopy( cent->currentState.angles2, surfNormal ); - BG_FindBBoxForClass( ( es->powerups >> 8 ) & 0xFF, mins, maxs, NULL, NULL, NULL ); - - AngleVectors( cent->lerpAngles, forward, NULL, NULL ); - VectorCopy( surfNormal, legs.axis[2] ); - ProjectPointOnPlane( legs.axis[0], forward, legs.axis[2] ); - if( !VectorNormalize( legs.axis[0] ) ) - { - AngleVectors( cent->lerpAngles, NULL, NULL, forward ); - ProjectPointOnPlane( legs.axis[0], forward, legs.axis[2] ); - VectorNormalize( legs.axis[0] ); - } - CrossProduct( legs.axis[0], legs.axis[2], legs.axis[1] ); - legs.axis[1][0] = -legs.axis[1][0]; - legs.axis[1][1] = -legs.axis[1][1]; - legs.axis[1][2] = -legs.axis[1][2]; + if( es->eFlags & EF_WALLCLIMBCEILING ) + VectorSet( surfNormal, 0.0f, 0.0f, -1.0f ); + else + VectorCopy( cent->currentState.angles2, surfNormal ); + + BG_FindBBoxForClass( class, mins, maxs, NULL, NULL, NULL ); VectorMA( legs.origin, -TRACE_DEPTH, surfNormal, end ); VectorMA( legs.origin, 1.0f, surfNormal, start ); @@ -1970,8 +1966,18 @@ void CG_Player( centity_t *cent ) VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all } + //rescale the model + scale = BG_FindModelScaleForClass( class ); + + if( scale != 1.0f ) + { + VectorScale( legs.axis[ 0 ], scale, legs.axis[ 0 ] ); + VectorScale( legs.axis[ 1 ], scale, legs.axis[ 1 ] ); + VectorScale( legs.axis[ 2 ], scale, legs.axis[ 2 ] ); + + legs.nonNormalizedAxes = qtrue; + } - //CG_AddRefEntityWithPowerups( &legs, cent->currentState.powerups, ci->team ); trap_R_AddRefEntityToScene( &legs ); // if the model failed, allow the default nullmodel to be displayed @@ -1989,17 +1995,11 @@ void CG_Player( centity_t *cent ) VectorCopy( cent->lerpOrigin, torso.lightingOrigin ); - CG_PositionRotatedEntityOnTag( &torso, &legs, ci->legsModel, "tag_torso"); + CG_PositionRotatedEntityOnTag( &torso, &legs, ci->legsModel, "tag_torso" ); - if( cent->currentState.legsAnim & ANIM_WALLCLIMBING && - !( cent->currentState.eFlags & EF_DEAD ) && - !( cg.intermissionStarted ) ) - AnglesToAxis( cent->lerpAngles, torso.axis ); - torso.shadowPlane = shadowPlane; torso.renderfx = renderfx; - //CG_AddRefEntityWithPowerups( &torso, cent->currentState.powerups, ci->team ); trap_R_AddRefEntityToScene( &torso ); // @@ -2013,17 +2013,11 @@ void CG_Player( centity_t *cent ) VectorCopy( cent->lerpOrigin, head.lightingOrigin ); - CG_PositionRotatedEntityOnTag( &head, &torso, ci->torsoModel, "tag_head"); - - if( cent->currentState.legsAnim & ANIM_WALLCLIMBING && - !( cent->currentState.eFlags & EF_DEAD ) && - !( cg.intermissionStarted ) ) - AnglesToAxis( cent->lerpAngles, head.axis ); + CG_PositionRotatedEntityOnTag( &head, &torso, ci->torsoModel, "tag_head" ); head.shadowPlane = shadowPlane; head.renderfx = renderfx; - //CG_AddRefEntityWithPowerups( &head, cent->currentState.powerups, ci->team ); trap_R_AddRefEntityToScene( &head ); // @@ -2032,10 +2026,6 @@ void CG_Player( centity_t *cent ) CG_AddPlayerWeapon( &torso, NULL, cent ); CG_PlayerUpgrades( cent, &torso ); - -/* if( ( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS ) && - ( ( cent->currentState.powerups & 0xFF ) == PTE_HUMANS ) ) - trap_R_AddAdditiveLightToScene( cent->lerpOrigin, 64, 0.1, 0.1, 0.4 );*/ } /* @@ -2076,7 +2066,7 @@ void CG_Corpse( centity_t *cent ) VectorCopy( cent->currentState.angles, cent->lerpAngles ); // get the rotation information - CG_PlayerAngles( cent, legs.axis, torso.axis, head.axis ); + CG_PlayerAngles( cent, cent->lerpAngles, legs.axis, torso.axis, head.axis ); //set the correct frame (should always be dead) if ( cg_noPlayerAnims.integer ) diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 2d56f353..3002c66b 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -212,29 +212,33 @@ CG_OffsetThirdPersonView =============== */ #define FOCUS_DISTANCE 512 -static void CG_OffsetThirdPersonView( void ) { - vec3_t forward, right, up; - vec3_t view; - vec3_t focusAngles; - trace_t trace; +static void CG_OffsetThirdPersonView( void ) +{ + vec3_t forward, right, up; + vec3_t view; + vec3_t focusAngles; + trace_t trace; static vec3_t mins = { -4, -4, -4 }; static vec3_t maxs = { 4, 4, 4 }; - vec3_t focusPoint; - float focusDist; - float forwardScale, sideScale; + vec3_t focusPoint; + float focusDist; + float forwardScale, sideScale; + vec3_t surfNormal; - //TA: when wall climbing the viewheight is not straight up - if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING ) - VectorMA( cg.refdef.vieworg, cg.predictedPlayerState.viewheight, cg.predictedPlayerState.grapplePoint, cg.refdef.vieworg ); + if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) + VectorSet( surfNormal, 0.0f, 0.0f, -1.0f ); else - cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight; + VectorCopy( cg.predictedPlayerState.grapplePoint, surfNormal ); + + VectorMA( cg.refdef.vieworg, cg.predictedPlayerState.viewheight, surfNormal, cg.refdef.vieworg ); VectorCopy( cg.refdefViewAngles, focusAngles ); // if dead, look at killer - if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) { - focusAngles[YAW] = cg.predictedPlayerState.generic1; - cg.refdefViewAngles[YAW] = cg.predictedPlayerState.generic1; + if( cg.predictedPlayerState.stats[ STAT_HEALTH ] <= 0 ) + { + focusAngles[ YAW ] = cg.predictedPlayerState.generic1; + cg.refdefViewAngles[ YAW ] = cg.predictedPlayerState.generic1; } //if ( focusAngles[PITCH] > 45 ) { @@ -246,11 +250,7 @@ static void CG_OffsetThirdPersonView( void ) { VectorCopy( cg.refdef.vieworg, view ); - //TA: when wall climbing the viewheight is not straight up - if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING ) - VectorMA( view, 8, cg.predictedPlayerState.grapplePoint, view ); - else - view[2] += 8; + VectorMA( view, 8, surfNormal, view ); //cg.refdefViewAngles[PITCH] *= 0.5; @@ -264,12 +264,14 @@ static void CG_OffsetThirdPersonView( void ) { // trace a ray from the origin to the viewpoint to make sure the view isn't // in a solid block. Use an 8 by 8 block to prevent the view from near clipping anything - if (!cg_cameraMode.integer) { + if( !cg_cameraMode.integer ) + { CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID ); - if ( trace.fraction != 1.0 ) { + if( trace.fraction != 1.0 ) + { VectorCopy( trace.endpos, view ); - view[2] += (1.0 - trace.fraction) * 32; + view[ 2 ] += ( 1.0 - trace.fraction ) * 32; // try another trace to this position, because a tunnel may have the ceiling // close enogh that this is poking out @@ -282,12 +284,12 @@ static void CG_OffsetThirdPersonView( void ) { // select pitch to look at focus point from vieword VectorSubtract( focusPoint, cg.refdef.vieworg, focusPoint ); - focusDist = sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] ); + focusDist = sqrt( focusPoint[ 0 ] * focusPoint[ 0 ] + focusPoint[ 1 ] * focusPoint[ 1 ] ); if ( focusDist < 1 ) { focusDist = 1; // should never happen } - cg.refdefViewAngles[PITCH] = -180 / M_PI * atan2( focusPoint[2], focusDist ); - cg.refdefViewAngles[YAW] -= cg_thirdPersonAngle.value; + cg.refdefViewAngles[ PITCH ] = -180 / M_PI * atan2( focusPoint[ 2 ], focusDist ); + cg.refdefViewAngles[ YAW ] -= cg_thirdPersonAngle.value; } @@ -1204,10 +1206,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo } } - if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS && - cg.predictedPlayerState.persistant[PERS_TEAM] != TEAM_SPECTATOR ) - trap_R_AddAdditiveLightToScene( cg.predictedPlayerState.origin, 2000, 0.02f, 0.00f, 0.00f ); - // actually issue the rendering calls CG_DrawActive( stereoView ); |