コード例 #1
0
    private PlayableGraph graph;                    //PlayAbleとの接続


    private void Awake()
    {
        graph = PlayableGraph.Create();
        var anim = GetComponent <Animator>();

        var defo = new List <AnimationClip>();

        //全レイヤーの初期アニメを取得し、デフォルトアニメとしてコンバータにセット
        foreach (var i in Enumerable.Range(0, anim.layerCount))
        {
            var temp = anim.GetCurrentAnimatorClipInfo(i)[0].clip;
            converters.Add(new Converter(graph, temp));
            defo.Add(temp);
            Debug.Log("Layer num " + i + ",defoult anim " + temp.name);
        }

        //LayerMask情報をコンバータにセット
        layerMixer = AnimationLayerMixerPlayable.Create(graph, anim.layerCount);
        foreach (var item in maskBoxs)
        {
            layerMixer.SetLayerMaskFromAvatarMask(item.numberToMask, item.layerMask);
        }

        var output = AnimationPlayableOutput.Create(graph, "output", anim);         //自身のAnimatorを出力先に決定

        output.SetSourcePlayable(layerMixer);
        graph.Play();
    }
コード例 #2
0
        public TwoDBlendTree(int layerId, PlayableGraph PlayableGraph, AnimationLayerMixerPlayable parentAnimationLayerMixerPlayable,
                             TwoDAnimationInput TwoDAnimationInput) : base(layerId, parentAnimationLayerMixerPlayable)
        {
            this.TwoDAnimationInput                   = TwoDAnimationInput;
            this.TwoDBlendTreeAnimationClips          = TwoDAnimationInput.TwoDBlendTreeAnimationClipInputs.ConvertAll(i => new TwoDBlendTreeAnimationClip(i.AnimationClip, i.TreePosition, i.Speed));
            this.TwoDBlendTreeAnimationClipsPositions = this.TwoDBlendTreeAnimationClips.ConvertAll(c => c.TreePosition).ToArray();
            this.Weights = new float[this.TwoDBlendTreeAnimationClipsPositions.Length];

            //create a playable mixer
            this.AnimationMixerPlayable = AnimationMixerPlayable.Create(PlayableGraph);

            foreach (var TwoDBlendTreeAnimationClip in TwoDBlendTreeAnimationClips)
            {
                var animationClipPlayable = AnimationClipPlayable.Create(PlayableGraph, TwoDBlendTreeAnimationClip.AnimationClip);
                animationClipPlayable.SetApplyFootIK(false);
                animationClipPlayable.SetApplyPlayableIK(false);
                animationClipPlayable.SetSpeed(TwoDBlendTreeAnimationClip.Speed);
                TwoDBlendTreeAnimationClip.InputHandler = PlayableExtensions.AddInput(this.AnimationMixerPlayable, animationClipPlayable, 0);
                PlayableExtensions.Play(animationClipPlayable);
                TwoDBlendTreeAnimationClip.AnimationClipPlayable = animationClipPlayable;
            }

            this.Inputhandler = PlayableExtensions.AddInput(parentAnimationLayerMixerPlayable, this.AnimationMixerPlayable, 0);
            if (TwoDAnimationInput.AvatarMask != null)
            {
                parentAnimationLayerMixerPlayable.SetLayerMaskFromAvatarMask((uint)this.Inputhandler, TwoDAnimationInput.AvatarMask);
            }
        }
