Exemplo n.º 1
0
        public static void ApplyMouthOffset(int charIndex, FBSCtrlMouth mouthControl)
        {
            if (charIndex >= characterOffsets.Length || mouthOffsets[charIndex] <= 0 || mouthControl == null || mouthControl.FBSTarget.Length == 0)
            {
                return;
            }

            foreach (FBSTargetInfo fbstargetInfo in mouthControl.FBSTarget)
            {
                SkinnedMeshRenderer skinnedMeshRenderer = fbstargetInfo.GetSkinnedMeshRenderer();
                if (skinnedMeshRenderer.name != "o_head")
                {
                    continue;
                }

                var mouthShape = skinnedMeshRenderer.GetBlendShapeWeight(46);
                if (mouthShape <= 0)
                {
                    continue;
                }

                if (mouthOffsets[charIndex] > 0)
                {
                    skinnedMeshRenderer.SetBlendShapeWeight(53, mouthShape * mouthOffsets[charIndex]);
                }
                else
                {
                    skinnedMeshRenderer.SetBlendShapeWeight(46, mouthShape * (mouthOffsets[charIndex] + 1));
                }
            }
        }
Exemplo n.º 2
0
            //[HarmonyPatch(typeof(FBSCtrlMouth), "CalcBlend")]
            //[HarmonyPrefix]
            public static bool NewCalcBlendShape(FBSCtrlMouth __instance)
            {
                var enabled = LipsyncConfig.Instance.enabled;

                if (!enabled.Value)
                {
                    return(true);
                }


                var nowFace  = AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").GetValue(__instance) as Dictionary <int, float>;
                var openness = (float)AccessTools.Field(typeof(FBSCtrlMouth), "openRate").GetValue(__instance);

                if (nowFace is null)
                {
                    return(true);
                }

                int key = __instance.GetHashCode();

                if (LipsyncConfig.Instance.frameStore.TryGetValue(key, out var targetFrame))
                {
                    MapFrame(targetFrame, ref nowFace, ref openness);
                    AccessTools.Field(typeof(FBSCtrlMouth), "openRate").SetValue(__instance, openness);
                    AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").SetValue(__instance, nowFace);
                    return(true);
                }
                else
                {
                    return(true);
                }
            }