Beispiel #1
0
 protected override void OnMixer(float time, MixClip mix)
 {
     if (mixPlayable.IsValid())
     {
         if (!mix.connect || !Application.isPlaying)
         {
             XAnimationClip clipA = (XAnimationClip)mix.blendA;
             XAnimationClip clipB = (XAnimationClip)mix.blendB;
             if (clipA && clipB)
             {
                 mixA = clipA.playable;
                 mixB = clipB.playable;
             }
         }
         mix.connect = true;
         float weight = (time - mix.start) / mix.duration;
         if (mixA.IsValid() && mixB.IsValid())
         {
             mixJob.weight = weight;
             mixPlayable.SetJobData(mixJob);
         }
         else
         {
             string tip = "playable invalid while animating mix ";
             Debug.LogError(tip + mixA.IsValid() + " " + mixB.IsValid());
         }
     }
 }
Beispiel #2
0
        //============================================================================================

        /**
         *  @brief This function is called automatically by the MxMAnimator before any playable graph
         *  changes have occured. It caches the position and rotation of all transfroms in your control
         *  rig so they can be re-applied in AnimationJobs.
         *
         *********************************************************************************************/
        public void CacheTransforms()
        {
            if (Time.time - m_lastTimeCached > Mathf.Epsilon)
            {
                m_lastTimeCached = Time.time;

                var rigJobData = m_riggingScriptPlayable.GetJobData <RiggingIntegrationJob>();
                m_fixRigTransforms = rigJobData.FixRigTransforms = false;

                for (int i = 0; i < m_rigControls.Length; ++i)
                {
                    Transform controlTransform = m_rigControls[i];

                    rigJobData.RigTransformCache[i] = new TransformData()
                    {
                        Position = controlTransform.localPosition, Rotation = controlTransform.localRotation
                    };
                }

                for (int i = 0; i < m_rigs.Length; ++i)
                {
                    rigJobData.RigWeightCache[i] = m_rigs[i].weight;
                }

                m_riggingScriptPlayable.SetJobData(rigJobData);
            }
        }
Beispiel #3
0
            public void ApplyPresentationState(float deltaTime)
            {
                float rotateAngleRemaining = 0f;

                if (m_AnimState.turnDirection != 0)
                {
                    rotateAngleRemaining = Mathf.DeltaAngle(m_AnimState.rotation, m_AnimState.turnStartAngle) + m_Settings.animTurnAngle * m_AnimState.turnDirection;
                }

                if (m_AnimState.turnDirection == 0)
                {
                    m_Transition.Update((int)LocoMixerPort.Idle, m_Settings.turnTransitionSpeed, Time.deltaTime);
                }
                else
                {
                    var fraction  = 1f - Mathf.Abs(rotateAngleRemaining / m_Settings.animTurnAngle);
                    var mixerPort = (m_AnimState.turnDirection == -1) ? (int)LocoMixerPort.TurnL : (int)LocoMixerPort.TurnR;
                    var anim      = (m_AnimState.turnDirection == -1) ? m_AnimTurnL : m_AnimTurnR;

                    m_Transition.Update(mixerPort, m_Settings.turnTransitionSpeed, Time.deltaTime);
                    anim.SetTime(anim.GetAnimationClip().length *fraction);

                    if (m_LocomotionMixer.GetInputWeight((int)LocoMixerPort.Idle) < 0.01f)
                    {
                        m_AnimIdle.SetTime(0f);
                    }
                }


                float aimPitchFraction = m_AnimState.aimPitch / 180.0f;

                m_AnimAimLeft.SetTime(aimPitchFraction * m_AnimAimLeft.GetDuration());
                m_AnimAimMid.SetTime(aimPitchFraction * m_AnimAimMid.GetDuration());
                m_AnimAimRight.SetTime(aimPitchFraction * m_AnimAimRight.GetDuration());

                float aimYawLocal    = Mathf.DeltaAngle(m_AnimState.rotation, m_AnimState.aimYaw);
                float aimYawFraction = Mathf.Abs(aimYawLocal / m_Settings.aimYawAngle);

                m_AimMixer.SetInputWeight((int)AimMixerPort.AimMid, 1.0f - aimYawFraction);
                if (aimYawLocal < 0)
                {
                    m_AimMixer.SetInputWeight((int)AimMixerPort.AimLeft, aimYawFraction);
                    m_AimMixer.SetInputWeight((int)AimMixerPort.AimRight, 0.0f);
                }
                else
                {
                    m_AimMixer.SetInputWeight((int)AimMixerPort.AimLeft, 0.0f);
                    m_AimMixer.SetInputWeight((int)AimMixerPort.AimRight, aimYawFraction);
                }


                var job = m_FootIk.GetJobData <FootIkJob>();

                job.normalLeftFoot  = m_AnimState.footIkNormalLeft;
                job.normalRightFoot = m_AnimState.footIkNormaRight;
                job.ikOffset        = m_AnimState.footIkOffset;
                m_FootIk.SetJobData(job);
            }
    void Update()
    {
        var job = m_IKPlayable.GetJobData <FullBodyIKJob>();

        job.stiffness        = stiffness;
        job.maxPullIteration = maxPullIteration;
        m_IKPlayable.SetJobData(job);
    }
