Ejemplo n.º 1
0
    public void UpdateInterpolators()
    {
        float tp;

        float[] newKeyTimes      = new float[_animInfo.Keys.Length];
        float[] originalKeyTimes = new float[_animInfo.Keys.Length];
        for (int i = 0; i < _animInfo.Keys.Length; i++)
        {
            int prevGoalKeyInd = _animInfo.FindPrevGoalAtTime(_animInfo.Keys[i].Time);
            int nextGoalKeyInd = prevGoalKeyInd + 1;
            if (nextGoalKeyInd > _animInfo.GoalKeys.Length - 1)
            {
                nextGoalKeyInd = _animInfo.GoalKeys.Length - 1;
            }

            int prevGoal = _animInfo.GoalKeys[prevGoalKeyInd];
            int nextGoal = _animInfo.GoalKeys[nextGoalKeyInd];


            if (_animInfo.Keys[i].Time <= _animInfo.Keys[prevGoal].Time)
            {
                tp = 0;
            }
            else if (_animInfo.Keys[nextGoal].Time == _animInfo.Keys[prevGoal].Time)
            {
                tp = 1;
            }
            else
            {
                tp = (_animInfo.Keys[i].Time - _animInfo.Keys[prevGoal].Time) / (_animInfo.Keys[nextGoal].Time - _animInfo.Keys[prevGoal].Time);
            }


            float s = TimingControl(tp);

            //map s into the whole spline
            float t = (s * (_animInfo.Keys[nextGoal].Time - _animInfo.Keys[prevGoal].Time) + _animInfo.Keys[prevGoal].Time);
            newKeyTimes[i] = t;
        }

        //Record original keytimes
        for (int i = 0; i < _animInfo.Keys.Length; i++)
        {
            originalKeyTimes[i]    = _animInfo.Keys[i].Time;
            _animInfo.Keys[i].Time = newKeyTimes[i];
        }

        //Update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);
        //Reset key times back
        for (int i = 0; i < _animInfo.Keys.Length; i++)
        {
            _animInfo.Keys[i].Time = originalKeyTimes[i];
        }
    }
Ejemplo n.º 2
0
    public void Reset()
    {
        _animInfo = GetComponent <AnimationInfo>();
        _animInfo.InitKeyPoints(); //should always update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);

        _interpolatorType = InterpolatorType.EndEffector;
        // FUNDA Effort2LowLevel(); //initialize low level parameters

        #if DEBUGMODE
        _targetRPrev = new List <Vector3>();
        _targetLPrev = new List <Vector3>();
        #endif

        _velArr = new List <float>();
        _tppArr = new List <float>();
    }
Ejemplo n.º 3
0
    public void Reset(){
        
		_animInfo = GetComponent<AnimationInfo>();        
    	_animInfo.InitKeyPoints(); //should always update interpolators
        _animInfo.InitInterpolators(Tval, Continuity, Bias);

        _interpolatorType = InterpolatorType.EndEffector;
		// FUNDA Effort2LowLevel(); //initialize low level parameters

        #if DEBUGMODE
        _targetRPrev = new List<Vector3>();
        _targetLPrev = new List<Vector3>();
        #endif

         _velArr = new List<float>();
        _tppArr = new List<float>();

    }