Example #1
0
 public void Apply(OCIChar _char)
 {
     _char.LoadAnime(this.group, this.category, this.no, this.normalizedTime);
     for (int index = 0; index < this.activeIK.Length; ++index)
     {
         _char.ActiveIK((OIBoneInfo.BoneGroup)(1 << index), this.activeIK[index], false);
     }
     _char.ActiveKinematicMode(OICharInfo.KinematicMode.IK, this.enableIK, true);
     foreach (KeyValuePair <int, ChangeAmount> keyValuePair in this.dicIK)
     {
         _char.oiCharInfo.ikTarget[keyValuePair.Key].changeAmount.Copy(keyValuePair.Value, true, true, true);
     }
     for (int index = 0; index < this.activeFK.Length; ++index)
     {
         _char.ActiveFK(FKCtrl.parts[index], this.activeFK[index], false);
     }
     _char.ActiveKinematicMode(OICharInfo.KinematicMode.FK, this.enableFK, true);
     foreach (KeyValuePair <int, ChangeAmount> keyValuePair in this.dicFK)
     {
         _char.oiCharInfo.bones[keyValuePair.Key].changeAmount.Copy(keyValuePair.Value, true, true, true);
     }
     for (int _category = 0; _category < this.expression.Length; ++_category)
     {
         _char.EnableExpressionCategory(_category, this.expression[_category]);
     }
 }
Example #2
0
        /// <summary>
        /// Enable simultaneous kinematics for the specified OCIChar
        /// </summary>
        public static void EnableFKIK(OCIChar ociChar)
        {
            //Store the original neck look pattern
            var origPtn = ociChar.neckLookCtrl.ptnNo;

            ociChar.oiCharInfo.enableIK = true;
            ociChar.ActiveIK(BoneGroup.Body, ociChar.oiCharInfo.activeIK[0], true);
            ociChar.ActiveIK(BoneGroup.RightLeg, ociChar.oiCharInfo.activeIK[1], true);
            ociChar.ActiveIK(BoneGroup.LeftLeg, ociChar.oiCharInfo.activeIK[2], true);
            ociChar.ActiveIK(BoneGroup.RightArm, ociChar.oiCharInfo.activeIK[3], true);
            ociChar.ActiveIK(BoneGroup.LeftArm, ociChar.oiCharInfo.activeIK[4], true);
            ociChar.ActiveKinematicMode(OICharInfo.KinematicMode.IK, true, true);

            ociChar.oiCharInfo.activeFK[3] = false;
            ociChar.fkCtrl.enabled         = true;
            ociChar.oiCharInfo.enableFK    = true;

            for (int j = 0; j < FKCtrl.parts.Length; j++)
            {
                ociChar.ActiveFK(FKCtrl.parts[j], ociChar.oiCharInfo.activeFK[j], true);
            }

            //Restore the original neck look pattern which will have been overwritten
            if (origPtn != ociChar.neckLookCtrl.ptnNo)
            {
                ociChar.ChangeLookNeckPtn(origPtn);
            }
        }
