Exemplo n.º 1
0
        public void CanSetDestinationRigDefinition()
        {
            var channels = new IAnimationChannel[]
            {
                new LocalTranslationChannel {
                    Id = "Root", DefaultValue = float3.zero
                },
                new LocalTranslationChannel {
                    Id = "Child1", DefaultValue = float3.zero
                },
                new LocalTranslationChannel {
                    Id = "Child2", DefaultValue = float3.zero
                },
            };

            var rig = new Rig {
                Value = RigBuilder.CreateRigDefinition(channels)
            };

            var rigRemapper = CreateNode <RigRemapperNode>();

            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.DestinationRig, rig);

            var otherRig = Set.GetDefinition(rigRemapper).ExposeKernelData(rigRemapper).DestinationRigDefinition;

            Assert.That(otherRig.Value.GetHashCode(), Is.EqualTo(rig.Value.Value.GetHashCode()));
        }
Exemplo n.º 2
0
    public Quaternion GetLastRotationForChannel(string channelName)
    {
        Quaternion previousRotation = Quaternion.identity;

        if (this.previousClip != null)
        {
            IAnimationChannel previousChannel = this.previousClip.GetAnimationChannel(channelName);

            if (previousChannel != null && previousChannel is RotationChannel)
            {
                RotationChannel previousRotationChannel = previousChannel as RotationChannel;
                previousRotation = previousRotationChannel.GetPreviousRotation();
            }
        }
        else
        {
            //If we dont have a previous clip to extract a rotation from we use the initial transform for this channel.
            if (this.animationTransforms.ContainsKey(channelName))
            {
                BoneTransform boneTransform = this.animationTransforms[channelName] as BoneTransform;
                previousRotation = boneTransform.GetInitialRotation();
            }
        }

        return(previousRotation);
    }
        public void CannotCreateRigSkeletonWithMoreThanOneRoot()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
            };

            var skeletonNodes = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 0
                },
                new SkeletonNode {
                    ParentIndex = -1
                },
            };

            Assert.Throws <ArgumentException>(() => RigBuilder.CreateRigDefinition(skeletonNodes, null, animationChannel));
        }
Exemplo n.º 4
0
        static BlobAssetReference <RigDefinition> CreateTestRigDefinition()
        {
            var skeletonNodes = new[]
            {
                new SkeletonNode {
                    ParentIndex = -1, Id = "Root", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 0, Id = "Child1", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 0, Id = "Child2", AxisIndex = -1
                }
            };

            var customChannels = new IAnimationChannel[]
            {
                new FloatChannel {
                    Id = "myFloat", DefaultValue = k_DefaultFloatValue
                },
                new IntChannel {
                    Id = "myInt", DefaultValue = k_DefaultIntValue
                }
            };

            return(RigBuilder.CreateRigDefinition(skeletonNodes, null, customChannels));
        }
        private static BlobAssetReference <RigDefinition> CreateTestRigDefinition()
        {
            var skeletonNodes = new[]
            {
                new SkeletonNode {
                    ParentIndex = -1, Id = "Root", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 0, Id = "Child1", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 1, Id = "Child2", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 2, Id = "Child3", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 3, Id = "Child4", AxisIndex = -1
                },
            };

            var channels = new IAnimationChannel[]
            {
                new FloatChannel {
                    Id = "IKWeight", DefaultValue = 0.0f
                },
                new IntChannel {
                    Id = "Type", DefaultValue = 10
                }
            };

            return(RigBuilder.CreateRigDefinition(skeletonNodes, null, channels));
        }