コード例 #3
0
        //Create and play the playable graph
        void CreateAndPlayTree()
        {
            graph           = PlayableGraph.Create();
            animationOutput = AnimationPlayableOutput.Create(graph, "Animation", animator);
            masterMixer     = AnimationLayerMixerPlayable.Create(graph, siblingTracks.Count + 2);
            for (var i = 0; i < siblingTracks.Count; i++)
            {
                var animatorTrack = siblingTracks[i];
                var mix           = animatorTrack.CreateClipsMixer(graph);
                graph.Connect(mix, 0, masterMixer, i);
                masterMixer.SetInputWeight(i, 1f);
                if (animatorTrack.mask != null)
                {
                    masterMixer.SetLayerMaskFromAvatarMask((uint)i, animatorTrack.mask);
                }
                masterMixer.SetLayerAdditive((uint)i, animatorTrack.blendMode == AnimationBlendMode.Additive);
            }

            animatorPlayable = AnimatorControllerPlayable.Create(graph, animator.runtimeAnimatorController);
            graph.Connect(animatorPlayable, 0, masterMixer, siblingTracks.Count + 1);
            masterMixer.SetInputWeight(siblingTracks.Count + 1, 0f);

            animationOutput.SetSourcePlayable(masterMixer);

            // graph.Play();
            // masterMixer.Pause();

            // GraphVisualizerClient.Show(graph, this.name);
        }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        animator = GetComponent <Animator>();

        playableGraph = PlayableGraph.Create("ClairePlayableGraph");
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", animator);

        // Create Top Level Layer Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);

        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Create an Emotion Mixer
        mixerEmotionPlayable = AnimationMixerPlayable.Create(playableGraph, 4);

        // Wrap AnimController
        runtimeAnimController = animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);

        // Connect to Top Level Layer Mixer
        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 0);
        playableGraph.Connect(mixerEmotionPlayable, 0, mixerLayerPlayable, 1);
        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);
        mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);

        // Wrap the clips in a playable
        pHappy             = AnimationClipPlayable.Create(playableGraph, happy);
        pHappyTransitionIn = AnimationClipPlayable.Create(playableGraph, happyTransitionIn);
        pAngry             = AnimationClipPlayable.Create(playableGraph, angry);
        pAngryTransitionIn = AnimationClipPlayable.Create(playableGraph, angryTransitionIn);
        pTPose             = AnimationClipPlayable.Create(playableGraph, tPose);

        // Setup Durations for IsDone Checks
        pHappyTransitionIn.SetDuration(happyTransitionIn.length);
        pAngryTransitionIn.SetDuration(angryTransitionIn.length);

        // Connect to Emotion Mixer
        mixerEmotionPlayable.SetInputCount(5); // InputCount needs to be == to the number of connected clips (for normalization purposes)
        playableGraph.Connect(pHappy, 0, mixerEmotionPlayable, 0);
        playableGraph.Connect(pHappyTransitionIn, 0, mixerEmotionPlayable, 1);
        playableGraph.Connect(pAngry, 0, mixerEmotionPlayable, 2);
        playableGraph.Connect(pAngryTransitionIn, 0, mixerEmotionPlayable, 3);
        playableGraph.Connect(pTPose, 0, mixerEmotionPlayable, 4);

        Debug.Log("INputLength: " + mixerEmotionPlayable.GetInputCount());



        // Activate T Pose
        mixerEmotionPlayable.SetInputWeight(4, 1.0f);

        Debug.Log("Happy Transition Time: " + pHappyTransitionIn.GetDuration());

        // Plays the Graph
        playableGraph.Play();
    }
コード例 #5
0
        public void InitializeLayerBlending(PlayableGraph graph, int layerIndex, AnimationLayerMixerPlayable layerMixer)
        {
            graph.Connect(stateMixer, 0, layerMixer, layerIndex);

            layerMixer.SetInputWeight(layerIndex, startWeight);
            layerMixer.SetLayerAdditive((uint)layerIndex, type == AnimationLayerType.Additive);
            if (mask != null)
            {
                layerMixer.SetLayerMaskFromAvatarMask((uint)layerIndex, mask);
            }
        }