Example #3
0
 public static bool ApplyPrefix(OCIChar _char, PauseCtrl.FileInfo __instance)
 {
     _char.LoadAnime(__instance.group, __instance.category, __instance.no, __instance.normalizedTime);
     for (int i = 0; i < __instance.activeIK.Length; i++)
     {
         _char.ActiveIK((OIBoneInfo.BoneGroup)(1 << i), __instance.activeIK[i], false);
     }
     _char.ActiveKinematicMode(OICharInfo.KinematicMode.IK, __instance.enableIK, true);
     foreach (KeyValuePair <int, ChangeAmount> keyValuePair in __instance.dicIK)
     {
         _char.oiCharInfo.ikTarget[keyValuePair.Key].changeAmount.Copy(keyValuePair.Value, true, true, true);
     }
     for (int j = 0; j < __instance.activeFK.Length; j++)
     {
         _char.ActiveFK(FKCtrl.parts[j], __instance.activeFK[j], false);
     }
     _char.ActiveKinematicMode(OICharInfo.KinematicMode.FK, __instance.enableFK, true);
     foreach (KeyValuePair <int, ChangeAmount> keyValuePair2 in __instance.dicFK)
     {
         _char.oiCharInfo.bones.TryGetValue(keyValuePair2.Key, out OIBoneInfo value);
         value?.changeAmount.Copy(keyValuePair2.Value, true, true, true);
     }
     for (int k = 0; k < __instance.expression.Length; k++)
     {
         _char.EnableExpressionCategory(k, __instance.expression[k]);
     }
     return(false);
 }
        public static void ActivateFKIK(OCIChar ociChar)
        {
            HashSet <string> fkikBodyBone;

            if (ociChar.charInfo.sex == 0)
            {
                fkikBodyBone = FKIKBodyBone_Male;
            }
            else
            {
                fkikBodyBone = FKIKBodyBone_Female;
            }

            ociChar.ActiveKinematicMode((OICharInfo.KinematicMode) 2, true, true);
            ociChar.fkCtrl.enabled      = true;
            ociChar.oiCharInfo.enableFK = true;
            //Func<OCIChar.BoneInfo, bool> thing = null;
            for (int i = 0; i < ociChar.oiCharInfo.activeFK.Length; i++)
            {
                if (ociChar.oiCharInfo.activeFK[i])
                {
                    var boneGroup = FKCtrl.parts[i];
                    //if(boneGroup == (OIBoneInfo.BoneGroup)1)
                    //{
                    //    IEnumerable<OCIChar.BoneInfo> listBones = ociChar.listBones;
                    //    Func<OCIChar.BoneInfo, bool> predicate;
                    //    if((predicate = thing) == null)
                    //    {
                    //        predicate = (thing = ((OCIChar.BoneInfo b) => fkikBodyBone.Contains(b.guideObject.transformTarget.name)));
                    //    }
                    //    foreach(OCIChar.BoneInfo boneInfo in listBones.Where(predicate))
                    //    {
                    //        boneInfo.active = true;
                    //    }

                    //    IEnumerator enumerator2 = (f_listBones.GetValue(ociChar.fkCtrl) as IEnumerable).GetEnumerator();
                    //    while(enumerator2.MoveNext())
                    //    {
                    //        object obj = enumerator2.Current;
                    //        GameObject gameObject = FKIKAssistMgr.f_gameObject.GetValue(obj) as GameObject;
                    //        if(gameObject != null && fkikBodyBone.Contains(gameObject.name))
                    //        {
                    //            FKIKAssistMgr.f_enable.SetValue(obj, true);
                    //        }
                    //    }
                    //    goto IL_168;
                    //}
                    ociChar.fkCtrl.SetEnable(boneGroup, true);
                    ociChar.ActiveFK(boneGroup, true, true);
                }
                //IL_168:;
            }
        }
Example #5
0
        /// <summary>
        /// Enable simultaneous kinematics for the specified OCIChar
        /// </summary>
        public static void EnableFKIK(OCIChar ociChar)
        {
            ociChar.oiCharInfo.enableIK = true;
            ociChar.ActiveIK(BoneGroup.Body, ociChar.oiCharInfo.activeIK[0], true);
            ociChar.ActiveIK(BoneGroup.RightLeg, ociChar.oiCharInfo.activeIK[1], true);
            ociChar.ActiveIK(BoneGroup.LeftLeg, ociChar.oiCharInfo.activeIK[2], true);
            ociChar.ActiveIK(BoneGroup.RightArm, ociChar.oiCharInfo.activeIK[3], true);
            ociChar.ActiveIK(BoneGroup.LeftArm, ociChar.oiCharInfo.activeIK[4], true);
            ociChar.ActiveKinematicMode(OICharInfo.KinematicMode.IK, true, true);

            ociChar.oiCharInfo.activeFK[3] = false;
            ociChar.fkCtrl.enabled         = true;
            ociChar.oiCharInfo.enableFK    = true;

            for (int j = 0; j < FKCtrl.parts.Length; j++)
            {
                ociChar.ActiveFK(FKCtrl.parts[j], ociChar.oiCharInfo.activeFK[j], true);
            }
        }
