예제 #1
0
 protected void InitAgent(AnimationInfo agent)
 {
     agent.Reset(agent.AnimName);
     agent.GetComponent <IKAnimator>().Reset();
     agent.GetComponent <Animation>().enabled = true;
     agent.GetComponent <Animation>().Play(agent.AnimName);
 }
예제 #2
0
 protected void Play(AnimationInfo agent)
 {
     //agent.animation[agent.AnimName].wrapMode = WrapMode.ClampForever;
     agent.GetComponent <Animation>()[agent.AnimName].wrapMode = WrapMode.Loop;
     agent.GetComponent <Animation>().Play(agent.AnimName);
     agent.GetComponent <Animation>().enabled = true;
 }
예제 #3
0
 protected void ResetComponents(AnimationInfo agent)
 {
     agent.GetComponent <Animation>().Stop();
     agent.GetComponent <FlourishAnimator>().Reset();
     agent.GetComponent <TorsoController>().Reset();
     agent.Reset(agent.AnimName);
     agent.GetComponent <IKAnimator>().Reset();
 }
예제 #4
0
    protected void StopAtFirstFrame(AnimationInfo agent)
    {
        if (!agent.GetComponent <Animation>().isPlaying)
        {
            agent.GetComponent <Animation>().Play(agent.AnimName);
        }

        agent.GetComponent <Animation>().clip.SampleAnimation(agent.gameObject, 0); //instead of rewind
        agent.GetComponent <Animation>().Stop();
    }
예제 #5
0
    protected void PlayAnim(AnimationInfo agent)
    {
        StopAtFirstFrame(agent); //stop first
        InitAgent(agent);


        agent.GetComponent <Animation>()[agent.AnimName].wrapMode = agent.IsContinuous ? WrapMode.Loop : WrapMode.ClampForever;
    }
예제 #6
0
    protected void StopAnimations(AnimationInfo agent)
    {
        StopAtFirstFrame(agent);
        agent.GetComponent <TorsoController>().Reset();


        StopAtFirstFrame(agent);
        PlayAnim(agent); //start the next animation
        StopAtFirstFrame(agent);
    }
예제 #7
0
    void Update()
    {
        //check if the last drive has been achieved
        if (_driveParams[31].DrivesAchieved && _firstQFirstPlay)     //special case for the first playing of the first question

        {
            UpdateParameters();  //map personality to motion callls initkeypoints which stops the animation
            ResetComponents(_agentRight);
            ResetComponents(_agentLeft);


            _persMapper.ComputeMotionEffortCoefs(_driveParams);


            _persMapper.MapPersonalityToMotion(_agentLeft.GetComponent <PersonalityComponent>());
            _persMapper.MapPersonalityToMotion(_agentRight.GetComponent <PersonalityComponent>());
            Play(_agentRight);
            Play(_agentLeft);

            _firstQFirstPlay = false;
        }

        UpdateCameraBoundaries();


#if DEBUGMODE || !WEBMODE
        if (Input.GetKeyDown("left"))
        {
            GetPrevQuestion();
        }

        else if (Input.GetKeyDown("right"))
        {
            GetNextQuestion();
        }
#endif
    }
