void CSDKPlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr ) { // Get the estimated movement yaw. EstimateYaw(); // Get the view yaw. float flAngle = AngleNormalize( m_flEyeYaw ); // Calc side to side turning - the view vs. movement yaw. float flYaw = flAngle - m_PoseParameterData.m_flEstimateYaw; flYaw = AngleNormalize( -flYaw ); // Get the current speed the character is running. bool bIsMoving; float flPlaybackRate = CalcMovementPlaybackRate( &bIsMoving ); // Setup the 9-way blend parameters based on our speed and direction. Vector2D vecCurrentMoveYaw( 0.0f, 0.0f ); if ( bIsMoving ) { if ( mp_slammoveyaw.GetBool() ) { flYaw = SnapYawTo( flYaw ); } vecCurrentMoveYaw.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate; vecCurrentMoveYaw.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate; } // Set the 9-way blend movement pose parameters. GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveX, vecCurrentMoveYaw.x ); GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, -vecCurrentMoveYaw.y ); //Tony; flip it m_DebugAnimData.m_vecMoveYaw = vecCurrentMoveYaw; }
void CBasePlayerAnimState::ComputePlaybackRate() { VPROF( "CBasePlayerAnimState::ComputePlaybackRate" ); if ( m_AnimConfig.m_LegAnimType != LEGANIM_9WAY && m_AnimConfig.m_LegAnimType != LEGANIM_8WAY ) { // When using a 9-way blend, playback rate is always 1 and we just scale the pose params // to speed up or slow down the animation. bool bIsMoving; float flRate = CalcMovementPlaybackRate( &bIsMoving ); if ( bIsMoving ) GetOuter()->SetPlaybackRate( flRate ); else GetOuter()->SetPlaybackRate( 1 ); } }
void CBasePlayerAnimState::ComputeAimSequence() { VPROF( "CBasePlayerAnimState::ComputeAimSequence" ); // Synchronize the lower and upper body cycles. float flCycle = m_pOuter->GetCycle(); // Figure out the new cycle time. UpdateAimSequenceLayers( flCycle, AIMSEQUENCE_LAYER, true, &m_IdleSequenceTransitioner, 1 ); if ( ShouldBlendAimSequenceToIdle() ) { // What we do here is blend between the idle upper body animation (like where he's got the dual elites // held out in front of him but he's not moving) and his walk/run/crouchrun upper body animation, // weighting it based on how fast he's moving. That way, when he's moving slowly, his upper // body doesn't jiggle all around. bool bIsMoving; float flPlaybackRate = CalcMovementPlaybackRate( &bIsMoving ); if ( bIsMoving ) UpdateAimSequenceLayers( flCycle, AIMSEQUENCE_LAYER+2, false, &m_SequenceTransitioner, flPlaybackRate ); } OptimizeLayerWeights( AIMSEQUENCE_LAYER, NUM_AIMSEQUENCE_LAYERS ); }
//----------------------------------------------------------------------------- // Purpose: Override for backpeddling // Input : dt - //----------------------------------------------------------------------------- void CBasePlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr ) { VPROF( "CBasePlayerAnimState::ComputePoseParam_MoveYaw" ); //Matt: Goldsrc style animations need to not rotate the model if ( m_AnimConfig.m_LegAnimType == LEGANIM_GOLDSRC ) { #ifndef CLIENT_DLL //Adrian: Make the model's angle match the legs so the hitboxes match on both sides. GetOuter()->SetLocalAngles( QAngle( 0, m_flCurrentFeetYaw, 0 ) ); #endif } // If using goldsrc-style animations where he's moving in the direction that his feet are facing, // we don't use move yaw. if ( m_AnimConfig.m_LegAnimType != LEGANIM_9WAY && m_AnimConfig.m_LegAnimType != LEGANIM_8WAY ) return; // view direction relative to movement float flYaw; EstimateYaw(); float ang = m_flEyeYaw; if ( ang > 180.0f ) { ang -= 360.0f; } else if ( ang < -180.0f ) { ang += 360.0f; } // calc side to side turning flYaw = ang - m_flGaitYaw; // Invert for mapping into 8way blend flYaw = -flYaw; flYaw = flYaw - (int)(flYaw / 360) * 360; if (flYaw < -180) { flYaw = flYaw + 360; } else if (flYaw > 180) { flYaw = flYaw - 360; } if ( m_AnimConfig.m_LegAnimType == LEGANIM_9WAY ) { #ifndef CLIENT_DLL //Adrian: Make the model's angle match the legs so the hitboxes match on both sides. GetOuter()->SetLocalAngles( QAngle( 0, m_flCurrentFeetYaw, 0 ) ); #endif int iMoveX = GetOuter()->LookupPoseParameter( pStudioHdr, "move_x" ); int iMoveY = GetOuter()->LookupPoseParameter( pStudioHdr, "move_y" ); if ( iMoveX < 0 || iMoveY < 0 ) return; bool bIsMoving; float flPlaybackRate = CalcMovementPlaybackRate( &bIsMoving ); // Setup the 9-way blend parameters based on our speed and direction. Vector2D vCurMovePose( 0, 0 ); if ( bIsMoving ) { vCurMovePose.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate; vCurMovePose.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate; } GetOuter()->SetPoseParameter( pStudioHdr, iMoveX, vCurMovePose.x ); GetOuter()->SetPoseParameter( pStudioHdr, iMoveY, vCurMovePose.y ); m_vLastMovePose = vCurMovePose; } else { int iMoveYaw = GetOuter()->LookupPoseParameter( pStudioHdr, "move_yaw" ); if ( iMoveYaw >= 0 ) { GetOuter()->SetPoseParameter( pStudioHdr, iMoveYaw, flYaw ); m_flLastMoveYaw = flYaw; // Now blend in his idle animation. // This makes the 8-way blend act like a 9-way blend by blending to // an idle sequence as he slows down. #if defined(CLIENT_DLL) #ifndef INFESTED_DLL bool bIsMoving; CAnimationLayer *pLayer = m_pOuter->GetAnimOverlay( MAIN_IDLE_SEQUENCE_LAYER ); pLayer->SetWeight( 1 - CalcMovementPlaybackRate( &bIsMoving ) ); if ( !bIsMoving ) { pLayer->SetWeight( 1 ); } if ( ShouldChangeSequences() ) { // Whenever this layer stops blending, we can choose a new idle sequence to blend to, so he // doesn't always use the same idle. if ( pLayer->GetWeight() < 0.02f || m_iCurrent8WayIdleSequence == -1 ) { m_iCurrent8WayIdleSequence = m_pOuter->SelectWeightedSequence( ACT_IDLE ); m_iCurrent8WayCrouchIdleSequence = m_pOuter->SelectWeightedSequence( ACT_CROUCHIDLE ); } if ( m_eCurrentMainSequenceActivity == ACT_CROUCHIDLE || m_eCurrentMainSequenceActivity == ACT_RUN_CROUCH ) pLayer->SetSequence( m_iCurrent8WayCrouchIdleSequence ); else pLayer->SetSequence( m_iCurrent8WayIdleSequence ); } pLayer->SetPlaybackRate( 1 ); pLayer->SetCycle( pLayer->GetCycle() + m_pOuter->GetSequenceCycleRate( pStudioHdr, pLayer->GetSequence() ) * gpGlobals->frametime ); pLayer->SetCycle( fmod( pLayer->GetCycle(), 1 ) ); pLayer->SetOrder( MAIN_IDLE_SEQUENCE_LAYER ); #endif #endif } } }
void CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr ) { //DHL - Skillet float flYaw = 0.0f; CDHL_Player* pDHLPlayer = ToDHLPlayer(GetBasePlayer()); if ( pDHLPlayer->GetStuntState() == STUNT_PRONE && pDHLPlayer->m_iStuntDir == STUNTDIR_FORWARDS && pDHLPlayer->GetAbsVelocity().Length() < 5.0f ) flYaw = 0.0f; else { // Get the estimated movement yaw. EstimateYaw(); #if 0 // 9way ConVarRef mp_slammoveyaw("mp_slammoveyaw"); // Get the view yaw. float flAngle = AngleNormalize( m_flEyeYaw ); // Calc side to side turning - the view vs. movement yaw. float flYaw = flAngle - m_PoseParameterData.m_flEstimateYaw; flYaw = AngleNormalize( -flYaw ); // Get the current speed the character is running. bool bIsMoving; float flPlaybackRate = CalcMovementPlaybackRate( &bIsMoving ); // Setup the 9-way blend parameters based on our speed and direction. Vector2D vecCurrentMoveYaw( 0.0f, 0.0f ); if ( bIsMoving ) { if ( mp_slammoveyaw.GetBool() ) flYaw = SnapYawTo( flYaw ); vecCurrentMoveYaw.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate; vecCurrentMoveYaw.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate; } GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveX, vecCurrentMoveYaw.x ); GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, vecCurrentMoveYaw.y ); m_DebugAnimData.m_vecMoveYaw = vecCurrentMoveYaw; #else // view direction relative to movement //float flYaw; QAngle angles = GetBasePlayer()->GetLocalAngles(); float ang = angles[ YAW ]; //DHL - Skillet - Local and Abs angles are 0,0,0 here for remote players on client #ifdef CLIENT_DLL if ( !GetBasePlayer()->IsLocalPlayer() ) ang = m_flEyeYaw; #endif if ( ang > 180.0f ) { ang -= 360.0f; } else if ( ang < -180.0f ) { ang += 360.0f; } // calc side to side turning flYaw = ang - m_PoseParameterData.m_flEstimateYaw; // Invert for mapping into 8way blend flYaw = -flYaw; flYaw = flYaw - (int)(flYaw / 360) * 360; if (flYaw < -180) { flYaw = flYaw + 360; } else if (flYaw > 180) { flYaw = flYaw - 360; } } //DHL - Skillet endif //DHL - Skillet - HACK - Set stunt_yaw identically to move_yaw for non-forward prones int iStuntPose = GetBasePlayer()->LookupPoseParameter( pStudioHdr, "stunt_yaw" ); if ( iStuntPose >= 0 ) { if ( pDHLPlayer->GetStuntState() == STUNT_DIVE ) GetBasePlayer()->SetPoseParameter( iStuntPose, flYaw ); else if ( pDHLPlayer->GetStuntState() == STUNT_PRONE ) { float flStuntYaw = 0.0f; //Hackish switch ( pDHLPlayer->m_iStuntDir ) { case STUNTDIR_FORWARDS: flStuntYaw = 0.0f; break; case STUNTDIR_BACKWARDS: flStuntYaw = 180.0f; break; case STUNTDIR_LEFT: flStuntYaw = 90.0f; break; case STUNTDIR_RIGHT: flStuntYaw = -90.0f; break; } GetBasePlayer()->SetPoseParameter( iStuntPose, flStuntYaw ); } } //Tony; the hl2mp player models have the pose parameter going the opposite direction, so we need to negate this here. GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, /*-*/flYaw ); //DHL - Skillet - no negation needed for our models #endif }
void CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr ) { // Get the estimated movement yaw. EstimateYaw(); #if 0 // 9way ConVarRef mp_slammoveyaw("mp_slammoveyaw"); // Get the view yaw. float flAngle = AngleNormalize( m_flEyeYaw ); // Calc side to side turning - the view vs. movement yaw. float flYaw = flAngle - m_PoseParameterData.m_flEstimateYaw; flYaw = AngleNormalize( -flYaw ); // Get the current speed the character is running. bool bIsMoving; float flPlaybackRate = CalcMovementPlaybackRate( &bIsMoving ); // Setup the 9-way blend parameters based on our speed and direction. Vector2D vecCurrentMoveYaw( 0.0f, 0.0f ); if ( bIsMoving ) { if ( mp_slammoveyaw.GetBool() ) flYaw = SnapYawTo( flYaw ); vecCurrentMoveYaw.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate; vecCurrentMoveYaw.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate; } GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveX, vecCurrentMoveYaw.x ); GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, vecCurrentMoveYaw.y ); m_DebugAnimData.m_vecMoveYaw = vecCurrentMoveYaw; #else // view direction relative to movement float flYaw; QAngle angles = GetBasePlayer()->GetLocalAngles(); float ang = angles[ YAW ]; if ( ang > 180.0f ) { ang -= 360.0f; } else if ( ang < -180.0f ) { ang += 360.0f; } // calc side to side turning flYaw = ang - m_PoseParameterData.m_flEstimateYaw; // Invert for mapping into 8way blend flYaw = -flYaw; flYaw = flYaw - (int)(flYaw / 360) * 360; if (flYaw < -180) { flYaw = flYaw + 360; } else if (flYaw > 180) { flYaw = flYaw - 360; } //Tony; the hl2mp player models have the pose parameter going the opposite direction, so we need to negate this here. GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, -flYaw ); #endif }