コード例 #6
0
    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent <Animator>();
        //smr = childwithSkinnedMeshRenderer.GetComponent<SkinnedMeshRenderer>();
        //blendShapeCount = smr.sharedMesh.blendShapeCount;

        playableGraph = PlayableGraph.Create("ClairePlayableGraph");
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", animator);

        // Create Top Level Layer Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);

        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Wrap AnimController
        runtimeAnimController = animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);

        // Create an Emotion Mixer
        mixerEmotionPlayable = AnimationMixerPlayable.Create(playableGraph, 10, true);
        //playableOutput.SetSourcePlayable(mixerEmotionPlayable);

        // Connect to Top Level Layer Mixer
        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 0);
        playableGraph.Connect(mixerEmotionPlayable, 0, mixerLayerPlayable, 1);
        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);
        mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);

        // Wrap the clips in a playable
        pInterested    = AnimationClipPlayable.Create(playableGraph, interested);
        pInterested2   = AnimationClipPlayable.Create(playableGraph, interested2);
        pEntertained   = AnimationClipPlayable.Create(playableGraph, entertained);
        pUncomfortable = AnimationClipPlayable.Create(playableGraph, uncomfortable);
        pConfused      = AnimationClipPlayable.Create(playableGraph, confused);
        pBored         = AnimationClipPlayable.Create(playableGraph, bored);
        pNeutral       = AnimationClipPlayable.Create(playableGraph, neutral);

        // Connect to Emotion Mixer
        //mixerEmotionPlayable.SetInputCount(5); // InputCount needs to be == to the number of connected clips (for normalization purposes)
        playableGraph.Connect(pInterested, 0, mixerEmotionPlayable, 0);
        playableGraph.Connect(pInterested2, 0, mixerEmotionPlayable, 1);
        playableGraph.Connect(pEntertained, 0, mixerEmotionPlayable, 2);
        playableGraph.Connect(pUncomfortable, 0, mixerEmotionPlayable, 3);
        playableGraph.Connect(pConfused, 0, mixerEmotionPlayable, 4);
        playableGraph.Connect(pBored, 0, mixerEmotionPlayable, 5);
        playableGraph.Connect(pNeutral, 0, mixerEmotionPlayable, 6);


        // Plays the Graph
        playableGraph.Play();
    }
コード例 #7
0
            /************************************************************************************************************************/

            /// <summary>[Pro-Only]
            /// Sets an <see cref="AvatarMask"/> to determine which bones the layer at the specified index will affect.
            /// </summary>
            public void SetMask(int index, AvatarMask mask)
            {
                SetMinCount(index + 1);

#if UNITY_EDITOR
                _Layers[index]._Mask = mask;
#endif

                if (mask == null)
                {
                    mask = new AvatarMask();
                }

                LayerMixer.SetLayerMaskFromAvatarMask((uint)index, mask);
            }
コード例 #8
0
    //============================================================================================================

    void Awake()
    {
        animator = this.GetComponent <Animator>();

        //PlayableAPIの準備
        graph = PlayableGraph.Create();
        motionMixers.Add(new MotionMixer(this, graph));
        motionMixers.Add(new MotionMixer(this, graph));
        layerMixer = AnimationLayerMixerPlayable.Create(graph, 2);
        if (upperMask != null)
        {
            layerMixer.SetLayerMaskFromAvatarMask(1, upperMask);
        }

        output = AnimationPlayableOutput.Create(graph, "output", animator);
        graph.Play();
    }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
        animator        = GetComponent <Animator>();
        smr             = childwithSkinnedMeshRenderer.GetComponent <SkinnedMeshRenderer>();
        blendShapeCount = smr.sharedMesh.blendShapeCount;

        playableGraph = PlayableGraph.Create("ClairePlayableGraph");
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", animator);

        // Create Top Level Layer Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);

        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Wrap AnimController
        runtimeAnimController = animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);

        // Create an Emotion Mixer
        mixerEmotionPlayable = AnimationMixerPlayable.Create(playableGraph, 4);
        //playableOutput.SetSourcePlayable(mixerEmotionPlayable);

        // Connect to Top Level Layer Mixer
        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 0);
        playableGraph.Connect(mixerEmotionPlayable, 0, mixerLayerPlayable, 1);
        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);
        mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);

        // Wrap the clips in a playable
        pHappy = AnimationClipPlayable.Create(playableGraph, happy);
        pAngry = AnimationClipPlayable.Create(playableGraph, angry);

        // Connect to Emotion Mixer
        //mixerEmotionPlayable.SetInputCount(5); // InputCount needs to be == to the number of connected clips (for normalization purposes)
        playableGraph.Connect(pHappy, 0, mixerEmotionPlayable, 0);
        playableGraph.Connect(pAngry, 0, mixerEmotionPlayable, 1);

        // Plays the Graph
        playableGraph.Play();
    }
