Esempio n. 1
0
    private Quaternion[] alternativeSampleRotations; // Stors the alternative sample rotations used for undoing and redoing animations

    /* Coroutine that moves the dummy from its current sample to the next sample by lerping over t. Will move back to first sample after
     * it has reached the last sample. Stores the information in global variables lastT and lastSampleIndex for the ability to pause and
     * then play again from the same position. */
    private IEnumerator MoveToNextSample()
    {
        if (lastSampleIndex < DMS.SFS_GetEndSliderSampleIndex())      // If last sample index isn't out of range, continue playing
        {
            if (!isPaused)
            {
                lastT = 0f;
            }
            else
            {
                isPaused = false;
            }
            while (lastT < 1)   // Lerp from t being 0 to t being 1
            {
                lastT += Time.deltaTime / DMS.SBS_GetSampleRate();
                transform.position = Vector3.Lerp(samplePositions[lastSampleIndex], samplePositions[lastSampleIndex + 1], lastT);
                transform.rotation = Quaternion.Lerp(sampleRotations[lastSampleIndex], sampleRotations[lastSampleIndex + 1], lastT);
                DMS.SFS_AdjustSlider("CurrentSlider", lastSampleIndex, lastT);
                yield return(null);
            }
            // When it has reached the next sample, increment last sample index and start MoveToNextSample again
            lastSampleIndex++;
            yield return(StartCoroutine(MoveToNextSample()));
        }
        else        // If the last sample index is out of range, reset dummy to start slider position and start MoveToNextSample again
        {
            GoToStart();
            yield return(StartCoroutine(MoveToNextSample()));
        }
    }
Esempio n. 2
0
    private int personalDummyIndex;              // The index that represents the respective dummy in DMS for this particular ghost

    /* Coroutine that takes in a ghost sample index and begins moving to the next sample index by lerping over t. Will increment the ghost sample index and call itself
    * once t is greater than 1. If the ghost sample index becomes greater than the end slider sample index, will start the ghost from the start slider sample index. */
    private IEnumerator MoveGhostToNextSample(int ghostSampleIndex)
    {
        if (ghostSampleIndex < sliderFieldScript.GetEndSliderSampleIndex())
        {
            float t = 0f;
            while (t < 1)
            {
                t += Time.deltaTime / speedBandScript.GetSampleRate();
                transform.position = Vector3.Lerp(DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex + 1), t);
                transform.rotation = Quaternion.Lerp(DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex + 1), t);
                DMS.SFS_AdjustSlider("GhostSlider", ghostSampleIndex, t);
                yield return(null);
            }
            yield return(MoveGhostToNextSample(ghostSampleIndex + 1));
        }
        else
        {
            transform.position = DMS.DS_GetSamplePosition(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            transform.rotation = DMS.DS_GetSampleRotation(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            yield return(MoveGhostToNextSample(sliderFieldScript.GetStartSliderSampleIndex()));
        }
    }