Example #6
0
            internal static bool Apply(PauseCtrl.FileInfo __instance, OCIChar _char)
            {
                //AI and KK pose files are apparently indistinguishable from each other
                //If the user is holding ctrl while loading the pose correct the right hand FK
                bool correctHand = false;

                if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                {
                    correctHand = true;
                }

                //326 is a bone that exists in HS but not KK, check that to see if this is a loaded HS pose
                bool HSPose = __instance.dicFK.Keys.Any(x => x == 326);

#if KK
                //Honey Select poses always need the right hand corrected in KK
                if (HSPose)
                {
                    correctHand = true;
                }
#endif

                if (!HSPose && !correctHand)
                {
                    return(true);
                }

                #region Vanilla Code
                _char.LoadAnime(__instance.group, __instance.category, __instance.no, __instance.normalizedTime);

                for (int i = 0; i < __instance.activeIK.Length; i++)
                {
                    _char.ActiveIK((OIBoneInfo.BoneGroup)(1 << i), __instance.activeIK[i]);
                }
                _char.ActiveKinematicMode(OICharInfo.KinematicMode.IK, __instance.enableIK, _force: true);
                foreach (KeyValuePair <int, ChangeAmount> item in __instance.dicIK)
                {
                    _char.oiCharInfo.ikTarget[item.Key].changeAmount.Copy(item.Value);
                }

                for (int j = 0; j < __instance.activeFK.Length; j++)
                {
                    _char.ActiveFK(FKCtrl.parts[j], __instance.activeFK[j]);
                }
                _char.ActiveKinematicMode(OICharInfo.KinematicMode.FK, __instance.enableFK, _force: true);
                #endregion

                foreach (KeyValuePair <int, ChangeAmount> item2 in __instance.dicFK)
                {
                    int key = item2.Key;

                    if (HSPose)
                    {
                        //Breasts translated from HS to KK/AI
                        if (key == 326)
                        {
                            key = 53;
                        }
                        if (key == 327)
                        {
                            key = 54;
                        }
                        if (key == 328)
                        {
                            key = 55;
                        }
                        if (key == 329)
                        {
                            key = 56;
                        }
                        if (key == 330)
                        {
                            key = 57;
                        }

                        if (key == 332)
                        {
                            key = 59;
                        }
                        if (key == 333)
                        {
                            key = 60;
                        }
                        if (key == 334)
                        {
                            key = 61;
                        }
                        if (key == 335)
                        {
                            key = 62;
                        }
                        if (key == 336)
                        {
                            key = 63;
                        }
                    }

                    if (_char.oiCharInfo.bones.TryGetValue(key, out var oIBoneInfo))
                    {
                        if (correctHand)
                        {
                            //Correct the right hand
                            if (key == 22 || key == 25 || key == 28 || key == 31 || key == 34)
                            {
                                item2.Value.rot = new Vector3(-item2.Value.rot.x, 180 + item2.Value.rot.y, 180 - item2.Value.rot.z);
                            }

                            if (key == 23 || key == 26 || key == 29 || key == 32 || key == 35)
                            {
                                item2.Value.rot = new Vector3(item2.Value.rot.x, -item2.Value.rot.y, -item2.Value.rot.z);
                            }

                            if (key == 24 || key == 27 || key == 30 || key == 33 || key == 36)
                            {
                                item2.Value.rot = new Vector3(item2.Value.rot.x, -item2.Value.rot.y, -item2.Value.rot.z);
                            }
                        }

                        oIBoneInfo.changeAmount.Copy(item2.Value);
                    }
                }

                #region Vanilla Code
                for (int k = 0; k < __instance.expression.Length; k++)
                {
                    _char.EnableExpressionCategory(k, __instance.expression[k]);
                }
                #endregion

                return(false);
            }