コード例 #10
0
        public Finger(PlayableGraph graph, AnimationClip closed, AnimationClip opened, AvatarMask mask, VariableTweener lerper)
        {
            mixer = AnimationLayerMixerPlayable.Create(graph, 2);
            var openPlayable = AnimationClipPlayable.Create(graph, opened);

            graph.Connect(openPlayable, 0, mixer, 0);
            var closedPlayable = AnimationClipPlayable.Create(graph, closed);

            graph.Connect(closedPlayable, 0, mixer, 1);
            mixer.SetLayerAdditive(0, false);
            mixer.SetLayerMaskFromAvatarMask(0, mask);
            mixer.SetInputWeight(0, 1);
            mixer.SetInputWeight(1, 0);
            crossFadingWeight           = new TweenableFloat(lerper);
            crossFadingWeight.onChange += (value) =>
            {
                mixer.SetInputWeight(0, 1 - value);
                mixer.SetInputWeight(1, value);
            };
        }
コード例 #11
0
        public void InitializeLayerBlending(PlayableGraph graph, int layerIndex, AnimationLayerMixerPlayable layerMixer)
        {
            graph.Connect(stateMixer, 0, layerMixer, layerIndex);

            layerMixer.SetInputWeight(layerIndex, startWeight);
            layerMixer.SetLayerAdditive((uint)layerIndex, type == AnimationLayerType.Additive);
            if (mask != null)
            {
                layerMixer.SetLayerMaskFromAvatarMask((uint)layerIndex, mask);
            }

            if (layerIndex == 0)
            {
                //Doesn't make any sense for base layer to be additive!
                layerMixer.SetLayerAdditive((uint)layerIndex, false);
            }
            else
            {
                layerMixer.SetLayerAdditive((uint)layerIndex, type == AnimationLayerType.Additive);
            }
        }
コード例 #12
0
        internal override Playable OnCreatePlayableGraph(PlayableGraph graph, GameObject go, IntervalTree <RuntimeElement> tree)
        {
            if (base.isSubTrack)
            {
                throw new InvalidOperationException("Nested animation tracks should never be asked to create a graph directly");
            }
            List <AnimationTrack> list = new List <AnimationTrack>();

            if (this.compilableIsolated)
            {
                list.Add(this);
            }
            foreach (TrackAsset trackAsset in base.GetChildTracks())
            {
                AnimationTrack animationTrack = trackAsset as AnimationTrack;
                if (animationTrack != null && animationTrack.compilable)
                {
                    list.Add(animationTrack);
                }
            }
            AnimationMotionXToDeltaPlayable animationMotionXToDeltaPlayable = AnimationMotionXToDeltaPlayable.Create(graph);
            AnimationLayerMixerPlayable     animationLayerMixerPlayable     = AnimationTrack.CreateGroupMixer(graph, go, list.Count);

            graph.Connect <AnimationLayerMixerPlayable, AnimationMotionXToDeltaPlayable>(animationLayerMixerPlayable, 0, animationMotionXToDeltaPlayable, 0);
            animationMotionXToDeltaPlayable.SetInputWeight(0, 1f);
            for (int i = 0; i < list.Count; i++)
            {
                Playable source = (!list[i].inClipMode) ? list[i].CreateInfiniteTrackPlayable(graph, go, tree) : this.CompileTrackPlayable(graph, list[i], go, tree);
                graph.Connect <Playable, AnimationLayerMixerPlayable>(source, 0, animationLayerMixerPlayable, i);
                animationLayerMixerPlayable.SetInputWeight(i, (float)((!list[i].inClipMode) ? 1 : 0));
                if (list[i].applyAvatarMask && list[i].avatarMask != null)
                {
                    animationLayerMixerPlayable.SetLayerMaskFromAvatarMask((uint)i, list[i].avatarMask);
                }
            }
            return(animationMotionXToDeltaPlayable);
        }
