Example #1
0
 public void Add2(float x)
 {
     ge2.Add(2);
 }
    public void FindAnimationSpeeds()
    {
        gapLength       = 1f / aniIns.gapsPerSecond;
        numberOfSamples = Mathf.RoundToInt(clip.length * aniIns.gapsPerSecond);
        numberOfGaps    = numberOfSamples - 1;

        deltaHands          = new float[numberOfGaps];
        deltaHandsLeft      = new float[numberOfGaps];
        deltaHandsRight     = new float[numberOfGaps];
        handPositions_left  = new Vector3[numberOfSamples];
        handPositions_right = new Vector3[numberOfSamples];

        float t            = 0f;
        float animDuration = clip.length;

        clip.SampleAnimation(anim.gameObject, t * animDuration);

        Vector3 sm_leftHand  = anim.GetBoneTransform(HumanBodyBones.LeftHand).position;
        Vector3 sm_rightHand = anim.GetBoneTransform(HumanBodyBones.RightHand).position;

        Vector3 sm_leftHand_pre  = Vector3.zero;
        Vector3 sm_rightHand_pre = Vector3.zero;

        clip.SampleAnimation(anim.gameObject, 0f);

        handPositions_left[0]  = anim.GetBoneTransform(HumanBodyBones.LeftHand).position;
        handPositions_right[0] = anim.GetBoneTransform(HumanBodyBones.RightHand).position;

        for (int i = 1; i < numberOfSamples; i++)
        {
            t = ((float)i) * gapLength;

            clip.SampleAnimation(anim.gameObject, t);

            sm_leftHand_pre  = sm_leftHand;
            sm_rightHand_pre = sm_rightHand;

            sm_leftHand  = anim.GetBoneTransform(HumanBodyBones.LeftHand).position;
            sm_rightHand = anim.GetBoneTransform(HumanBodyBones.RightHand).position;

            handPositions_left[i]  = anim.GetBoneTransform(HumanBodyBones.LeftHand).position;
            handPositions_right[i] = anim.GetBoneTransform(HumanBodyBones.RightHand).position;

            deltaHands[i - 1]      = Vector3.Distance(sm_leftHand, sm_leftHand_pre); // + Vector3.Distance(sm_rightHand, sm_rightHand_pre);
            deltaHandsLeft[i - 1]  = Vector3.Distance(sm_leftHand, sm_leftHand_pre);
            deltaHandsRight[i - 1] = Vector3.Distance(sm_rightHand, sm_rightHand_pre);
        }

        // populate graph element
        for (int i = 0; i < numberOfGaps; i++)
        {
            gElementLeft.Add(deltaHandsLeft[i]);
            gElementRight.Add(deltaHandsRight[i]);
        }

        gElementLeft.AdjustRange();
        gElementRight.AdjustRange();

        indexes = new int[numberOfGaps];

        for (int i = 0; i < numberOfGaps; i++)
        {
            indexes[i] = i;
        }

        Array.Sort(deltaHands, indexes);
    }
Example #3
0
 public void Add1(float x)
 {
     ge1.Add(x);
 }