Example #7
0
        private void ExtendedSave_PoseBeingLoaded(string poseName, PauseCtrl.FileInfo fileInfo, OCIChar ociChar, ExtendedSave.GameNames gameName)
        {
            bool       loadSkirtFK = false;
            PluginData data        = ExtendedSave.GetPoseExtendedDataById(PoseToolsData);

            if (data != null)
            {
                bool sameGame = false;

                //Only load expression data for the game this pose was created on, eye etc. patterns wouldn't match otherwise
#if KK || KKS
                if (gameName == ExtendedSave.GameNames.Koikatsu || gameName == ExtendedSave.GameNames.KoikatsuSunshine)
                {
                    sameGame = true;
                }
#elif AI || HS2
                if (gameName == ExtendedSave.GameNames.AIGirl || gameName == ExtendedSave.GameNames.HoneySelect2)
                {
                    sameGame = true;
                }
#elif PH
                if (gameName == ExtendedSave.GameNames.PlayHome)
                {
                    sameGame = true;
                }
#endif

                //Facial expression
                if (sameGame && ConfigLoadExpression.Value)
                {
#if !PH
                    if (data.data.TryGetValue(EyebrowPatternData, out var eyebrowPatternData))
                    {
                        ociChar.charInfo.ChangeEyebrowPtn((int)eyebrowPatternData);
                    }
#endif
                    if (data.data.TryGetValue(EyesPatternData, out var eyesPatternData))
                    {
                        ociChar.charInfo.ChangeEyesPtn((int)eyesPatternData);
                    }
                    if (data.data.TryGetValue(MouthPatternData, out var mouthPatternData))
                    {
                        ociChar.charInfo.ChangeMouthPtn((int)mouthPatternData);
                    }
                    if (data.data.TryGetValue(EyeOpenData, out var eyeOpenData))
                    {
                        ociChar.ChangeEyesOpen((float)eyeOpenData);
                    }
                    if (data.data.TryGetValue(MouthOpenData, out var mouthOpenData))
                    {
                        ociChar.ChangeMouthOpen((float)mouthOpenData);
                    }
                }

                //Skirt FK
                if (sameGame && ConfigLoadSkirtFK.Value && data.data.TryGetValue(SkirtFKData, out var skirtFKData) && skirtFKData != null)
                {
                    loadSkirtFK = true;
                    Dictionary <int, Vector3> skirtFK = MessagePackSerializer.Deserialize <Dictionary <int, Vector3> >((byte[])skirtFKData);
                    foreach (KeyValuePair <int, Vector3> item in skirtFK)
                    {
                        ociChar.oiCharInfo.bones[item.Key].changeAmount.rot = item.Value;
                    }
                }

                //Joint correction
                if (data.data.TryGetValue(JointCorrectionData, out var jointCorrectionData) && jointCorrectionData != null)
                {
                    bool[] expression = MessagePackSerializer.Deserialize <bool[]>((byte[])jointCorrectionData);
                    //Skip the first 4 since those are handled by vanilla code
                    for (int i = 4; i < expression.Length; i++)
                    {
                        ociChar.EnableExpressionCategory(i, expression[i]);
                    }
                }
            }

            if (!loadSkirtFK)
            {
                //Disable skirt FK if there was none to load since it's worthless to have enabled
                StartCoroutine(DisableSkirtFK(ociChar));
                ociChar.ActiveFK(OIBoneInfo.BoneGroup.Skirt, false);
            }
        }
Example #8
0
        private IEnumerator DisableSkirtFK(OCIChar ociChar)
        {
            yield return(null);

            ociChar.ActiveFK(OIBoneInfo.BoneGroup.Skirt, false);
        }