コード例 #13
0
    //private float mainLoopTriggerTime = 1.0f;           // Time over which a main loop is interpolated with itself. [TODO] Should be made relative to main clip duration, as it will behave strangely for small durations.

    /*
     * Awake
     */
    private void Awake()
    {
        animator        = GetComponent <Animator>();
        goToEmotionList = new List <GoToEmotionEntry>();

        currentlyPlayingClips = new List <IFAClip>();

        // Create Playable Graph
        playableGraph = PlayableGraph.Create("ClairePlayableGraph");
        playableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
        var playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", animator);

        // Create Top Level Layer Mixer
        AnimationLayerMixerPlayable mixerLayerPlayable = AnimationLayerMixerPlayable.Create(playableGraph, 2);

        playableOutput.SetSourcePlayable(mixerLayerPlayable);

        // Create an Emotion Mixer
        int numberOfClips = 0;

        for (int i = 0; i < emotionObjects.Count; i++)
        {
            for (int j = 0; j < emotionObjects[i].animationGroupList.Count; j++)
            {
                if (emotionObjects[i].animationGroupList[j].main)
                {
                    numberOfClips++;
                }
                if (emotionObjects[i].animationGroupList[j].transitionIn)
                {
                    numberOfClips++;
                }
            }
        }
        mixerEmotionPlayable = AnimationMixerPlayable.Create(playableGraph, numberOfClips);    // Second argument sets number of inputs for clips to connect.

        // Wrap AnimController
        runtimeAnimController = animator.runtimeAnimatorController;
        var runtimeAnimControllerPlayable = AnimatorControllerPlayable.Create(playableGraph, runtimeAnimController);

        // Connect to Top Level Layer Mixer
        playableGraph.Connect(runtimeAnimControllerPlayable, 0, mixerLayerPlayable, 0);
        playableGraph.Connect(mixerEmotionPlayable, 0, mixerLayerPlayable, 1);
        mixerLayerPlayable.SetInputWeight(0, 1.0f);
        mixerLayerPlayable.SetInputWeight(1, 1.0f);
        mixerLayerPlayable.SetLayerMaskFromAvatarMask(1, headMask);
        //mixerLayerPlayable.SetLayerAdditive(1, true);

        // 1. Wraps each clip in a playable and connects them to the emotion mixer
        // 2. Also populate "playablesDict" to later be able to access the AnimationClipPlayables by their Index in the emotionMixer
        // 3. Main animations are not connected directly: Instead another MixerPlayable (mainMixer) is connected.
        //    The main playable is copied and both the original and copy are connected to the new MainMixer.
        //    This is to allow for smoothly looping main animations
        playablesDict = new Dictionary <string, int>();      // String: "Name"+"Index of Emotion Variation"; Int: Index in mixerEmotionPlayable
        int playablesCount     = 0;
        int tempPlayablesCount = 0;

        for (int i = 0; i < emotionObjects.Count; i++)
        {
            tempPlayablesCount = playablesCount;
            for (int j = 0; j < emotionObjects[i].animationGroupList.Count; j++)
            {
                if (emotionObjects[i].animationGroupList[j].main)
                {
                    playablesDict.Add(emotionObjects[i].name + j, playablesCount);
                    AnimationMixerPlayable mainMixer = AnimationMixerPlayable.Create(playableGraph, 2);
                    //var mainMixerBehaviour = ScriptPlayable<IFAMainMixerBehaviour>.Create(playableGraph, 1);                                    // Throwing a behaviour controller between emotionMixer and mainMixer
                    //mainMixerBehaviour.GetBehaviour().constructor2(mainMixer, mainLoopTriggerTime, mainMixerMainIndex, mainMixerCopyIndex);     // To automize looping of the main clip
                    //playableGraph.Connect(mainMixerBehaviour, 0, mixerEmotionPlayable, playablesCount);
                    playableGraph.Connect(mainMixer, 0, mixerEmotionPlayable, playablesCount);
                    playablesCount++;

                    AnimationClipPlayable main = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].main);
                    playableGraph.Connect(main, 0, mainMixer, mainMixerMainIndex);
                    mainMixer.SetInputWeight(mainMixerMainIndex, 1.0f);  // Set first clip to active
                    main.SetDuration(emotionObjects[i].animationGroupList[j].main.length);

                    AnimationClipPlayable mainCopy = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].main);
                    playableGraph.Connect(mainCopy, 0, mainMixer, mainMixerCopyIndex);
                    mainMixer.SetInputWeight(mainMixerCopyIndex, 0.1f);  // Set second clip to inactive
                    mainCopy.SetDuration(emotionObjects[i].animationGroupList[j].main.length);
                }

                if (emotionObjects[i].animationGroupList[j].transitionIn)
                {
                    playablesDict.Add(emotionObjects[i].name + "TransitionIn" + j, playablesCount);
                    AnimationClipPlayable transition = AnimationClipPlayable.Create(playableGraph, emotionObjects[i].animationGroupList[j].transitionIn);
                    playableGraph.Connect(transition, 0, mixerEmotionPlayable, playablesCount);

                    transition.SetDuration(emotionObjects[i].animationGroupList[j].transitionIn.length);
                    playablesCount++;
                }
            }

            // If an emotion has any animationClips, it can be transitioned to
            if (tempPlayablesCount < playablesCount)
            {
                goToEmotionList.Add(new GoToEmotionEntry(emotionObjects[i].name, false, i));
            }
        }

        // Unrelated to Playables; For Display Purposes
        if (GOWithDrawGraphOnImage)
        {
            drawGraphOnImage = GOWithDrawGraphOnImage.GetComponent <DrawGraphOnImage>();
        }
    }
