/// <inheritdoc/>
        public void HandlePacket(Player player, Span <byte> packet)
        {
            if (packet.Length < 5)
            {
                return;
            }

            AnimationRequest request = packet;

            var rotation  = request.Rotation.ParseAsDirection();
            var animation = request.AnimationNumber;

            player.Rotation = rotation;

            switch (animation)
            {
            case 0x80:
                player.Pose = CharacterPose.Sitting;
                break;

            case 0x81:
                player.Pose = CharacterPose.Leaning;
                break;

            case 0x82:
                player.Pose = CharacterPose.Hanging;
                break;

            default:
                player.Pose = default;
                break;
            }

            player.ForEachWorldObserver(o => o.ViewPlugIns.GetPlugIn <IShowAnimationPlugIn>()?.ShowAnimation(player, animation, null, rotation), false);
        }
示例#2
0
        private async Task Animate()
        {
            // アニメーション要求の作成
            var request = new AnimationRequest();

            // ベースレイヤーのアニメーション
            request.AddAnimation("AGIA_Idle_angry_01_hands_on_waist", 3.0f);
            //request.AddAnimation("AGIA_Idle_brave_01_hand_on_chest", 3.0f);
            //request.AddAnimation("AGIA_Idle_energetic_01_right_fist_up", 3.0f);

            //// 上半身のアニメーション
            //request.AddAnimation("AGIA_Layer_swinging_body_01", "Upper Body", 2.0f);
            //request.AddAnimation("Default", "Upper Body", 2.0f);
            //request.AddAnimation("AGIA_Layer_look_away_01", "Upper Body", 2.0f);

            // アニメーションの実行
            await chatdoll.ModelController.Animate(request, GetToken());
        }
示例#3
0
        /// <inheritdoc/>
        public void HandlePacket(Player player, Span <byte> packet)
        {
            if (packet.Length < 5)
            {
                return;
            }

            AnimationRequest request = packet;

            var rotation  = request.Rotation.ParseAsDirection();
            var animation = request.AnimationNumber;

            player.Rotation = rotation;

            player.Pose = animation switch
            {
                0x80 => CharacterPose.Sitting,
                0x81 => CharacterPose.Leaning,
                0x82 => CharacterPose.Hanging,
                _ => default
            };

            player.ForEachWorldObserver(o => o.ViewPlugIns.GetPlugIn <IShowAnimationPlugIn>()?.ShowAnimation(player, animation, null, rotation), false);
        }
示例#4
0
 public AnimationRequestStruct(AvatarModel avatarModel, global::AnimationRequest animationRequest, object param = null)
 {
     AnimationRequest = animationRequest;
     AvatarModel      = avatarModel;
     Param            = param;
 }
示例#5
0
        public void TestAnimationRequest()
        {
            var animationRequest = new AnimationRequest();

            Assert.AreEqual(new Dictionary <string, List <Model.Animation> >(), animationRequest.Animations);
            Assert.IsTrue(animationRequest.DisableBlink);
            Assert.IsTrue(animationRequest.StartIdlingOnEnd);
            Assert.IsTrue(animationRequest.StopIdlingOnStart);
            Assert.IsTrue(animationRequest.StopLayeredAnimations);
            Assert.AreEqual(string.Empty, animationRequest.BaseLayerName);

            animationRequest.AddAnimation("Smile");
            animationRequest.AddAnimation("Angry", 2.0f, 1.0f, 0.5f, 0.1f);
            animationRequest.AddAnimation("WaveHands", "UpperBody", 3.0f, 2.0f, 0.8f, 0.2f, "upper animation");

            var animation01 = animationRequest.Animations[string.Empty][0];

            Assert.AreEqual("Smile", animation01.Name);
            Assert.AreEqual(string.Empty, animation01.LayerName);
            Assert.AreEqual(0.0f, animation01.Duration);
            Assert.AreEqual(-1.0f, animation01.FadeLength);
            Assert.AreEqual(1.0f, animation01.Weight);
            Assert.AreEqual(0.0f, animation01.PreGap);
            Assert.IsNull(animation01.Description);
            Assert.AreEqual(0.0f, animation01.Length);

            var animation02 = animationRequest.Animations[string.Empty][1];

            Assert.AreEqual("Angry", animation02.Name);
            Assert.AreEqual(string.Empty, animation02.LayerName);
            Assert.AreEqual(2.0f, animation02.Duration);
            Assert.AreEqual(1.0f, animation02.FadeLength);
            Assert.AreEqual(0.5f, animation02.Weight);
            Assert.AreEqual(0.1f, animation02.PreGap);
            Assert.IsNull(animation02.Description);
            Assert.AreEqual(2.1f, animation02.Length);

            var animation03 = animationRequest.Animations["UpperBody"][0];

            Assert.AreEqual("WaveHands", animation03.Name);
            Assert.AreEqual("UpperBody", animation03.LayerName);
            Assert.AreEqual(3.0f, animation03.Duration);
            Assert.AreEqual(2.0f, animation03.FadeLength);
            Assert.AreEqual(0.8f, animation03.Weight);
            Assert.AreEqual(0.2f, animation03.PreGap);
            Assert.AreEqual("upper animation", animation03.Description);
            Assert.AreEqual(3.2f, animation03.Length);

            Assert.AreEqual(2, animationRequest.BaseLayerAnimations.Count);
            Assert.AreEqual("Smile", animationRequest.BaseLayerAnimations[0].Name);
            Assert.AreEqual("Angry", animationRequest.BaseLayerAnimations[1].Name);

            // With params
            var animations = new Dictionary <string, List <Model.Animation> >()
            {
                {
                    string.Empty, new List <Model.Animation>()
                    {
                        new Model.Animation("Smile", null, 0.1f, 0.2f, 0.3f, 0.4f, "smile animation"),
                        new Model.Animation("Angry", null, 0.1f, 0.2f, 0.3f, 0.4f, "angry animation")
                    }
                },
                {
                    "UpperBody", new List <Model.Animation>()
                    {
                        new Model.Animation("WaveHands", "UpperBody", 0.1f, 0.2f, 0.3f, 0.4f, "wave animation")
                    }
                }
            };
            var animationRequestP = new AnimationRequest(animations, false, false, false, false, "Base Layer");

            Assert.AreEqual(2, animationRequestP.Animations.Count);
            Assert.AreEqual(2, animationRequestP.Animations[string.Empty].Count);   // not "Base Layer"
            Assert.AreEqual(1, animationRequestP.Animations["UpperBody"].Count);
            Assert.AreEqual(2, animationRequestP.BaseLayerAnimations.Count);
            Assert.IsFalse(animationRequestP.DisableBlink);
            Assert.IsFalse(animationRequestP.StartIdlingOnEnd);
            Assert.IsFalse(animationRequestP.StopIdlingOnStart);
            Assert.IsFalse(animationRequestP.StopLayeredAnimations);
            Assert.AreEqual("Base Layer", animationRequestP.BaseLayerName);

            // Others
            var animationRequestO1 = new AnimationRequest(baseLayerName: "Base Layer");

            animationRequestO1.AddAnimation("Smile");
            Assert.AreEqual(1, animationRequestO1.Animations["Base Layer"].Count);  // "Base Layer" when added after instancing

            var animationRequestO2 = new AnimationRequest();

            Assert.AreEqual(string.Empty, animationRequestO2.BaseLayerName);
            animationRequestO2.AddAnimation("Smile", "Dummy Layer");
            Assert.AreEqual("Dummy Layer", animationRequestO2.BaseLayerName);
        }