Beispiel #5
0
//
    public void Update(Vector3 target, JobSettings jobSettings, AnimationScriptPlayable playable)
    {
        var job = playable.GetJobData <CameraNoiseJob>();

        job.target      = target;
        job.jobSettings = jobSettings;
        playable.SetJobData(job);
    }
Beispiel #6
0
    void Update()
    {
        var job = m_CustomMixerPlayable.GetJobData <MixerJob>();

        job.weight = weight;

        m_CustomMixerPlayable.SetJobData(job);
    }
Beispiel #7
0
    public void Update(Vector3 target, Settings settings, CharAnimState animationState, AnimationScriptPlayable playable)
    {
        var job = playable.GetJobData <AimDragJob>();

        job.settings  = settings;
        job.animState = animationState;
        playable.SetJobData(job);
    }
Beispiel #8
0
    public void Update(PresentationState animState, Settings settings, AnimationScriptPlayable playable)
    {
        var job = playable.GetJobData <BankingJob>();

        job.animState  = animState;
        job.bankAmount = animState.banking;
        job.settings   = settings;
        playable.SetJobData(job);
    }
Beispiel #9
0
    public void Update(CharacterInterpolatedData animState, Settings settings, AnimationScriptPlayable playable)
    {
        var job = playable.GetJobData <BankingJob>();

        job.animState  = animState;
        job.bankAmount = animState.banking;
        job.settings   = settings;
        playable.SetJobData(job);
    }
    void Update()
    {
        var job = m_CustomMixerPlayable.GetJobData <MixerJob>();

        UpdateWeights();
        job.weight      = weight;
        job.boneWeights = m_BoneWeights;

        m_CustomMixerPlayable.SetJobData(job);
    }
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            base.PrepareFrame(playable, info);

            var job = postprocess.GetJobData <AnimationIKApplyJobPlayable>();

            job.leftHand  = leftHand.jobData;
            job.rightHand = rightHand.jobData;
            job.leftFoot  = leftFoot.jobData;
            job.rightFoot = rightFoot.jobData;
            job.look      = look.jobData;
            postprocess.SetJobData(job);
        }
Beispiel #12
0
    public static void Transition(AnimationScriptPlayable jobPlayable, float duration)
    {
        var job = jobPlayable.GetJobData <VelBasedBlendJob>();

        // Ignore transition when output buffer isnt full
        if (job.m_StoredOutputCount < k_OutputBufferCount)
        {
            return;
        }

        job.transitionDuration      = duration;
        job.transitionTimeRemaining = duration;
        job.doTransition            = true;
        job.inTransition            = true;
        jobPlayable.SetJobData(job);
    }
        public void UpdateTransition()
        {
            if (m_blending)
            {
                var inertializerJob = m_intertialPlayable.GetJobData <InertializerJob>();

                m_remainingTime -= Time.deltaTime;

                if (m_remainingTime <= 0f)
                {
                    inertializerJob.BlendActive = false;
                }
                else
                {
                    inertializerJob.BlendActive   = true;
                    inertializerJob.DeltaTime     = Time.deltaTime;
                    inertializerJob.RemainingTime = Mathf.Max(0.0001f, m_remainingTime);
                }

                m_intertialPlayable.SetJobData(inertializerJob);
            }
        }