コード例 #14
0
        public BlendedAnimationLayer(PlayableGraph PlayableGraph, AnimationLayerMixerPlayable parentAnimationLayerMixerPlayable,
                                     int layerId, BlendedAnimationInput BlendedAnimationInput, Func <float> InputWeightProvider) : base(layerId, parentAnimationLayerMixerPlayable)
        {
            this.BlendedAnimationInput = BlendedAnimationInput;
            this.BlendedAnimationClips = BlendedAnimationInput.BlendedAnimationClips.ConvertAll(i => i.ToBlendedAnimationClip());

            //create a playable mixer
            this.AnimationMixerPlayable = AnimationMixerPlayable.Create(PlayableGraph);

            foreach (var blendedAnimationClip in  this.BlendedAnimationClips)
            {
                var animationClipPlayable = AnimationClipPlayable.Create(PlayableGraph, blendedAnimationClip.AnimationClip);
                animationClipPlayable.SetApplyFootIK(false);
                animationClipPlayable.SetApplyPlayableIK(false);
                blendedAnimationClip.InputHandler = PlayableExtensions.AddInput(this.AnimationMixerPlayable, animationClipPlayable, 0);
                PlayableExtensions.Play(animationClipPlayable);
                blendedAnimationClip.AnimationClipPlayable = animationClipPlayable;
            }

            //calculate blendings
            for (var i = 0; i < this.BlendedAnimationClips.Count; i++)
            {
                if (i == 0)
                {
                    this.BlendedAnimationClips[i].Blending = this.BlendedAnimationClips[i].Blending.SetWeightTimePoints(
                        AnimationWeightStartIncreasingTime: 0f,
                        AnimationWeightEndIncreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightStartDecreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightEndDecreasingTime:  this.BlendedAnimationClips[i + 1].WeightTime
                        );
                }
                else if (i == this.BlendedAnimationClips.Count - 1)
                {
                    this.BlendedAnimationClips[i].Blending = this.BlendedAnimationClips[i].Blending.SetWeightTimePoints(
                        AnimationWeightStartIncreasingTime:  this.BlendedAnimationClips[i - 1].WeightTime,
                        AnimationWeightEndIncreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightStartDecreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightEndDecreasingTime: 1f
                        );
                }
                else
                {
                    this.BlendedAnimationClips[i].Blending = this.BlendedAnimationClips[i].Blending.SetWeightTimePoints(
                        AnimationWeightStartIncreasingTime:  this.BlendedAnimationClips[i - 1].WeightTime,
                        AnimationWeightEndIncreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightStartDecreasingTime:  this.BlendedAnimationClips[i].WeightTime,
                        AnimationWeightEndDecreasingTime:  this.BlendedAnimationClips[i + 1].WeightTime
                        );
                }
            }

            this.Inputhandler = PlayableExtensions.AddInput(parentAnimationLayerMixerPlayable, this.AnimationMixerPlayable, 0);
            parentAnimationLayerMixerPlayable.SetLayerAdditive((uint)layerId, BlendedAnimationInput.IsAdditive);
            if (BlendedAnimationInput.AvatarMask != null)
            {
                parentAnimationLayerMixerPlayable.SetLayerMaskFromAvatarMask((uint)layerId, BlendedAnimationInput.AvatarMask);
            }

            if (InputWeightProvider != null)
            {
                this.inputWeightProvider = InputWeightProvider;
            }
        }
コード例 #15
0
 public void SetLayerAvatarMask(uint layerIndex, AvatarMask mask)
 {
     layerMixer.SetLayerMaskFromAvatarMask(layerIndex, mask);
 }