コード例 #1
0
        /// <summary>
        /// クラスに含まれる処理を適用します。
        /// </summary>
        /// <param name="avatar"></param>
        /// <param name="enableAutoEyeMovement">オートアイムーブメントを有効化するなら<c>true</c>、無効化するなら<c>false</c>。</param>
        /// <param name="addedShouldersPositionY">VRChat上でモデルがなで肩・いかり肩になる問題について、Shoulder/UpperArmボーンのPositionのYに加算する値。</param>
        /// <param name="addedArmaturePositionY"></param>
        /// <param name="moveEyeBoneToFrontForEyeMovement"></param>
        /// <param name="forQuest"></param>
        /// <returns>変換中に発生したメッセージ。</returns>
        internal static IEnumerable <(string, MessageType)> Apply(
            GameObject avatar,
            bool enableAutoEyeMovement,
            float addedShouldersPositionY,
            float addedArmaturePositionY,
            float moveEyeBoneToFrontForEyeMovement,
            bool forQuest
            )
        {
            var messages = new List <(string, MessageType)>();

            VRChatsBugsWorkaround.EnableAnimationOvrride(avatar: avatar);
            if (VRChatUtility.SDKVersion == 2)
            {
                if (enableAutoEyeMovement)
                {
                    if (!VRChatsBugsWorkaround.ApplyAutoEyeMovementDegreeMapping(avatar: avatar))
                    {
                        moveEyeBoneToFrontForEyeMovement = 0.0f;
                    }
                }
                else
                {
                    VRChatsBugsWorkaround.DisableAutoEyeMovement(avatar: avatar);
                    moveEyeBoneToFrontForEyeMovement = 0.0f;
                }
            }
            else
            {
                moveEyeBoneToFrontForEyeMovement = 0.0f;
            }
            VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ(
                avatar: avatar,
                addedValueToArmature: addedArmaturePositionY,
                addedValueToShoulders: addedShouldersPositionY,
                addedValueToEyes: moveEyeBoneToFrontForEyeMovement
                );
            if (VRChatUtility.SDKVersion == 2)
            {
                if (enableAutoEyeMovement || forQuest)
                {
                    // VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ() より後に実行しないと
                    // 同メソッド内部で使用しているUniVRMが、同名ボーンのエラーを出す場合がある
                    VRChatsBugsWorkaround.EnableAutoEyeMovement(avatar: avatar);
                }
            }
            messages.AddRange(VRChatsBugsWorkaround.EnableTextureMipmapStreaming(avatar: avatar));

            return(messages);
        }
コード例 #2
0
        /// <summary>
        /// クラスに含まれる処理を適用します。
        /// </summary>
        /// <param name="avatar"></param>
        /// <param name="enableAutoEyeMovement">オートアイムーブメントを有効化するなら<c>true</c>、無効化するなら<c>false</c>。</param>
        /// <param name="addedShouldersPositionY">VRChat上でモデルがなで肩・いかり肩になる問題について、Shoulder/UpperArmボーンのPositionのYに加算する値。</param>
        /// <param name="addedArmaturePositionY"></param>
        /// <param name="moveEyeBoneToFrontForEyeMovement"></param>
        /// <param name="forQuest"></param>
        /// <returns>変換中に発生したメッセージ。</returns>
        internal static IEnumerable <Converter.Message> Apply(
            GameObject avatar,
            bool enableAutoEyeMovement,
            float addedShouldersPositionY,
            float addedArmaturePositionY,
            float moveEyeBoneToFrontForEyeMovement,
            bool forQuest
            )
        {
            var messages = new List <Converter.Message>();

            VRChatsBugsWorkaround.EnableAnimationOvrride(avatar: avatar);
#if VRC_SDK_VRCSDK2
            if (enableAutoEyeMovement)
            {
                VRChatsBugsWorkaround.SetEyeBonesForCecilHenShin(avatar: avatar);
            }
            if (enableAutoEyeMovement)
            {
                if (!VRChatsBugsWorkaround.ApplyAutoEyeMovementDegreeMapping(avatar: avatar))
                {
                    moveEyeBoneToFrontForEyeMovement = 0.0f;
                }
            }
            else
            {
                VRChatsBugsWorkaround.DisableAutoEyeMovement(avatar: avatar);
                moveEyeBoneToFrontForEyeMovement = 0.0f;
            }
#else
            moveEyeBoneToFrontForEyeMovement = 0.0f;
#endif
            VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ(
                avatar: avatar,
                addedValueToArmature: addedArmaturePositionY,
                addedValueToShoulders: addedShouldersPositionY,
                addedValueToEyes: moveEyeBoneToFrontForEyeMovement
                );
#if VRC_SDK_VRCSDK2
            if (enableAutoEyeMovement || forQuest)
            {
                // VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ() より後に実行しないと
                // 同メソッド内部で使用しているUniVRMが、同名ボーンのエラーを出す場合がある
                VRChatsBugsWorkaround.EnableAutoEyeMovement(avatar: avatar);
            }
#endif
            messages.AddRange(VRChatsBugsWorkaround.EnableTextureMipmapStreaming(avatar: avatar));

            return(messages);
        }
コード例 #3
0
        /// <summary>
        /// <see cref="HumanBodyBones.UpperChest"/>が存在する場合、それを<see cref="HumanBodyBones.Chest"/>とし、元の<see cref="HumanBodyBones.Chest"/>の関連付けを外します。
        /// </summary>
        /// <param name="avatar"></param>
        private static void RemoveUpperChest(GameObject avatar)
        {
            var avatarDescription = avatar.GetComponent <VRMHumanoidDescription>().Description;

            var boneLimits = avatarDescription.human.ToList();
            var upperChest = boneLimits.FirstOrDefault(boneLimit => boneLimit.humanBone == HumanBodyBones.UpperChest);

            if (string.IsNullOrEmpty(upperChest.boneName))
            {
                return;
            }

            boneLimits.Remove(boneLimits.First(boneLimit => boneLimit.humanBone == HumanBodyBones.Chest));

            upperChest.humanBone = HumanBodyBones.Chest;
            boneLimits[boneLimits.FindIndex(boneLimit => boneLimit.humanBone == HumanBodyBones.UpperChest)] = upperChest;

            avatarDescription.human = boneLimits.ToArray();
            VRChatsBugsWorkaround.ApplyAvatarDescription(avatar);
        }
コード例 #4
0
        /// <summary>
        /// クラスに含まれる処理を適用します。
        /// </summary>
        /// <param name="avatar"></param>
        /// <param name="keepingUpperChest"></param>
        /// <param name="addedShouldersPositionY">VRChat上でモデルがなで肩・いかり肩になる問題について、Shoulder/UpperArmボーンのPositionのYに加算する値。</param>
        /// <param name="addedArmaturePositionY"></param>
        /// <returns>変換中に発生したメッセージ。</returns>
        internal static IEnumerable <(string, MessageType)> Apply(
            GameObject avatar,
            bool keepingUpperChest,
            float addedShouldersPositionY,
            float addedArmaturePositionY
            )
        {
            var messages = new List <(string, MessageType)>();

            VRChatsBugsWorkaround.EnableAnimationOvrride(avatar: avatar);
            if (!keepingUpperChest)
            {
                VRChatsBugsWorkaround.RemoveUpperChest(avatar);
            }
            VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ(
                avatar: avatar,
                addedValueToArmature: addedArmaturePositionY,
                addedValueToShoulders: addedShouldersPositionY
                );
            messages.AddRange(VRChatsBugsWorkaround.EnableTextureMipmapStreaming(avatar: avatar));

            return(messages);
        }