Exemplo n.º 6
0
    public void UpdateAnimation(PhonemeBuffer.InternalBuffer frontBuffer)
    {
        if (!this.hasStartedStreaming)
        {
            this.hasStartedStreaming = true;
            this.startupTime         = Time.realtimeSinceStartup;
        }

        //Keep track of time when animation data comes in, this allows us to track what frame we should be on.
        this.timeSinceStart = Time.realtimeSinceStartup - this.startupTime;

        float mergeBufferLength;
        List <PhonemeContainer> mergeBuffer = CreateMergeBuffer(frontBuffer, out mergeBufferLength);

        //Determine how much of the mergebuffer to keep after calculating animation.
        float offsetStream = mergeBufferLength - frontBuffer.GetBufferLength();

        this.lipSyncer.StreamedTextToSpeech(mergeBuffer, offsetStream);

        //Only triggered once on the first callback.
        if (!this.hasBegunAnimating)
        {
            this.animationTarget.PlayFacialAnimation(this.streamedAnimationClip, true, 0.5f, 0f);
            this.hasBegunAnimating = true;
        }

        #if UNITY_EDITOR && DEBUG_MODE
        for (int i = 0; i < this.streamedLipsyncChannels.Count; i++)
        {
            IAnimationChannel channel = this.streamedLipsyncChannels[i];
            channel.UpdateDebugWindow();
        }
        #endif
    }
        public void CannotCreateRigSkeletonWhenAxisIndexIsValidAndAxisIsNull()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
            };

            var skeletonNodes = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = 0
                },
                new SkeletonNode {
                    ParentIndex = 0, AxisIndex = 1
                },
                new SkeletonNode {
                    ParentIndex = 1, AxisIndex = 2
                },
            };

            Assert.Throws <ArgumentNullException>(() => RigBuilder.CreateRigDefinition(skeletonNodes, null, animationChannel));
        }
        private static BlobAssetReference <RigDefinition> CreateTestRigDefinition()
        {
            var skeletonNodes = new[]
            {
                new SkeletonNode {
                    ParentIndex = -1, Id = "Root", AxisIndex = -1
                },
                new SkeletonNode {
                    ParentIndex = 0, Id = "Child1", AxisIndex = -1
                },
            };

            var animationChannel = new IAnimationChannel[] {
                new FloatChannel {
                    Id = "Root", DefaultValue = 1000.0f
                },
                new FloatChannel {
                    Id = "Child1", DefaultValue = 1000.0f
                },
                new IntChannel {
                    Id = "Root", DefaultValue = 1000
                },
                new IntChannel {
                    Id = "Child1", DefaultValue = 1000
                },
            };

            return(RigBuilder.CreateRigDefinition(skeletonNodes, null, animationChannel));
        }
        private static BlobAssetReference <RigDefinition> CreateTestRigDefinition()
        {
            var skeletonNodes = new[]
            {
                new SkeletonNode {
                    ParentIndex = -1, Id = "Root", AxisIndex = -1, LocalTranslationDefaultValue = new float3(100.0f, 0.0f, 0.0f), LocalRotationDefaultValue = quaternion.RotateX(math.radians(90.0f)), LocalScaleDefaultValue = new float3(10.0f, 1.0f, 1.0f)
                },
                new SkeletonNode {
                    ParentIndex = 0, Id = "Child1", AxisIndex = -1, LocalTranslationDefaultValue = new float3(0.0f, 100.0f, 0.0f), LocalRotationDefaultValue = quaternion.RotateY(math.radians(90.0f)), LocalScaleDefaultValue = new float3(1.0f, 1.0f, 10.0f)
                }
            };

            var animationChannel = new IAnimationChannel[] {
                new FloatChannel {
                    Id = "Root", DefaultValue = 10f
                },
                new FloatChannel {
                    Id = "Child1", DefaultValue = 10f
                },
                new IntChannel {
                    Id = "Root", DefaultValue = 20
                },
                new IntChannel {
                    Id = "Child1", DefaultValue = 20
                }
            };

            return(RigBuilder.CreateRigDefinition(skeletonNodes, null, animationChannel));
        }
