コード例 #1
0
ファイル: sdk_playeranimstate.cpp プロジェクト: ziming/IOS
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CSDKPlayerAnimState::Update( float eyeYaw, float eyePitch )
{
	// Profile the animation update.
	VPROF( "CMultiPlayerAnimState::Update" );

	// Clear animation overlays because we're about to completely reconstruct them.
	ClearAnimationLayers();

	// Some mods don't want to update the player's animation state if they're dead and ragdolled.
	if ( !ShouldUpdateAnimState() )
	{
		ClearAnimationState();
		return;
	}

	// Get the SDK player.
	CSDKPlayer *pSDKPlayer = GetSDKPlayer();
	if ( !pSDKPlayer )
		return;

	// Get the studio header for the player.
	CStudioHdr *pStudioHdr = pSDKPlayer->GetModelPtr();
	if ( !pStudioHdr )
		return;

	// Check to see if we should be updating the animation state - dead, ragdolled?
	if ( !ShouldUpdateAnimState() )
	{
		ClearAnimationState();
		return;
	}

	// Store the eye angles.
	m_flEyeYaw = AngleNormalize( eyeYaw );
	m_flEyePitch = AngleNormalize( eyePitch );

	// Compute the player sequences.
	ComputeSequences( pStudioHdr );

	if ( SetupPoseParameters( pStudioHdr ) )
	{
		// Pose parameter - what direction are the player's legs running in.
		ComputePoseParam_MoveYaw( pStudioHdr );

		// Pose parameter - Torso aiming (up/down).
		ComputePoseParam_AimPitch( pStudioHdr );

		// Pose parameter - Torso aiming (rotation).
		ComputePoseParam_AimYaw( pStudioHdr );
	}

#ifdef CLIENT_DLL 
	if ( C_BasePlayer::ShouldDrawLocalPlayer() )
	{
		m_pSDKPlayer->SetPlaybackRate( 1.0f );
	}
#endif
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHL2MPPlayerAnimState::Update( float eyeYaw, float eyePitch )
{
	// Profile the animation update.
	VPROF( "CHL2MPPlayerAnimState::Update" );

	// Get the HL2MP player.
	CHL2MP_Player *pHL2MPPlayer = GetHL2MPPlayer();
	if ( !pHL2MPPlayer )
		return;

	// Get the studio header for the player.
	CStudioHdr *pStudioHdr = pHL2MPPlayer->GetModelPtr();
	if ( !pStudioHdr )
		return;

	// Check to see if we should be updating the animation state - dead, ragdolled?
	if ( !ShouldUpdateAnimState() )
	{
		ClearAnimationState();
		return;
	}

	// Store the eye angles.
	m_flEyeYaw = AngleNormalize( eyeYaw );
	m_flEyePitch = AngleNormalize( eyePitch );

	// Compute the player sequences.
	ComputeSequences( pStudioHdr );

	if ( SetupPoseParameters( pStudioHdr ) )
	{
		// Pose parameter - what direction are the player's legs running in.
		ComputePoseParam_MoveYaw( pStudioHdr );

		// Pose parameter - Torso aiming (up/down).
		ComputePoseParam_AimPitch( pStudioHdr );

		// Pose parameter - Torso aiming (rotation).
		ComputePoseParam_AimYaw( pStudioHdr );
	}

#ifdef CLIENT_DLL 
	if ( C_BasePlayer::ShouldDrawLocalPlayer() )
	{
		m_pHL2MPPlayer->SetPlaybackRate( 1.0f );
	}
#endif
}
コード例 #3
0
void CBasePlayerAnimState::Init( CBaseAnimatingOverlay *pPlayer, const CModAnimConfig &config )
{
	m_pOuter = pPlayer;
	m_AnimConfig = config;
	ClearAnimationState();
}
コード例 #4
0
void CBasePlayerAnimState::Update( float eyeYaw, float eyePitch )
{
	VPROF( "CBasePlayerAnimState::Update" );

	// Clear animation overlays because we're about to completely reconstruct them.
	ClearAnimationLayers();

	// Some mods don't want to update the player's animation state if they're dead and ragdolled.
	if ( !ShouldUpdateAnimState() )
	{
		ClearAnimationState();
		return;
	}
	
	
	CStudioHdr *pStudioHdr = GetOuter()->GetModelPtr();
	// Store these. All the calculations are based on them.
	m_flEyeYaw = AngleNormalize( eyeYaw );
	m_flEyePitch = AngleNormalize( eyePitch );

	// Compute sequences for all the layers.
	ComputeSequences( pStudioHdr );
	
	
	// Compute all the pose params.
	ComputePoseParam_BodyPitch( pStudioHdr );	// Look up/down.
	ComputePoseParam_BodyYaw();		// Torso rotation.
	ComputePoseParam_MoveYaw( pStudioHdr );		// What direction his legs are running in.

	
	ComputePlaybackRate();


#ifdef CLIENT_DLL
	if ( cl_showanimstate.GetInt() == m_pOuter->entindex() )
	{
		DebugShowAnimStateFull( 5 );
	}
	else if ( cl_showanimstate.GetInt() == -2 )
	{
		C_BasePlayer *targetPlayer = C_BasePlayer::GetLocalPlayer();

		if( targetPlayer && ( targetPlayer->GetObserverMode() == OBS_MODE_IN_EYE || targetPlayer->GetObserverMode() == OBS_MODE_CHASE ) )
		{
			C_BaseEntity *target = targetPlayer->GetObserverTarget();

			if( target && target->IsPlayer() )
			{
				targetPlayer = ToBasePlayer( target );
			}
		}

		if ( m_pOuter == targetPlayer )
		{
			DebugShowAnimStateFull( 6 );
		}
	}
#else
	if ( sv_showanimstate.GetInt() == m_pOuter->entindex() )
	{
		DebugShowAnimState( 20 );
	}
#endif
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CSDKPlayerAnimState::Update( float eyeYaw, float eyePitch, float flCharacterYaw, float flCharacterPitch )
{
	// Profile the animation update.
	VPROF( "CMultiPlayerAnimState::Update" );

	// Get the SDK player.
	CSDKPlayer *pSDKPlayer = GetSDKPlayer();
	if ( !pSDKPlayer )
		return;

	// Get the studio header for the player.
	CStudioHdr *pStudioHdr = pSDKPlayer->GetModelPtr();
	if ( !pStudioHdr )
		return;

	// Check to see if we should be updating the animation state - dead, ragdolled?
	if ( !ShouldUpdateAnimState() )
	{
		ClearAnimationState();
		return;
	}

	// Store the eye angles.
	m_flEyeYaw = AngleNormalize( eyeYaw );
	m_flEyePitch = AngleNormalize( eyePitch );

	float flRampSpeed = 20;
	if (pSDKPlayer->GetActiveSDKWeapon() && pSDKPlayer->GetActiveSDKWeapon()->HasAimInSpeedPenalty())
		flRampSpeed = 50;

	float flApproachSpeed = gpGlobals->frametime * pSDKPlayer->GetSlowMoMultiplier() * RemapVal(m_pSDKPlayer->m_Shared.GetAimIn(), 0, 1, 10, flRampSpeed);

	float flYawDifference = AngleNormalize( flCharacterYaw - m_flCharacterEyeYaw );
	float flYawApproachSpeed = flYawDifference * flApproachSpeed;
	if (fabs(flYawApproachSpeed) < fabs(flYawDifference))
		m_flCharacterEyeYaw += flYawApproachSpeed;
	else
		m_flCharacterEyeYaw = flCharacterYaw;

	float flPitchDifference = AngleNormalize( flCharacterPitch - m_flCharacterEyePitch );
	float flPitchApproachSpeed = flPitchDifference * flApproachSpeed;
	if (fabs(flPitchApproachSpeed) < fabs(flPitchDifference))
		m_flCharacterEyePitch += flPitchApproachSpeed;
	else
		m_flCharacterEyePitch = flCharacterPitch;

	// Compute the player sequences.
	ComputeSequences( pStudioHdr );

	if ( SetupPoseParameters( pStudioHdr ) )
	{
		// Pose parameter - what direction are the player's legs running in.
		ComputePoseParam_MoveYaw( pStudioHdr );

		ComputePoseParam_StuntYaw( pStudioHdr );

		// Pose parameter - Torso aiming (up/down).
		ComputePoseParam_AimPitch( pStudioHdr );

		// Pose parameter - Torso aiming (rotation).
		ComputePoseParam_AimYaw( pStudioHdr );
	}

#ifdef CLIENT_DLL 
	if ( C_BasePlayer::ShouldDrawLocalPlayer() )
	{
		m_pSDKPlayer->SetPlaybackRate( 1.0f );
	}
#endif
}
コード例 #6
0
ファイル: sdk_playeranimstate.cpp プロジェクト: ziming/IOS
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : event - 
//-----------------------------------------------------------------------------
void CSDKPlayerAnimState::DoAnimationEvent(PlayerAnimEvent_t event)
{
	bool resetShotCharging = false;

	switch(event)
	{
	case PLAYERANIMEVENT_BLANK:
		{
			GetSDKPlayer()->ResetShotCharging();
			return; // This is a dummy event, so don't do anything and return early
		}
	case PLAYERANIMEVENT_NONE:
		{
			resetShotCharging = true;
			//GetSDKPlayer()->RemoveFlag(FL_FREECAM | FL_KEEPER_SIDEWAYS_DIVING | FL_SLIDING);
			break;
		}
	case PLAYERANIMEVENT_CANCEL:
		{
			resetShotCharging = true;
			//GetSDKPlayer()->RemoveFlag(FL_FREECAM | FL_KEEPER_SIDEWAYS_DIVING | FL_SLIDING);
			ClearAnimationState();
			break;
		}
	case PLAYERANIMEVENT_KICK:
	case PLAYERANIMEVENT_PASS:
	case PLAYERANIMEVENT_PASS_STATIONARY:
	case PLAYERANIMEVENT_VOLLEY:
	case PLAYERANIMEVENT_HEELKICK:
	case PLAYERANIMEVENT_HEADER:
	case PLAYERANIMEVENT_HEADER_STATIONARY:
	case PLAYERANIMEVENT_THROWIN:
	case PLAYERANIMEVENT_THROW:
	case PLAYERANIMEVENT_KEEPER_HANDS_THROW:
	case PLAYERANIMEVENT_KEEPER_HANDS_KICK:
	case PLAYERANIMEVENT_KEEPER_HANDS_PUNCH:
	case PLAYERANIMEVENT_DIVINGHEADER:
		{
			resetShotCharging = true;
		}
	case PLAYERANIMEVENT_SLIDE:
	case PLAYERANIMEVENT_TACKLED_FORWARD:
	case PLAYERANIMEVENT_TACKLED_BACKWARD:
	case PLAYERANIMEVENT_KEEPER_DIVE_LEFT:
	case PLAYERANIMEVENT_KEEPER_DIVE_RIGHT:
	case PLAYERANIMEVENT_KEEPER_DIVE_FORWARD:
	case PLAYERANIMEVENT_KEEPER_DIVE_BACKWARD:
	case PLAYERANIMEVENT_LIFT_UP:
	case PLAYERANIMEVENT_BALL_ROLL_LEFT:
	case PLAYERANIMEVENT_BALL_ROLL_RIGHT:
	case PLAYERANIMEVENT_FAKE_SHOT:
	case PLAYERANIMEVENT_RAINBOW_FLICK:
	case PLAYERANIMEVENT_BICYCLE_KICK:
		{
			// HACKHACK: Side effects?
			//if (GetSDKPlayer()->m_Shared.GetAnimEvent() == PLAYERANIMEVENT_SLIDE)
			//{
			//	return;
			//}

			m_flPrimaryActionSequenceCycle = 0;
			m_iPrimaryActionSequence = CalcPrimaryActionSequence( event );
			m_bIsPrimaryActionSequenceActive = m_iPrimaryActionSequence != -1;
			break;
		}
	case PLAYERANIMEVENT_JUMP:
	case PLAYERANIMEVENT_KEEPER_JUMP:
		{
			// Play the jump animation.
			if (!m_bJumping)
			{
				m_bJumping = true;
				m_bFirstJumpFrame = true;
				m_flJumpStartTime = gpGlobals->curtime;
			}
			break;
		}
	case PLAYERANIMEVENT_CARRY:
		{
			m_iSecondaryActionSequence = CalcSecondaryActionSequence();			//add keeper carry as layer
			if ( m_iSecondaryActionSequence != -1 )
			{
				m_bIsSecondaryActionSequenceActive = true;
				m_flSecondaryActionSequenceCycle = 0;
				m_bCarryHold = true;
			}
			break;
		}
	case PLAYERANIMEVENT_CARRY_END:
		{
			//GetSDKPlayer()->RemoveFlag(FL_FREECAM);
			m_iSecondaryActionSequence = CalcSecondaryActionSequence();
			if ( m_iSecondaryActionSequence != -1 )
			{
				m_bIsSecondaryActionSequenceActive = true;
				m_flSecondaryActionSequenceCycle = 1.1f;
				m_bCarryHold = false;
			}
			break;
		}
	}

	if (resetShotCharging)
		GetSDKPlayer()->ResetShotCharging();

	switch (event)
	{
	case PLAYERANIMEVENT_DIVINGHEADER:
	case PLAYERANIMEVENT_TACKLED_FORWARD:
	case PLAYERANIMEVENT_TACKLED_BACKWARD:
		GetSDKPlayer()->AddFlag(FL_FREECAM);
		break;
	case PLAYERANIMEVENT_CARRY:
	case PLAYERANIMEVENT_SLIDE:
	case PLAYERANIMEVENT_KEEPER_DIVE_LEFT:
	case PLAYERANIMEVENT_KEEPER_DIVE_RIGHT:
	case PLAYERANIMEVENT_KEEPER_DIVE_FORWARD:
	case PLAYERANIMEVENT_KEEPER_DIVE_BACKWARD:
		break;
	default:
		GetSDKPlayer()->RemoveFlag(FL_FREECAM);
		break;
	}

	if (event != PLAYERANIMEVENT_CARRY && event != PLAYERANIMEVENT_CARRY_END)
	{
		GetSDKPlayer()->m_Shared.SetAnimEvent(event);
	}

	//GetSDKPlayer()->RemoveFlag(FL_KEEPER_SIDEWAYS_DIVING | FL_SLIDING);

	//switch(event)
	//{
	//case PLAYERANIMEVENT_KEEPER_DIVE_LEFT:
	//case PLAYERANIMEVENT_KEEPER_DIVE_RIGHT:
	//	//TODO: Uncomment once the getting stuck problem is fixed
	//	//GetSDKPlayer()->AddFlag(FL_KEEPER_SIDEWAYS_DIVING);
	//	break;
	//case PLAYERANIMEVENT_KEEPER_DIVE_FORWARD:
	//case PLAYERANIMEVENT_KEEPER_DIVE_BACKWARD:
	//case PLAYERANIMEVENT_SLIDE:
	//	//TODO: Uncomment once the getting stuck problem is fixed
	//	//GetSDKPlayer()->AddFlag(FL_SLIDING);
	//	break;
	//}

	//GetSDKPlayer()->m_Shared.SetAnimEvent(event);
}
コード例 #7
0
ファイル: sdk_playeranimstate.cpp プロジェクト: ziming/IOS
void CSDKPlayerAnimState::OnNewModel( void )
{
	m_bPoseParameterInit = false;
	ClearAnimationState();
}