int KComplexPath::GetEndVelocity() { BOOL bRetCode = false; int nVelocityX = 0; int nVelocityY = 0; int nVelocityZ = 0; int nTotalFrame = 0; int nEndVelocity = 1000; // default if no pre path IPath* pPath = NULL; bRetCode = m_cSubPaths.empty(); KG_PROCESS_SUCCESS(bRetCode); pPath = m_cSubPaths.back(); KGLOG_PROCESS_ERROR(pPath); nTotalFrame = pPath->GetTotalFrame(); pPath->GetVelocityByDeltaFrame(nTotalFrame, nVelocityX, nVelocityY, nVelocityZ); nEndVelocity = (int)sqrt((double)(nVelocityX * nVelocityX + nVelocityY * nVelocityY + nVelocityZ * nVelocityZ)); Exit1: Exit0: return nEndVelocity; }
void KComplexPath::GetVelocityByDeltaFrame(int nDeltaFrame, int& nVelocityX, int& nVelocityY, int& nVelocityZ) { IPath* pPath = NULL; int nDeltaFrameInPath = 0; nVelocityX = 0; nVelocityY = 0; nVelocityZ = 0; KGLOG_PROCESS_ERROR(nDeltaFrame >= 0); KGLOG_PROCESS_ERROR(nDeltaFrame <= m_nTotalFrame); KG_PROCESS_SUCCESS(m_nTotalFrame == 0); pPath = GetPathByDeltaFrame(nDeltaFrame, &nDeltaFrameInPath); KGLOG_PROCESS_ERROR(pPath); pPath->GetVelocityByDeltaFrame(nDeltaFrameInPath, nVelocityX, nVelocityY, nVelocityZ); Exit1: Exit0: return; }