Exemplo n.º 10
0
    public VoiceRecordingAnimation(FacialAnimationClip clip, FacialAnimation animationTarget, float estimatedSpeakTime, string phonemesPath)
    {
        this.streamedAnimationClip = clip;
        this.animationTarget       = animationTarget;
        this.phonemesPath          = phonemesPath;
        this.lipSyncer             = new LipSyncData();

        //Used to size our animation channels, this way the internal array in the keyframes list should be big enough.
        this.estimatedSpeakFrames = (int)(FacialAnimation.FRAMERATE * estimatedSpeakTime);

        //Create all our streamed lipsync channels.
        this.streamedLipsyncChannels = new List <IAnimationChannel>(7);
        this.streamedLipsyncChannels.Add(new RotationChannel("Mid_Head_Jnt_03", new List <Vector3>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("Corner_In", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("I", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("Lip_LowerUp", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("Lip_LowerDown", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("Lip_UpperUp", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));
        this.streamedLipsyncChannels.Add(new MorphChannel("Lip_UpperDown", new List <float>(50), false, false, true, true, FacialAnimation.FRAMERATE));

        //Add our streamed channels. This will also remove any previous channel with the same name.
        for (int i = 0; i < this.streamedLipsyncChannels.Count; i++)
        {
            IAnimationChannel channel = this.streamedLipsyncChannels[i];
            this.streamedAnimationClip.AddAnimationChannel(channel);
        }

        //Stream data into these animation channels.
        this.lipSyncer.SetLipSyncChannels(this.streamedLipsyncChannels);

        this.hasBegunAnimating   = false;
        this.hasStartedStreaming = false;

        #if UNITY_EDITOR && DEBUG_MODE
        //Close previous instance of window.
        if (visemeVisualizer != null)
        {
            visemeVisualizer.Close();
        }

        EditorApplication.ExecuteMenuItem("Plotagon/VisemeVisualizer");
        visemeVisualizer = EditorWindow.focusedWindow;

        //Allows us to see results in unitys editor window.
        for (int i = 0; i < this.streamedLipsyncChannels.Count; i++)
        {
            IAnimationChannel channel = this.streamedLipsyncChannels[i];
            channel.AddDebugWindow(visemeVisualizer);
        }
        #endif
    }
Exemplo n.º 11
0
    public IAnimationChannel GetAnimationChannel(string channelName)
    {
        for (int i = 0; i < this.animationChannels.Count; i++)
        {
            IAnimationChannel channel = this.animationChannels[i];

            if (string.CompareOrdinal(channel.GetChannelName(), channelName) == 0)
            {
                return(channel);
            }
        }

        return(null);
    }
        public void CannotCreateRigSkeletonWhenAxisIndexIsInvalid()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
            };

            var skeletonNodes = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = 0
                },
                new SkeletonNode {
                    ParentIndex = 0, AxisIndex = 1
                },
                new SkeletonNode {
                    ParentIndex = 1, AxisIndex = 100
                },
            };

            var axis = new Axis[] {
                new Axis(),
                new Axis()
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => RigBuilder.CreateRigDefinition(skeletonNodes, axis, animationChannel));

            skeletonNodes = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = 0
                },
                new SkeletonNode {
                    ParentIndex = 0, AxisIndex = 1
                },
                new SkeletonNode {
                    ParentIndex = 1, AxisIndex = -100
                },
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => RigBuilder.CreateRigDefinition(skeletonNodes, axis, animationChannel));
        }
Exemplo n.º 13
0
    public void BindAllChannels(Dictionary <string, TransformBase> animationTransforms)
    {
        for (int i = 0; i < this.animationChannels.Count; i++)
        {
            IAnimationChannel channel     = this.animationChannels[i];
            string            channelName = channel.GetChannelName();

            //Bind channel to a transform.
            if (animationTransforms.ContainsKey(channelName))
            {
                TransformBase animationTransform = animationTransforms[channelName];

                //Bind channel to animatable transform.
                channel.Bind(animationTransform);
            }
        }
    }
Exemplo n.º 14
0
    public void AddAnimationChannel(IAnimationChannel channel)
    {
        if (this.animationChannels != null)
        {
            //Remove previous entry if there is one.
            RemoveAnimationChannel(channel.GetChannelName());

            //Add channel to our iterator list.
            this.animationChannels.Add(channel);

            //Find the channel that is the longest within this animation clip, that channel determines the clips total length.
            float channelLength = (float)((float)channel.GetLength() / this.framerate);
            if (channelLength > this.maxChannelLength)
            {
                this.maxChannelLength = channelLength;
            }
        }
    }