예제 #8
0
    //Has to be lateupdate because we overwrite the transforms
    private void LateUpdate() {
        
        //correct breathing scales to ensure fbik computations are correct
        _torso.Spine1.transform.localScale = new Vector3(1, 1, 1);
        for (int i = 0; i < _torso.Spine1.GetChildCount(); i++)
            _torso.Spine1.GetChild(i).localScale = new Vector3(1, 1, 1); //correct child


       

        if (_animInfo.DisableLMA) {
            _animInfo.GetComponent<Animation>()[_animInfo.AnimName].speed = 1;
            DisableIK();

            return;
        }


        Interpolate();


        if (!GetComponent<Animation>().isPlaying || _animInfo.NormalizedT > 1f)
            return;


        EnableIK();

        if (_animInfo.NormalizedT > 1f)
            _stopHeadRotation = true;




        int keyInd = _animInfo.CurrKeyInd;
        float lt = _animInfo.LocalT;
        T = _animInfo.GlobalT;




        ComputeTargets(keyInd, lt, T);


        if (_animInfo.AnimName.ToUpper().Contains("AIM") || _animInfo.AnimName.ToUpper().Contains("GUARD") || _animInfo.AnimName.ToUpper().Contains("CUSTOMER"))
            BendKnees();

        if (_animInfo.CharacterName.ToUpper().Contains("CUSTOMER") || _animInfo.CharacterName.ToUpper().Contains("CARL"))
            BendKnees();


        if (_animInfo.AnimName.ToUpper().Contains("GUARD") || _animInfo.AnimName.ToUpper().Contains("CUSTOMER") ||
            _animInfo.AnimName.ToUpper().Contains("ROBBER") || _animInfo.AnimName.ToUpper().Contains("TELLER") || _animInfo.AnimName.ToUpper().Contains("CONVERS") || _animInfo.AnimName.ToUpper().Contains("FOOTBALL")) {

            if (HrMag < 0.1f)
                _stopHeadRotation = true;

          

            if (_stopHeadRotation) {
                //_laIk.solver.target = HeadTarget;
                _torso.Head.rotation = _torso.Spine.rotation;
                _laIk.solver.headWeight = 0;
            }

            else {
                _laIk.solver.headWeight = 1;
                //_laIk.solver.target = null;
            }

         //   UpdateLook(_animInfo.Tp + _animInfo.PrevGoalKeyInd);
       //     UpdateBodyIK(_animInfo.Tp + _animInfo.PrevGoalKeyInd);
            //UpdateBodyIK(_animInfo.NormalizedT);

        }
        //else {
            UpdateLook(_animInfo.NormalizedT);
            UpdateBodyIK(_animInfo.NormalizedT);


        //}


       

    }
    //Has to be lateupdate because we overwrite the transforms
    private void LateUpdate() {
        
        //correct breathing scales to ensure fbik computations are correct
        _torso.Spine1.transform.localScale = new Vector3(1, 1, 1);
        for (int i = 0; i < _torso.Spine1.childCount; i++)
            _torso.Spine1.GetChild(i).localScale = new Vector3(1, 1, 1); //correct child


       

        if (_animInfo.DisableLMA) {
            _animInfo.GetComponent<Animation>()[_animInfo.AnimName].speed = 1;
            DisableIK();
            //hack

            
           

            return;
        }

        //correct shoulder rotation back
        //_torso.Shoulder[1].transform.rotation = GetComponent<FlourishAnimator>().OriginalShoulderRot;


        Interpolate();


        if (!GetComponent<Animation>().isPlaying || _animInfo.NormalizedT > 1f)
            return;


        EnableIK();

        if (_animInfo.NormalizedT > 1f)
            _stopHeadRotation = true;




        int keyInd = _animInfo.CurrKeyInd;
        float lt = _animInfo.LocalT;
        T = _animInfo.GlobalT;




        ComputeTargets(keyInd, lt, T);


        //HACK!!
        //if (_animInfo.AnimName.Contains("Pick") || _animInfo.AnimName.Contains("pick") || _animInfo.AnimName.Contains("Point") || _animInfo.AnimName.Contains("point")) 
        //if (_animInfo.AnimName.Contains("Point") || _animInfo.AnimName.Contains("point") || _animInfo.AnimName.Contains("Guard") || _animInfo.AnimName.Contains("Customer"))
        //  BendArms();

        //To prevent comical affects during overshoot
     //   if (T > 1 && (_animInfo.AnimName.ToUpper().Contains("WALK") || _animInfo.AnimName.ToUpper().Contains("SALSA") || _animInfo.AnimName.ToUpper().Contains("HIGHFIVE")))
       //     return;


        if (_animInfo.AnimName.ToUpper().Contains("AIM") || _animInfo.AnimName.ToUpper().Contains("GUARD") || _animInfo.AnimName.ToUpper().Contains("CUSTOMER"))
            BendKnees();

        if (_animInfo.CharacterName.ToUpper().Contains("CUSTOMER") || _animInfo.CharacterName.ToUpper().Contains("CARL"))
            BendKnees();


        //HACK for customers scene
        if (_animInfo.AnimName.ToUpper().Contains("GUARD") || _animInfo.AnimName.ToUpper().Contains("CUSTOMER") ||
            _animInfo.AnimName.ToUpper().Contains("ROBBER") || _animInfo.AnimName.ToUpper().Contains("TELLER") || _animInfo.AnimName.ToUpper().Contains("CONVERS") || _animInfo.AnimName.ToUpper().Contains("FOOTBALL")) {

            if (HrMag < 0.1f)
                _stopHeadRotation = true;

          

            if (_stopHeadRotation) {
                //_laIk.solver.target = HeadTarget;
                _torso.Head.rotation = _torso.Spine.rotation;
                _laIk.solver.headWeight = 0;
            }

            else {
                _laIk.solver.headWeight = 1;
                //_laIk.solver.target = null;
            }

         //   UpdateLook(_animInfo.Tp + _animInfo.PrevGoalKeyInd);
       //     UpdateBodyIK(_animInfo.Tp + _animInfo.PrevGoalKeyInd);
            //UpdateBodyIK(_animInfo.NormalizedT);

        }
        //else {
            UpdateLook(_animInfo.NormalizedT);
            UpdateBodyIK(_animInfo.NormalizedT);


        //}


       

    }