private void ImpactFinding() { NewClipInfoToPlay output = new NewClipInfoToPlay(-1, 0, -1, float.MaxValue); int poseStep = currentPose.Length; int frameCount = framesInfo.Length; float currentCost; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { float contactCost = contactPoints[frameIndex].CalculateCost(currentContactPoints[0], contactCostType); int boneIndex = frameIndex * poseStep; float poseCost = 0f; for (int i = 0; i < poseStep; i++) { poseCost += currentPose[i].CalculateCost(bonesData[boneIndex], poseCostType); boneIndex++; } currentCost = poseCost * poseWeight + contactCost * contactWeight; if (currentCost < output.bestCost) { output.Set( framesInfo[frameIndex].clipIndex, framesInfo[frameIndex].localTime, currentCost ); } } infos[0] = output; }
public void Execute() { NewClipInfoToPlay output = new NewClipInfoToPlay(-1, 0, -1, float.MaxValue); int trajectoryStep = currentTrajectory.Length; int poseStep = currentPose.Length; int frameCount = framesInfo.Length; int currentClipIndex; float currentCost; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { currentClipIndex = framesInfo[frameIndex].clipIndex; if ( framesInfo[frameIndex].localTime <whereWeCanFindingPos[currentClipIndex].x || framesInfo[frameIndex].localTime> whereWeCanFindingPos[currentClipIndex].y ) { continue; } currentCost = 0; float trajectoryCost = 0f; int tpIndex = frameIndex * trajectoryStep; for (int i = 0; i < trajectoryStep; i++) { trajectoryCost += currentTrajectory[i].CalculateCost(trajectoryPoints[tpIndex], trajectoryCostType); tpIndex++; } trajectoryCost *= trajectoryWeight; float poseCost = 0; int boneIndex = frameIndex * poseStep; for (int i = 0; i < poseStep; i++) { poseCost += currentPose[i].CalculateCost(bonesData[boneIndex], poseCostType); boneIndex++; } poseCost *= poseWeight; currentCost = trajectoryCost + poseCost; if (currentCost < output.bestCost) { output.Set( framesInfo[frameIndex].clipIndex, framesInfo[frameIndex].localTime, currentCost ); } } infos[0] = output; }
public void Execute() { NewClipInfoToPlay output = new NewClipInfoToPlay(-1, currentGroupIndex, -1, float.MaxValue); int trajectoryStep = currentTrajectory.Length; int poseStep = currentPose.Length; int frameCount = framesInfo.Length; float currentCost; float trajectoryCost; float poseCost; float costWeight; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { bool notSkipCheckingFrame = true; for (int i = 0; i < currentPlayingClips.Length; i++) { if (currentPlayingClips[i].groupIndex == currentGroupIndex && currentPlayingClips[i].clipIndex == framesInfo[frameIndex].clipIndex && currentPlayingClips[i].notFindInYourself) { notSkipCheckingFrame = false; break; } } if (notSkipCheckingFrame && framesInfo[frameIndex].sections.GetSection(sectionsIndexes[framesInfo[frameIndex].clipIndex])) { trajectoryCost = 0; poseCost = 0; costWeight = 1f; for (int i = 0; i < sectionDependecies.Length; i++) { if (framesInfo[frameIndex].sections.GetSection(sectionDependecies[i].sectionIndex)) { costWeight *= sectionDependecies[i].sectionWeight; } } int tpIndex = frameIndex * trajectoryStep; for (int i = 0; i < trajectoryStep; i++) { trajectoryCost += currentTrajectory[i].CalculateCost(trajectoryPoints[tpIndex], trajectoryCostType); tpIndex++; } int boneIndex = frameIndex * poseStep; for (int i = 0; i < poseStep; i++) { poseCost += currentPose[i].CalculateCost(bonesData[boneIndex], poseCostType); boneIndex++; } currentCost = costWeight * (poseWeight * poseCost + trajectoryWeight * trajectoryCost); if (currentCost < output.bestCost) { output.Set( framesInfo[frameIndex].clipIndex, framesInfo[frameIndex].localTime, currentCost ); } } } infos[0] = output; }
public void Execute() { NewClipInfoToPlay output = new NewClipInfoToPlay(-1, 0, -1, float.MaxValue); int poseStep = currentPose.Length; int frameCount = framesInfo.Length; int currentClipIndex; int contactPointIndex; int trajectoryStep = currentTrajectory.Length; float currentCost; for (int frameIndex = 0; frameIndex < frameCount; frameIndex++) { currentClipIndex = framesInfo[frameIndex].clipIndex; if ( framesInfo[frameIndex].localTime <whereWeCanFindingPos[currentClipIndex].x || framesInfo[frameIndex].localTime> whereWeCanFindingPos[currentClipIndex].y ) { continue; } currentCost = 0; float contactCost = 0f; int lastContactsIndex; switch (cntactMovmentType) { case ContactStateMovemetType.StartContact: contactPointIndex = frameIndex * (middleContactsCount + 1); for (int i = 0; i <= middleContactsCount; i++) { contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[i], contactCostType); contactPointIndex++; } break; case ContactStateMovemetType.ContactLand: contactPointIndex = frameIndex * (middleContactsCount + 1); for (int i = 1; i < middleContactsCount; i++) { contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[i], contactCostType); contactPointIndex++; } lastContactsIndex = currentContactPoints.Length - 1; contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[lastContactsIndex], contactCostType); break; case ContactStateMovemetType.StartContactLand: contactPointIndex = frameIndex * (middleContactsCount + 2); for (int i = 0; i <= middleContactsCount; i++) { contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[i], contactCostType); contactPointIndex++; } lastContactsIndex = currentContactPoints.Length - 1; contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[lastContactsIndex], contactCostType); break; case ContactStateMovemetType.Contact: contactPointIndex = frameIndex * middleContactsCount; for (int i = 1; i < middleContactsCount; i++) { contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[i], contactCostType); contactPointIndex++; } break; case ContactStateMovemetType.StartLand: contactPointIndex = frameIndex * 2; contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[0], contactCostType); contactPointIndex++; lastContactsIndex = currentContactPoints.Length - 1; contactCost += contactPoints[contactPointIndex].CalculateCost(currentContactPoints[lastContactsIndex], contactCostType); break; } int tpIndex = frameIndex * trajectoryStep; float trajectoryCost = 0f; for (int i = 0; i < trajectoryStep; i++) { trajectoryCost += currentTrajectory[i].CalculateCost(trajectoryPoints[tpIndex], trajectoryCostType); tpIndex++; } int boneIndex = frameIndex * poseStep; float poseCost = 0f; for (int i = 0; i < poseStep; i++) { poseCost += currentPose[i].CalculateCost(bonesData[boneIndex], poseCostType); boneIndex++; } currentCost = contactCost * contactWeight + trajectoryCost * trajectoryWeight + poseCost * poseWeight; if (currentCost < output.bestCost) { output.Set( framesInfo[frameIndex].clipIndex, framesInfo[frameIndex].localTime, currentCost ); } } infos[0] = output; }