Exemplo n.º 15
0
    public void RemoveAnimationChannel(string channelName)
    {
        IAnimationChannel channel = null;

        for (int i = 0; i < this.animationChannels.Count; i++)
        {
            if (string.CompareOrdinal(this.animationChannels[i].GetChannelName(), channelName) == 0)
            {
                channel = this.animationChannels[i];
                break;
            }
        }

        if (channel != null)
        {
            this.animationChannels.Remove(channel);
        }
    }
        public void RigDefinitionWithDifferentDataHaveDifferentHashCode()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                }
            };

            var skeletonNodes1 = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = -1, Id = "Root"
                }
            };

            var rig1 = RigBuilder.CreateRigDefinition(skeletonNodes1, null, animationChannel);

            var skeletonNodes2 = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = -1, Id = "Root1"
                }
            };
            var rig2 = RigBuilder.CreateRigDefinition(skeletonNodes2, null, animationChannel);

            Assert.That(rig1.Value.GetHashCode(), Is.Not.EqualTo(rig2.Value.GetHashCode()));
        }
Exemplo n.º 17
0
    public void SetLipSyncChannels(List <IAnimationChannel> animationChannels)
    {
        for (int i = 0; i < animationChannels.Count; i++)
        {
            IAnimationChannel channel     = animationChannels[i];
            string            channelName = channel.GetChannelName();

            switch (channelName)
            {
            case "Mid_Head_Jnt_03":
                jawChannel = channel as RotationChannel;
                break;

            case "Corner_In":
                cornerinChannel = channel as MorphChannel;
                break;

            case "I":
                iChannel = channel as MorphChannel;
                break;

            case "Lip_LowerUp":
                lowerUpChannel = channel as MorphChannel;
                break;

            case "Lip_LowerDown":
                lowerDownChannel = channel as MorphChannel;
                break;

            case "Lip_UpperUp":
                upperUpChannel = channel as MorphChannel;
                break;

            case "Lip_UpperDown":
                upperDownChannel = channel as MorphChannel;
                break;
            }
        }
    }
        public void CanRemoveDuplicateChannelFromRigDefinition()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalTranslationChannel {
                    Id = "Root"
                }
            };

            var skeletonNodes = new SkeletonNode[] {
                new SkeletonNode {
                    ParentIndex = -1, AxisIndex = -1, Id = "Root"
                }
            };

            var rig = RigBuilder.CreateRigDefinition(skeletonNodes, null, animationChannel);

            Assert.That(rig.Value.Bindings.TranslationBindings.Length, Is.EqualTo(1));
            Assert.That(rig.Value.Bindings.RotationBindings.Length, Is.EqualTo(1));
            Assert.That(rig.Value.Bindings.ScaleBindings.Length, Is.EqualTo(1));
        }
        public void CanCreateRigWithoutSkeleton()
        {
            var animationChannel = new IAnimationChannel[] {
                new LocalTranslationChannel {
                    Id = "Root"
                },
                new LocalRotationChannel {
                    Id = "Root"
                },
                new LocalScaleChannel {
                    Id = "Root"
                },
            };

            var rig = RigBuilder.CreateRigDefinition(animationChannel);

            Assert.That(rig.Value.Skeleton.BoneCount, Is.EqualTo(0));
            Assert.That(rig.Value.Bindings.TranslationBindings.Length, Is.EqualTo(1));
            Assert.That(rig.Value.Bindings.RotationBindings.Length, Is.EqualTo(1));
            Assert.That(rig.Value.Bindings.ScaleBindings.Length, Is.EqualTo(1));
            Assert.That(rig.Value.Bindings.FloatBindings.Length, Is.EqualTo(0));
            Assert.That(rig.Value.Bindings.IntBindings.Length, Is.EqualTo(0));
        }
