void CBaseAnimatingOverlay::GetSkeleton( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], int boneMask ) { if(!pStudioHdr) { Assert(!"CBaseAnimating::GetSkeleton() without a model"); return; } if (!pStudioHdr->SequencesAvailable()) { return; } InitPose( pStudioHdr, pos, q, boneMask ); AccumulatePose( pStudioHdr, m_pIk, pos, q, GetSequence(), GetCycle(), GetPoseParameterArray(), boneMask, 1.0, gpGlobals->curtime ); // sort the layers int layer[MAX_OVERLAYS]; int i; for (i = 0; i < m_AnimOverlay.Count(); i++) { layer[i] = MAX_OVERLAYS; } for (i = 0; i < m_AnimOverlay.Count(); i++) { CAnimationLayer &pLayer = m_AnimOverlay[i]; if( (pLayer.m_flWeight > 0) && pLayer.IsActive() && pLayer.m_nOrder >= 0 && pLayer.m_nOrder < m_AnimOverlay.Count()) { layer[pLayer.m_nOrder] = i; } } for (i = 0; i < m_AnimOverlay.Count(); i++) { if (layer[i] >= 0 && layer[i] < m_AnimOverlay.Count()) { CAnimationLayer &pLayer = m_AnimOverlay[layer[i]]; // UNDONE: Is it correct to use overlay weight for IK too? AccumulatePose( pStudioHdr, m_pIk, pos, q, pLayer.m_nSequence, pLayer.m_flCycle, GetPoseParameterArray(), boneMask, pLayer.m_flWeight, gpGlobals->curtime ); } } if ( m_pIk ) { CIKContext auto_ik; auto_ik.Init( pStudioHdr, GetAbsAngles(), GetAbsOrigin(), gpGlobals->curtime, 0, boneMask ); CalcAutoplaySequences( pStudioHdr, &auto_ik, pos, q, GetPoseParameterArray(), boneMask, gpGlobals->curtime ); } else { CalcAutoplaySequences( pStudioHdr, NULL, pos, q, GetPoseParameterArray(), boneMask, gpGlobals->curtime ); } CalcBoneAdj( pStudioHdr, pos, q, GetEncodedControllerArray(), boneMask ); }
//----------------------------------------------------------------------------- // Purpose: find frame where they animation has moved a given distance. // Output : //----------------------------------------------------------------------------- float CAnimating::GetMovementFrame( float flDist ) { CStudioHdr *pstudiohdr = GetModelPtr( ); if (! pstudiohdr) return 0; float t = Studio_FindSeqDistance( pstudiohdr, GetSequence(), GetPoseParameterArray(), flDist ); return t; }
//----------------------------------------------------------------------------- // Purpose: // Output : //----------------------------------------------------------------------------- float CAnimating::GetEntryVelocity( int iSequence ) { CStudioHdr *pstudiohdr = GetModelPtr( ); if (! pstudiohdr) return 0; Vector vecVelocity; Studio_SeqVelocity( pstudiohdr, iSequence, 0.0, GetPoseParameterArray(), vecVelocity ); return vecVelocity.Length(); }
//----------------------------------------------------------------------------- // Purpose: // // Input : iSequence - // // Output : float - //----------------------------------------------------------------------------- float CAnimating::GetSequenceMoveYaw( int iSequence ) { Vector vecReturn; Assert( GetModelPtr() ); ::GetSequenceLinearMotion( GetModelPtr(), iSequence, GetPoseParameterArray(), &vecReturn ); if (vecReturn.Length() > 0) { return UTIL_VecToYaw( vecReturn ); } return NOMOTION; }
//----------------------------------------------------------------------------- // Purpose: // Output : //----------------------------------------------------------------------------- float CAnimating::GetInstantaneousVelocity( float flInterval ) { CStudioHdr *pstudiohdr = GetModelPtr( ); if (! pstudiohdr) return 0; // FIXME: someone needs to check for last frame, etc. float flNextCycle = GetCycle() + flInterval * GetSequenceCycleRate( GetSequence() ) * m_flPlaybackRate; Vector vecVelocity; Studio_SeqVelocity( pstudiohdr, GetSequence(), flNextCycle, GetPoseParameterArray(), vecVelocity ); vecVelocity *= m_flPlaybackRate; return vecVelocity.Length(); }
//========================================================= //========================================================= float CAnimating::SequenceDuration( CStudioHdr *pStudioHdr, int iSequence ) { if ( !pStudioHdr ) { DevWarning( 2, "CBaseAnimating::SequenceDuration( %d ) NULL pstudiohdr on %s!\n", iSequence, GetClassname() ); return 0.1; } if ( !pStudioHdr->SequencesAvailable() ) { return 0.1; } if (iSequence >= pStudioHdr->GetNumSeq() || iSequence < 0 ) { DevWarning( 2, "CBaseAnimating::SequenceDuration( %d ) out of range\n", iSequence ); return 0.1; } return Studio_Duration( pStudioHdr, iSequence, GetPoseParameterArray() ); }
float CAnimating::GetPoseParameter( int iParameter ) { CStudioHdr *pstudiohdr = GetModelPtr( ); if ( !pstudiohdr ) { Assert(!"CBaseAnimating::GetPoseParameter: model missing"); return 0.0; } if ( !pstudiohdr->SequencesAvailable() ) { return 0; } if (iParameter >= 0) { return Studio_GetPoseParameter( pstudiohdr, iParameter, GetPoseParameterArray()[iParameter]); } return 0.0; }
//----------------------------------------------------------------------------- // Purpose: // // Input : iSequence - // *pVec - // //----------------------------------------------------------------------------- void CAnimating::GetSequenceLinearMotion( int iSequence, Vector *pVec ) { Assert( GetModelPtr() ); ::GetSequenceLinearMotion( GetModelPtr(), iSequence, GetPoseParameterArray(), pVec ); }