void CMountedGunController::ReplayUpdateThirdPersonAnimations( ICharacterInstance* pCharacter, float aimRad, float aimUp, float aimDown, bool firstPerson /*= false*/) { if (pCharacter) { ISkeletonAnim *pSkeletonAnim = pCharacter->GetISkeletonAnim(); assert(pSkeletonAnim); //Update manually animation time, to match current weapon orientation uint32 numAnimsLayer = pSkeletonAnim->GetNumAnimsInFIFO(REPLAY_PLAYER_ANIMATION_LAYER_BASE); for(uint32 i=0; i<numAnimsLayer; i++) { CAnimation &animation = pSkeletonAnim->GetAnimFromFIFO(REPLAY_PLAYER_ANIMATION_LAYER_BASE, i); if (animation.HasStaticFlag(CA_MANUAL_UPDATE)) { float time = CalculateAnimationTime(aimRad); pSkeletonAnim->SetAnimationNormalizedTime(&animation, time); animation.ClearStaticFlag( CA_DISABLE_MULTILAYER ); } } if (firstPerson) return; //Update additive weights for aiming up/down pSkeletonAnim->SetLayerBlendWeight(REPLAY_PLAYER_ANIMATION_LAYER_AIM_UP, aimUp); pSkeletonAnim->SetLayerBlendWeight(REPLAY_PLAYER_ANIMATION_LAYER_AIM_DOWN, aimDown); } }
void CActionScope::Resume(float forcedBlendTime, uint32 resumeFlags) { if (!m_scopeContext.charInst) { return; } IAnimationSet *pAnimSet = m_scopeContext.charInst->GetIAnimationSet(); if (!pAnimSet) { return; } ISkeletonAnim *pSkeletonAnim = m_scopeContext.charInst->GetISkeletonAnim(); if (!pSkeletonAnim) { return; } const bool useDefaultBlendTime = (forcedBlendTime < 0); for (int i = 0; i < m_numLayers; ++i) { SSequencer &sequencer = m_layerSequencers[i]; const int animationLayer = m_layer + i; const float blendTime = useDefaultBlendTime ? sequencer.blend.duration : forcedBlendTime; if (sequencer.savedAnimNormalisedTime < 0) { pSkeletonAnim->StopAnimationInLayer(animationLayer, blendTime); } else { const uint32 pos = sequencer.pos - 1; if (pos < sequencer.sequence.size()) { SAnimClip& clip = sequencer.sequence[pos]; const int animID = pAnimSet->GetAnimIDByCRC(clip.animation.animRef.crc); if (0 <= animID) { CryCharAnimationParams params; InitAnimationParams(clip.animation, i, clip.blend, params); const bool installAnimationSuccess = InstallAnimation(animID, params); if (installAnimationSuccess) { const int animationsInLayer = pSkeletonAnim->GetNumAnimsInFIFO(animationLayer); CRY_ASSERT(1 <= animationsInLayer); const bool loopingAnimation = ((clip.animation.flags & CA_LOOP_ANIMATION) != 0); const uint32 restoreAnimationTimeFlagToCheck = loopingAnimation ? IActionController::ERF_RestoreLoopingAnimationTime : IActionController::ERF_RestoreNonLoopingAnimationTime; const bool restoreAnimationTime = ((restoreAnimationTimeFlagToCheck & resumeFlags) != 0); if (restoreAnimationTime) { const int lastAnimationIndex = animationsInLayer - 1; CAnimation &animation = pSkeletonAnim->GetAnimFromFIFO(animationLayer, lastAnimationIndex); pSkeletonAnim->SetAnimationNormalizedTime(&animation, sequencer.savedAnimNormalisedTime); } } } } } } }
void CVehicleWeaponControlled::Update3PAnim(CPlayer *player, float goalTime, float frameTime, const Matrix34 &mat) { if (player) { if (IEntity *entity = player->GetEntity()) { const float ANIM_ANGLE_RANGE = gf_PI*0.25f; static float dir = 0.05f; static float pos = 0.5f; pos += dir; if (pos > 1.0f) { pos = 1.0f; dir = -dir; } else if (pos < 0.0f) { pos = 0.0f; dir = -dir; } m_CurrentTime = LERP(m_CurrentTime, goalTime, frameTime); if (ICharacterInstance *character = entity->GetCharacter(0)) { ISkeletonAnim *pSkeletonAnim = character->GetISkeletonAnim(); assert(pSkeletonAnim); //Update manually animation time, to match current weapon orientation uint32 numAnimsLayer = pSkeletonAnim->GetNumAnimsInFIFO(0); for(uint32 i=0; i<numAnimsLayer; i++) { CAnimation &animation = pSkeletonAnim->GetAnimFromFIFO(0, i); if (animation.HasStaticFlag( CA_MANUAL_UPDATE )) { float time = m_CurrentTime; //pos; //fmod_tpl(aimRad / ANIM_ANGLE_RANGE, 1.0f); time = (float)__fsel(time, time, 1.0f + time); pSkeletonAnim->SetAnimationNormalizedTime(&animation, time); animation.ClearStaticFlag( CA_DISABLE_MULTILAYER ); } } } const SMountParams* pMountParams = GetMountedParams(); SEntitySlotInfo info; if (GetEntity()->GetSlotInfo(eIGS_ThirdPerson, info)) { if (info.pStatObj) { IStatObj *pStatsObj = info.pStatObj; const Vec3 &leftHandPos = pStatsObj->GetHelperPos(pMountParams->left_hand_helper.c_str()); const Vec3 &rightHandPos = pStatsObj->GetHelperPos(pMountParams->right_hand_helper.c_str()); const Vec3 leftIKPos = mat.TransformPoint(leftHandPos); const Vec3 rightIKPos = mat.TransformPoint(rightHandPos); player->SetIKPos("leftArm", leftIKPos, 1); player->SetIKPos("rightArm", rightIKPos, 1); } } } } }