Exemplo n.º 20
0
        public void CanRemapAllIntChannel()
        {
            var sourceChannels = new IAnimationChannel[]
            {
                new IntChannel {
                    Id = "Root", DefaultValue = m_ExpectedSourceInt
                },
                new IntChannel {
                    Id = "Child1", DefaultValue = m_ExpectedSourceInt
                },
                new IntChannel {
                    Id = "Child2", DefaultValue = m_ExpectedSourceInt
                },
            };

            var sourceRig = new Rig {
                Value = RigBuilder.CreateRigDefinition(sourceChannels)
            };

            var destinationChannels = new IAnimationChannel[]
            {
                new IntChannel {
                    Id = "AnotherRoot", DefaultValue = 0
                },
                new IntChannel {
                    Id = "AnotherChild1", DefaultValue = 0
                },
                new IntChannel {
                    Id = "AnotherChild2", DefaultValue = 0
                },
            };
            var destinationRig = new Rig {
                Value = RigBuilder.CreateRigDefinition(destinationChannels)
            };
            var rigEntity = m_Manager.CreateEntity();

            RigEntityBuilder.SetupRigEntity(rigEntity, m_Manager, destinationRig);

            var rigRemapQuery = new RigRemapQuery
            {
                AllChannels = new [] {
                    new ChannelMap {
                        SourceId = "Root", DestinationId = "AnotherRoot"
                    },
                    new ChannelMap {
                        SourceId = "Child1", DestinationId = "AnotherChild1"
                    },
                    new ChannelMap {
                        SourceId = "Child2", DestinationId = "AnotherChild2"
                    }
                }
            };
            var remapTable = rigRemapQuery.ToRigRemapTable(sourceRig, destinationRig);

            // Here I'm using a layerMixer with no inputs connected
            // the expected result is to inject the default pose into Graph samples buffer
            var layerMixer = CreateNode <LayerMixerNode>();

            Set.SendMessage(layerMixer, LayerMixerNode.SimulationPorts.Rig, sourceRig);

            var rigRemapper = CreateNode <RigRemapperNode>();

            Set.Connect(layerMixer, LayerMixerNode.KernelPorts.Output, rigRemapper, RigRemapperNode.KernelPorts.Input);

            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.SourceRig, sourceRig);
            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.DestinationRig, destinationRig);
            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.RemapTable, remapTable);

            var entityNode = CreateComponentNode(rigEntity);

            Set.Connect(rigRemapper, RigRemapperNode.KernelPorts.Output, entityNode);

            m_Manager.AddComponent <PreAnimationGraphTag>(rigEntity);

            m_AnimationGraphSystem.Update();

            var streamECS = AnimationStream.CreateReadOnly(
                destinationRig,
                m_Manager.GetBuffer <AnimatedData>(rigEntity).AsNativeArray()
                );

            Assert.That(streamECS.GetInt(0), Is.EqualTo(m_ExpectedSourceInt), "Channel int 0 doesn't match source rig default value");
            Assert.That(streamECS.GetInt(1), Is.EqualTo(m_ExpectedSourceInt), "Channel int 1 doesn't match source rig default value");
            Assert.That(streamECS.GetInt(2), Is.EqualTo(m_ExpectedSourceInt), "Channel int 2 doesn't match source rig default value");
        }
