bool CAnimationProxyDualCharacter::StartAnimationById(IEntity *entity, int animId, const CryCharAnimationParams& Params, float speedMultiplier) { ICharacterInstance* pICharacter = entity->GetCharacter(m_characterMain); if (pICharacter) { ISkeletonAnim* pISkeletonAnim = pICharacter->GetISkeletonAnim(); ICharacterInstance* pIShadowCharacter = m_firstPersonMode ? entity->GetCharacter(m_characterShadow) : NULL; IAnimationSet* pAnimSet = pICharacter->GetIAnimationSet(); SPlayParams playParams; GetPlayParams(animId, speedMultiplier, pAnimSet, playParams); bool shadowLocomotion = !(((Params.m_nFlags & CA_DISABLE_MULTILAYER) || (Params.m_nLayerID != 0)) || !m_killMixInFirst); bool bAnimStarted = false; bool bShouldPlayShadow = true; CryCharAnimationParams localParams = Params; if (!m_firstPersonMode || !shadowLocomotion) { localParams.m_fPlaybackSpeed *= m_firstPersonMode ? playParams.speedFP : playParams.speedTP; bAnimStarted = pISkeletonAnim->StartAnimationById(m_firstPersonMode ? playParams.animIDFP : playParams.animIDTP, localParams); if (bAnimStarted) { pISkeletonAnim->SetLayerBlendWeight(Params.m_nLayerID, 1.0f); } else bShouldPlayShadow = false; } if (bShouldPlayShadow && pIShadowCharacter != NULL) { ISkeletonAnim* pIShadowSkeletonAnim = pIShadowCharacter->GetISkeletonAnim(); localParams.m_fPlaybackSpeed = Params.m_fPlaybackSpeed * playParams.speedTP; if (pIShadowSkeletonAnim->StartAnimationById(playParams.animIDTP, localParams)) { bAnimStarted = true; pIShadowSkeletonAnim->SetLayerBlendWeight(Params.m_nLayerID, 1.0f); } } if (bAnimStarted && (Params.m_nLayerID == 0)) { m_allowsMix = (Params.m_nFlags & CA_DISABLE_MULTILAYER) == 0; } return bAnimStarted; } return false; }
bool CAnimationProxyDualCharacterUpper::StartAnimationById(IEntity *entity, int animId, const CryCharAnimationParams& Params, float speedMultiplier) { ICharacterInstance* pICharacter = entity->GetCharacter(m_characterMain); if (pICharacter) { ISkeletonAnim* pISkeletonAnim = pICharacter->GetISkeletonAnim(); ICharacterInstance* pIShadowCharacter = m_firstPersonMode ? entity->GetCharacter(m_characterShadow) : NULL; IAnimationSet* pAnimSet = pICharacter->GetIAnimationSet(); SPlayParams playParams; GetPlayParams(animId, speedMultiplier, pAnimSet, playParams); CryCharAnimationParams localParams = Params; bool startedMain = false; if (m_firstPersonMode) { localParams.m_fPlaybackSpeed *= playParams.speedFP; startedMain = pISkeletonAnim->StartAnimationById(playParams.animIDFP, localParams); } else { localParams.m_fPlaybackSpeed *= playParams.speedTP; startedMain = pISkeletonAnim->StartAnimationById(playParams.animIDTP, localParams); } if (startedMain) { pISkeletonAnim->SetLayerBlendWeight(Params.m_nLayerID, 1.0f); } if (pIShadowCharacter != NULL && (Params.m_nLayerID != 0)) { ISkeletonAnim* pIShadowSkeletonAnim = pIShadowCharacter->GetISkeletonAnim(); localParams.m_fPlaybackSpeed = Params.m_fPlaybackSpeed * playParams.speedTP; if (pIShadowSkeletonAnim->StartAnimationById(playParams.animIDTP, localParams)) { pIShadowSkeletonAnim->SetLayerBlendWeight(Params.m_nLayerID, 1.0f); } } return startedMain; } return false; }
void CLipSyncProvider_TransitionQueue::StartLipSync(IEntityAudioProxy* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) { CRY_ASSERT(pProxy); CRY_ASSERT(audioTriggerId != INVALID_AUDIO_CONTROL_ID); CRY_ASSERT((m_state == eS_Requested) || (m_state == eS_Unpaused)); if (lipSyncMethod != eLSM_None) { m_soundId = audioTriggerId; m_isSynchronized = false; if (ICharacterInstance* pChar = GetCharacterInstance()) { if (m_requestedAnimId >= 0) { ISkeletonAnim* skeletonAnimation = pChar->GetISkeletonAnim(); const bool success = skeletonAnimation->StartAnimationById(m_requestedAnimId, m_requestedAnimParams); if (success) { m_nCurrentAnimationToken = m_requestedAnimParams.m_nUserToken; SynchronizeAnimationToSound(audioTriggerId); } else { m_nCurrentAnimationToken = -1; } } } } m_state = eS_Started; }
bool CActionScope::InstallAnimation(int animID, const CryCharAnimationParams &animParams) { ISkeletonAnim *pSkelAnim = m_scopeContext.charInst->GetISkeletonAnim(); const bool startAnimationSuccess = pSkelAnim->StartAnimationById(animID, animParams); pSkelAnim->SetLayerPlaybackScale(animParams.m_nLayerID, m_speedBias); pSkelAnim->SetLayerBlendWeight(animParams.m_nLayerID, m_animWeight); return startAnimationSuccess; }
////////////////////////////////////////////////////////////////////////// /// Recording System Replay - This should work through mannequin void CMountedGunController::ReplayStartThirdPersonAnimations( ICharacterInstance* pCharacter, int upAnimId, int downAnimId ) { assert(pCharacter); ISkeletonAnim *pSkeletonAnim = pCharacter->GetISkeletonAnim(); assert(pSkeletonAnim); CryCharAnimationParams animParams; animParams.m_nFlags = CA_LOOP_ANIMATION; animParams.m_fTransTime = 0.1f; animParams.m_nLayerID = REPLAY_PLAYER_ANIMATION_LAYER_AIM_UP; animParams.m_fPlaybackWeight = 0.0f; pSkeletonAnim->StartAnimationById(upAnimId, animParams); animParams.m_nLayerID = REPLAY_PLAYER_ANIMATION_LAYER_AIM_DOWN; animParams.m_fPlaybackWeight = 0.0f; pSkeletonAnim->StartAnimationById(downAnimId, animParams); }