Exemplo n.º 21
0
        public void CanRemapRigRotationOffset()
        {
            var sourceChannels = new IAnimationChannel[]
            {
                new LocalRotationChannel {
                    Id = "Root", DefaultValue = m_ExpectedSourceRotation
                },
                new LocalRotationChannel {
                    Id = "Child", DefaultValue = m_ExpectedSourceRotation
                },
            };

            var sourceRig = new Rig {
                Value = RigBuilder.CreateRigDefinition(sourceChannels)
            };

            var destinationChannels = new IAnimationChannel[]
            {
                new LocalRotationChannel {
                    Id = "AnotherRoot", DefaultValue = quaternion.identity
                },
                new LocalRotationChannel {
                    Id = "AnotherChild", DefaultValue = quaternion.identity
                },
            };

            var destinationRig = new Rig {
                Value = RigBuilder.CreateRigDefinition(destinationChannels)
            };
            var rigEntity = m_Manager.CreateEntity();

            RigEntityBuilder.SetupRigEntity(rigEntity, m_Manager, destinationRig);

            var rigRemapQuery = new RigRemapQuery
            {
                RotationChannels = new []
                {
                    new ChannelMap {
                        SourceId = "Root", DestinationId = "AnotherRoot"
                    },
                    new ChannelMap {
                        SourceId = "Child", DestinationId = "AnotherChild", OffsetIndex = 1
                    }
                },

                RotationOffsets = new []
                {
                    new RigRotationOffset(),
                    new RigRotationOffset {
                        PreRotation = math.normalize(math.quaternion(1, 2, 3, 4)), PostRotation = math.normalize(math.quaternion(5, 6, 7, 8))
                    }
                }
            };

            var remapTable = rigRemapQuery.ToRigRemapTable(sourceRig, destinationRig);

            // Here I'm using a layerMixer with no inputs connected
            // the expected result is to inject the default pose into Graph samples buffer
            var layerMixer = CreateNode <LayerMixerNode>();

            Set.SendMessage(layerMixer, LayerMixerNode.SimulationPorts.Rig, sourceRig);

            var rigRemapper = CreateNode <RigRemapperNode>();

            Set.Connect(layerMixer, LayerMixerNode.KernelPorts.Output, rigRemapper, RigRemapperNode.KernelPorts.Input);

            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.SourceRig, sourceRig);
            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.DestinationRig, destinationRig);
            Set.SendMessage(rigRemapper, RigRemapperNode.SimulationPorts.RemapTable, remapTable);

            var entityNode = CreateComponentNode(rigEntity);

            Set.Connect(rigRemapper, RigRemapperNode.KernelPorts.Output, entityNode);

            m_Manager.AddComponent <PreAnimationGraphTag>(rigEntity);

            m_AnimationGraphSystem.Update();

            var streamECS = AnimationStream.CreateReadOnly(
                destinationRig,
                m_Manager.GetBuffer <AnimatedData>(rigEntity).AsNativeArray()
                );

            Assert.That(streamECS.GetLocalToParentRotation(1), Is.EqualTo(math.mul(rigRemapQuery.RotationOffsets[1].PreRotation, math.mul(m_ExpectedSourceRotation, rigRemapQuery.RotationOffsets[1].PostRotation))).Using(RotationComparer), "Channel localRotation doesn't match destination rig default value with rig rotation offset");
        }
Exemplo n.º 22
0
 public bool Equals(IAnimationChannel other)
 {
     return(other.GetType() == typeof(IntChannel) && Id.Equals(other.Id));
 }
        protected void OneTimeSetUp()
        {
            var srcSkeletonNodes = new SkeletonNode[]
            {
                new SkeletonNode {
                    Id = "Root", ParentIndex = -1, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "Hips", ParentIndex = 0, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "LeftUpLeg", ParentIndex = 1, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "RightUpLeg", ParentIndex = 1, AxisIndex = -1
                },
            };
            var srcChannels = new IAnimationChannel[]
            {
                new LocalTranslationChannel {
                    Id = "Velocity"
                },
                new LocalRotationChannel {
                    Id = "AngularVelocity"
                },
                new FloatChannel {
                    Id = "Intensity"
                },
                new FloatChannel {
                    Id = "Radius"
                },
                new IntChannel {
                    Id = "Index"
                },
                new IntChannel {
                    Id = "Mode"
                },
            };

            var dstSkeletonNodes = new SkeletonNode[]
            {
                new SkeletonNode {
                    Id = "AnotherRoot", ParentIndex = -1, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "AnotherHips", ParentIndex = 0, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "AnotherLeftUpLeg", ParentIndex = 1, AxisIndex = -1
                },
                new SkeletonNode {
                    Id = "AnotherRightUpLeg", ParentIndex = 1, AxisIndex = -1
                },
            };
            var dstChannels = new IAnimationChannel[]
            {
                new LocalTranslationChannel {
                    Id = "AnotherVelocity"
                },
                new LocalRotationChannel {
                    Id = "AnotherAngularVelocity"
                },
                new FloatChannel {
                    Id = "AnotherIntensity"
                },
                new FloatChannel {
                    Id = "AnotherRadius"
                },
                new IntChannel {
                    Id = "AnotherIndex"
                },
                new IntChannel {
                    Id = "AnotherMode"
                },
            };

            m_SourceRig      = RigBuilder.CreateRigDefinition(srcSkeletonNodes, null, srcChannels);
            m_DestinationRig = RigBuilder.CreateRigDefinition(dstSkeletonNodes, null, dstChannels);
        }