public bool UpdateTex(Maid maid, Material[] slotMaterials, EditTarget texEdit) {
            // material 抽出 => texture 抽出
            if (slotMaterials.Length <=  texEdit.matNo) return false;
            Material mat = slotMaterials[texEdit.matNo];

            return UpdateTex(maid, mat, texEdit);
        }
        public void Update(Maid maid, Dictionary<string, List<Material>> slotMaterials,
            List<Texture2D> textures, EditTarget texEdit ) {

            originalTexCache.Refresh(textures.ToArray());

            FilterTexture(slotMaterials, textures, maid, texEdit);
        }
        /// <summary>
        /// メイドを更新する.
        /// 名前が未指定の場合は、statusのlast_nameとfirst_nameから生成する.
        /// 
        /// </summary>
        /// <param name="maid0">メイド</param>
        /// <param name="name">メイドの名前</param>
        /// <param name="act"></param>
        /// <returns>別のメイドに変更された場合、trueを返す</returns>
        public bool UpdateMaid(Maid maid0, string name, Action act) 
        {
            if (maid0 == null) {
                // メイドリストから最初に有効なメイドを取得
                int count = GameMain.Instance.CharacterMgr.GetMaidCount();
                for (int i=0; i< count; i++) {
                    Maid m = GameMain.Instance.CharacterMgr.GetMaid(i);
                    if (m != null && m.enabled) {
                        maid0 = m;
                        break;
                    }
                }            
            }
            if (currentMaid == maid0) return false;
            currentMaid = maid0;
            if (currentMaid != null) {
                MaidName = name?? currentMaid.Param.status.last_name + " " + currentMaid.Param.status.first_name;

                isOfficial = checkOfficial(currentMaid);
            } else {
                MaidName = "(not selected)";
            }
            LogUtil.Debug("maid changed.", MaidName);

            act();
            return true;
        }
 private void SetClassLevel(Maid maid, string classDataFieldName, int classID, int level)
 {
     FieldInfo classDataField = maid.Param.status_.GetType().GetField(classDataFieldName);
     object classData =
         classDataField.FieldType.GetMethod("GetValue", new[] {typeof(int)})
                       .Invoke(classDataField.GetValue(maid.Param.status_), new[] {(object) classID});
     ((SimpleExperienceSystem) classData.GetType().GetField("exp_system").GetValue(classData)).SetLevel(level);
 }
 public void ProcGUI(Maid maid, string slotName, Material material, string propName, float margin, float fontSize, float itemHeight)
 {
     FilterParam fp = Get(maid, slotName, material, propName);
     if (fp != null)
     {
         fp.ProcGUI(margin, fontSize, itemHeight);
     }
 }
 private void SetClassIsHave(Maid maid, string classDataFieldName, int classID, bool value)
 {
     FieldInfo classDataField = maid.Param.status_.GetType().GetField(classDataFieldName);
     object classData =
         classDataField.FieldType.GetMethod("GetValue", new[] {typeof(int)})
                       .Invoke(classDataField.GetValue(maid.Param.status_), new[] {(object) classID});
     classData.GetType().GetField("is_have").SetValue(classData, value);
 }
Exemplo n.º 7
0
 public static int MaidCompareCreateTime(Maid x, Maid y)
 {
     int result;
     if (x.Param.status.create_time_num < y.Param.status.create_time_num)
         result = -1;
     else
         result = x.Param.status.create_time_num == y.Param.status.create_time_num ? 0 : 1;
     return result;
 }
        public void ProcGUI(Maid maid, string slotName, Material material, string propName) {
            // material 抽出 => texture 抽出
            var tex2d = material.GetTexture(propName) as Texture2D;
            if (tex2d == null || string.IsNullOrEmpty(tex2d.name)) return ;

            var key = CreateKey(maid.Param.status.guid, slotName, material.name, tex2d.name);
            FilterParam fp = filterParams.GetOrAdd(key.ToString());
            fp.ProcGUI(tex2d);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 拡張セーブデータ内の設定を得る(文字列)
 /// <para>指定した設定が存在しない場合はdefaultValueを返す</para>
 /// <seealso cref="GetBool"/>
 /// <seealso cref="GetInt"/>
 /// <seealso cref="GetFloat"/>
 /// </summary>
 /// <param name="maid">メイドインスタンス</param>
 /// <param name="pluginName">プラグイン名("CM3D2.Test.Plugin"など)</param>
 /// <param name="propName">プロパティ名</param>
 /// <param name="defaultValue">プロパティが存在しない場合に返すデフォルト値</param>
 /// <returns>設定文字列</returns>
 public static string Get(Maid maid, string pluginName, string propName, string defaultValue)
 {
     if (maid == null || pluginName == null || propName == null)
     {
         return defaultValue;
     }
     if (!Contains(maid))
     {
         SetMaid(maid);
     }
     return PluginSettings.Get(maid.Param.status.guid, pluginName, propName, defaultValue);
 }
        void LoadCameraSettings(Maid maid)
        {
            if (maid == null || !maid.Visible)
            {
                return;
            }

            bool autoCam = ExSaveData.GetBool(maid, PluginName, "AutoCameraInitialValue", true);
            if (autoCam)
            {
                return;
            }

            float cameraPosX = ExSaveData.GetFloat(maid, PluginName, "CameraPos.x", float.NaN);
            float cameraPosY = ExSaveData.GetFloat(maid, PluginName, "CameraPos.y", float.NaN);
            float cameraPosZ = ExSaveData.GetFloat(maid, PluginName, "CameraPos.z", float.NaN);
            float cameraTargetPosX = ExSaveData.GetFloat(maid, PluginName, "CameraTargetPos.x", float.NaN);
            float cameraTargetPosY = ExSaveData.GetFloat(maid, PluginName, "CameraTargetPos.y", float.NaN);
            float cameraTargetPosZ = ExSaveData.GetFloat(maid, PluginName, "CameraTargetPos.z", float.NaN);
            float cameraDistance = ExSaveData.GetFloat(maid, PluginName, "CameraDistance", float.NaN);
            float cameraRotatationX = ExSaveData.GetFloat(maid, PluginName, "CameraRotation.x", float.NaN);
            float cameraRotatationY = ExSaveData.GetFloat(maid, PluginName, "CameraRotation.y", float.NaN);
            float cameraRotatationZ = ExSaveData.GetFloat(maid, PluginName, "CameraRotation.z", float.NaN);
            float cameraRotatationW = ExSaveData.GetFloat(maid, PluginName, "CameraRotation.w", float.NaN);
            float cameraFov = ExSaveData.GetFloat(maid, PluginName, "CameraFov", float.NaN);

            if (!float.IsNaN(cameraRotatationX) && !float.IsNaN(cameraRotatationY) && !float.IsNaN(cameraRotatationZ) && !float.IsNaN(cameraRotatationW))
            {
                Camera.main.gameObject.transform.rotation = new Quaternion(cameraRotatationX, cameraRotatationY, cameraRotatationZ, cameraRotatationW);
            }

            if (!float.IsNaN(cameraPosX) && !float.IsNaN(cameraPosY) && !float.IsNaN(cameraPosZ))
            {
                mainCamera.SetPos(new Vector3(cameraPosX, cameraPosY, cameraPosZ));
            }

            if (!float.IsNaN(cameraTargetPosX) && !float.IsNaN(cameraTargetPosY) && !float.IsNaN(cameraTargetPosZ))
            {
                mainCamera.SetTargetPos(new Vector3(cameraTargetPosX, cameraTargetPosY, cameraTargetPosZ), true);
            }

            if (!float.IsNaN(cameraDistance))
            {
                mainCamera.SetDistance(cameraDistance, true);
            }
            if (!float.IsNaN(cameraFov))
            {
                Camera.main.fieldOfView = cameraFov;
            }
        }
        public bool UpdateTex(Maid maid, Material mat, EditTarget texEdit) 
        {
            var tex2d = mat.GetTexture(texEdit.propName) as Texture2D;
            if (tex2d == null || string.IsNullOrEmpty(tex2d.name)) return false;

            var key = CreateKey(maid.Param.status.guid, texEdit.slotName, mat.name, tex2d.name);
            FilterParam filterParam = filterParams.GetOrAdd(key.ToString());

            // スライダー変更がなければ何もしない
            if (!filterParam.IsDirty) return false;
            //LogUtil.DebugLogF("Update Texture. slot={0}, material={0}, tex={1}", texEdit.slotName, mat.name, tex2d.name);

            FilterTexture(tex2d, filterParam);
            return true;
        }
        public void Update(
            Maid maid,
            Dictionary<string, List<Material>> slotMaterials,
            List<Texture2D> textures,
            string slotName, int materialIndex, string propName
        )
        {
            originalTextureCache.Refresh(textures.ToArray());

            // マウスボタンが離されたタイミングでフィルターを適用する
            if (Input.GetMouseButtonUp(0))
            {
                FilterTexture(slotMaterials, textures, maid, slotName, materialIndex, propName);
            }
        }
 private string GetKey(Maid maid, string slotName, Material material, string propName)
 {
     if (maid == null || material == null || string.IsNullOrEmpty(propName))
     {
         return null;
     }
     Texture2D tex2d = material.GetTexture(propName) as Texture2D;
     if (tex2d == null || string.IsNullOrEmpty(tex2d.name))
     {
         return null;
     }
     return string.Format("{0}/{1}/{2}/{3}"
                          , maid.Param.status.guid
                          , slotName
                          , material.name
                          , tex2d.name);
 }
Exemplo n.º 14
0
 /// <summary>
 /// KHông thể tin nổi là đóng này được dùng với update
 /// </summary>
 /// <param name="maid"></param>
 public TouchableMaid(Maid maid)
 {
     this._maid = maid;
     try
     {
         this._personal = (Personality)Enum.Parse(typeof(Personality), this._maid.Param.status.personal.ToString());
     }
     catch
     {
         this._personal = Personality.Other;
     }
     this._persistPoseSeconds = -1;
     this._touchTargets.Add(new TouchTarget(this._maid, "target_mune", new Vector3(0.1f, 0.1f, 0.1f), "_IK_muneR", null));
     this._touchTargets.Add(new TouchTarget(this._maid, "target_mune", new Vector3(0.1f, 0.1f, 0.1f), "_IK_muneL", null));
     this._touchTargets.Add(new TouchTarget(this._maid, "target_hip", new Vector3(0.12f, 0.12f, 0.12f), "_IK_hipL", "Hip_L"));
     this._touchTargets.Add(new TouchTarget(this._maid, "target_hip", new Vector3(0.12f, 0.12f, 0.12f), "_IK_hipR", "Hip_R"));
     this._touchTargets.Add(new TouchTarget(this._maid, "target_vagina", new Vector3(0.08f, 0.08f, 0.08f), "Bip01 Pelvis", null));
 }
Exemplo n.º 15
0
 /// <summary>
 /// 拡張セーブデータへ設定を書き込む
 /// <seealso cref="SetBool"/>
 /// <seealso cref="SetInt"/>
 /// <seealso cref="SetFloat"/>
 /// </summary>
 /// <param name="maid">メイドインスタンス</param>
 /// <param name="pluginName">プラグイン名("CM3D2.Test.Plugin"など)</param>
 /// <param name="propName">プロパティ名</param>
 /// <param name="value">書き込む値</param>
 /// <param name="overwrite">trueなら常に上書き。falseなら設定が存在する場合は書き込みを行わない</param>
 /// <returns>true:書き込み成功。false:失敗</returns>
 public static bool Set(Maid maid, string pluginName, string propName, string value, bool overwrite)
 {
     if (maid == null || pluginName == null || propName == null)
     {
         return false;
     }
     if (!Contains(maid))
     {
         SetMaid(maid);
     }
     if (!overwrite)
     {
         if (Contains(maid, pluginName, propName))
         {
             return false;
         }
     }
     return PluginSettings.Set(maid.Param.status.guid, pluginName, propName, value);
 }
Exemplo n.º 16
0
            public MaidInfo(Maid maid, MaidFiddlerGUI gui)
            {
                Debugger.WriteLine("Creating new MaidInfo");
                this.gui = gui;
                forceUpdateNightWorks = new Dictionary<int, bool>();
                Maid = maid;
                ValueLocks = new Dictionary<MaidChangeType, bool>();
                EnumHelper.MaidChangeTypes.ForEach(t => ValueLocks.Add(t, false));
                TempUnlocks = new Dictionary<MaidChangeType, bool>();
                EnumHelper.MaidChangeTypes.ForEach(t => TempUnlocks.Add(t, false));
#if DEBUG
                Debugger.WriteLine(LogLevel.Info, "Loading functions");
                Stopwatch watch = new Stopwatch();
                watch.Start();
#endif
                InitFunctions();
#if DEBUG
                watch.Stop();
                Debugger.WriteLine(
                LogLevel.Info,
                $"Functions loaded. Time taken: {watch.Elapsed.TotalMilliseconds} ms.");
#endif
            }
Exemplo n.º 17
0
        private void SetUnlockMaxAllMaids(object sender, EventArgs e)
        {
            foreach (var maid in loadedMaids)
            {
                MaidInfo  maidInfo    = maid.Value;
                Maid      currentMaid = maid.Key;
                MaidParam maidParam   = currentMaid.Param;
                Debugger.WriteLine(LogLevel.Info,
                                   $"Setting all to max for {currentMaid.Param.status.first_name} {currentMaid.Param.status.last_name}");

                for (int maidClass = 0; maidClass < EnumHelper.MaxMaidClass; maidClass++)
                {
                    SetClassIsHave(currentMaid, "maid_class_data", maidClass, true);
                    SetClassLevel(currentMaid, "maid_class_data", maidClass, 10);
                }
                maidInfo.UpdateMaidClasses();

                foreach (int yotogiClass in EnumHelper.EnabledYotogiClasses)
                {
                    SetClassIsHave(currentMaid, "yotogi_class_data", yotogiClass, true);
                    SetClassLevel(currentMaid, "yotogi_class_data", yotogiClass, 10);
                }
                maidInfo.UpdateYotogiClasses();

                maidParam.SetSexualMouth(1000);
                maidParam.SetSexualCuri(1000);
                maidParam.SetSexualNipple(1000);
                maidParam.SetSexualThroat(1000);

                for (Feature i = Feature.Null + 1; i < EnumHelper.MaxFeature; i++)
                {
                    maidParam.SetFeature(i, true);
                }

                for (Propensity i = Propensity.Null + 1; i < EnumHelper.MaxPropensity; i++)
                {
                    maidParam.SetPropensity(i, true);
                }

                maidParam.SetCare(9999);
                maidParam.SetCharm(9999);
                maidParam.SetElegance(9999);
                maidParam.SetEvaluation(999999L);
                maidParam.SetFrustration(0);
                maidParam.SetHentai(9999);
                maidParam.SetHousi(9999);
                maidParam.SetHp(999);
                maidParam.SetInyoku(9999);
                maidParam.SetLikability(999);
                maidParam.SetLovely(9999);
                maidParam.SetMValue(9999);
                maidParam.SetMaidPoint(999);
                maidParam.SetPlayNumber(9999);
                maidParam.SetMind(9999);
                maidParam.SetReason(9999);
                maidParam.SetReception(9999);
                maidParam.SetPopularRank(99);
                maidParam.SetSales(9999999999L);
                maidParam.SetCurHp(999);
                maidParam.SetCurMind(999);
                maidParam.SetCurReason(999);

                foreach (var noonWork in ScheduleCSVData.NoonWorkData)
                {
                    maidParam.SetNewGetWork(noonWork.Value.id);
                    maidInfo.SetWorkValue(noonWork.Value.id, TABLE_COLUMN_TOTAL_XP, 999U);
                }

                foreach (var dataDic in Yotogi.skill_data_list.SelectMany(s => s))
                {
                    maidParam.SetNewGetSkill(dataDic.Value.id);
                    maidParam.AddSkillExp(dataDic.Value.id, 10000);
                    maidParam.status_.skill_data[dataDic.Value.id].play_count = 1;
                    maidInfo.UpdateSkillData(dataDic.Value.id);
                }

                foreach (var dataDic in Yotogi.skill_data_list.SelectMany(s => s))
                {
                    maidParam.SetNewGetSkill(dataDic.Value.id);
                    maidInfo.UpdateHasSkill(dataDic.Value.id);
                }
            }
        }
 public bool CheckOfficial(Maid maid)
 {
     //LogUtil.Debug("slotCount:", SLOT_COUNT, ", maid. count=", maid.body0.goSlot.Count);
     return(maid.body0.goSlot.Count == _slotCount);
 }
        private void LateUpdate()
        {
            if (danceMain == null)
            {
                return;
            }

            // カメラの表示を適当に広げる よくわからんので毎フレームやっとく
            GameMain.Instance.MainCamera.camera.farClipPlane = xmlManager.farClipPlane;

            if (maidSetting == false)
            {
                if (xmlManager.BackGroundPreset != null)
                {
                    String extent = Path.GetExtension(xmlManager.BackGroundPreset);
                    if (extent.Equals(".preset"))
                    {
                        maid = searchStockMaid("plugin", "backGround");
                        if (maid == null)
                        {
                            maid = GameMain.Instance.CharacterMgr.AddStockMaid();
                            MaidParam m_Param = (MaidParam)fieldMaid.GetValue(maid);
                            m_Param.SetName("plugin", "backGround");
                        }
                        SetPreset(maid, xmlManager.BackGroundPreset);
                    }
                    else
                    {
                        string[] nameList = xmlManager.BackGroundPreset.Split(' ');
                        if (nameList.Length != 2)
                        {
                            Debug.LogError("DanceBg.Plugin:[Maid name Invalid] " + nameList.Length + "#" + xmlManager.BackGroundPreset);
                            maidSetting = true;
                            return;
                        }
                        maid = searchStockMaid(nameList[0], nameList[1]);
                        if (maid == null)
                        {
                            Debug.LogError("DanceBg.Plugin:[Maid not found] #" + nameList[0] + "#" + nameList[1]);
                            maidSetting = true;
                            return;
                        }
                    }
                }
                if (maid != null)
                {
                    //表示済みのめいどさんの位置変更
                    int maidIndex;
//                    for(maidIndex = 1; maidIndex < GameMain.Instance.CharacterMgr.GetMaidCount(); maidIndex++){
                    for (maidIndex = 0; maidIndex < GameMain.Instance.CharacterMgr.GetMaidCount(); maidIndex++)
                    {
                        Maid maidx = GameMain.Instance.CharacterMgr.GetMaid(maidIndex);
                        if (maidx == null)
                        {
                            break;
                        }
//                         if(maidIndex == 0){
//                         maidx.SetRot(maid.GetRot() + new Vector3(0.0f,180.0f,0.0f));
//                         }
//                         else{
                        maidx.SetPos(maidx.gameObject.transform.localPosition + xmlManager.BackGroundPos);
//                         maidx.gameObject.transform.localScale = localscale;
//                         }
                    }
                    // 照明移動は時々?動く ここで初期位置設定
                    // ダンスによってはMainLight以外にもLightがあるのでLightを移動
                    lightList       = (Light[])FindObjectsOfType(typeof(Light));
                    lightVectorList = new Vector3[lightList.Length];
                    for (int i = 0; i < lightList.Length; i++)
                    {
                        lightList[i].gameObject.transform.position =
                            new Vector3(lightList[i].gameObject.transform.position.x,
                                        lightList[i].gameObject.transform.position.y,
                                        lightList[i].gameObject.transform.position.z) + xmlManager.BackGroundPos;
                        lightVectorList[i] = new Vector3(lightList[i].gameObject.transform.position.x,
                                                         lightList[i].gameObject.transform.position.y,
                                                         lightList[i].gameObject.transform.position.z);
                        //  Debug.LogError("Dance_khg.Plugin:light.transform.position" + lightList[i].gameObject.transform.position.ToString());
                        //  Debug.LogError("Dance_khg.Plugin:light.transform.eulerAngles" + lightList[i].gameObject.transform.eulerAngles.ToString());
                        //  Debug.LogError("Dance_khg.Plugin:light.range" + lightList[i].type + " " + lightList[i].range);
                        //  if(lightList[i].type == LightType.Point) lightList[i].range += 30.0f;
                        //  lightList[i].range = lightList[i].range * 2.0f;
                    }
                    // カメラはほぼ毎フレーム移動 トランスフォームの取得しておく
                    cameraTransform = GameMain.Instance.MainCamera.transform;
                    // 背景用メイド設定
                    GameMain.Instance.CharacterMgr.SetActiveMaid(maid, maidIndex);
                    maid.SetPos(xmlManager.BackGroundPos + xmlManager.BackGroundPos2);
                    maid.SetRot(xmlManager.BackGroundrotate);
//                    maid.gameObject.transform.localScale = localscale;
                    maid.Visible = true;

                    // 固定ライト追加
//                    GameObject goSubLight;
//                    goSubLight = new GameObject("sub light");
//                    goSubLight.AddComponent<Light>();
//                    goSubLight.transform.SetParent(goSubCam.transform);
//                    goSubLight.transform.position =
//                                            new Vector3(0.0f,
//                                                        1.0f,
//                                                        0.0f) + xmlManager.BackGroundPos;
//                    goSubLight.transform.eulerAngles =
//                                            new Vector3(90.0f,  全然わからん
//                                                        0.0f,
//                                                        0.0f);

//                    goSubLight.GetComponent<Light>().type = LightType.Spot;
//                    goSubLight.GetComponent<Light>().type = LightType.Directional;
//                    goSubLight.GetComponent<Light>().range = 10;
//                    goSubLight.GetComponent<Light>().enabled = true;
//                    goSubLight.GetComponent<Light>().intensity = 1.2f;
//                  goSubLight.GetComponent<Light>().spotAngle = ssParam.fValue[PKeySubLight][PPropSubLightRange];
                }

//                GameObject[] gObjList = (GameObject[])FindObjectsOfType(typeof(GameObject));
//                foreach (GameObject gObj in gObjList){
//                    Debug.LogError("DanceBg.Plugin:" + gObj.tag);
//                }

                maidSetting = true;
            }
            if (cameraTransform != null)
            {
                cameraTransform.position = new Vector3(cameraTransform.position.x,
                                                       cameraTransform.position.y,
                                                       cameraTransform.position.z) + xmlManager.BackGroundPos;
//                cameraTransform.position = new Vector3(cameraTransform.position.x * localscale.x,
//                                                       cameraTransform.position.y * localscale.y,
//                                                       cameraTransform.position.z * localscale.z) + xmlManager.BackGroundPos;
            }
            if (lightList != null)
            {
                for (int i = 0; i < lightList.Length; i++)
                {
                    if (lightList[i].gameObject.transform.position != lightVectorList[i])
                    {
                        lightList[i].gameObject.transform.position =
                            new Vector3(lightList[i].gameObject.transform.position.x,
                                        lightList[i].gameObject.transform.position.y,
                                        lightList[i].gameObject.transform.position.z) + xmlManager.BackGroundPos;
                        lightVectorList[i] = new Vector3(lightList[i].gameObject.transform.position.x,
                                                         lightList[i].gameObject.transform.position.y,
                                                         lightList[i].gameObject.transform.position.z);
                        //    Debug.LogError("Dance_khg.Plugin:light.transform.position" + lightList[i].gameObject.transform.position.ToString());
                        //  Debug.LogError("Dance_khg.Plugin:light.range" + lightList[i].type + " " + lightList[i].range);
                        //  Debug.LogError("Dance_khg.Plugin:light.transform.eulerAngles" + lightList[i].gameObject.transform.eulerAngles.ToString());
                    }
                }
            }

//            if(Input.GetKeyDown(KeyCode.Space)){
//                xmlManager = new XmlManager();
//                Maid maidx = GameMain.Instance.CharacterMgr.GetMaid(0);
//                maidx.SetPos(maidx.gameObject.transform.localPosition + xmlManager.BackGroundPos);
//            }
        }
Exemplo n.º 20
0
 public override object GetIkCtrl(Maid maid)
 {
     return(maid.IKCtrl);
 }
Exemplo n.º 21
0
        string drawFileField(string value, string label, IFileSelectable file, int indent = 0)
        {
            GUILayout.BeginHorizontal();
            spacer(indent);
            GUILayout.Label(label, labelStyle, labelWidth);
            string val = GUILayout.TextField(value, textStyle, textHeight);

            if (GUILayout.Button("...", buttonStyle, GUILayout.Width(fontSize * 2)))
            {
                openFileBrowser(file);
            }
            if (GUILayout.Button("適用", buttonStyle, GUILayout.Width(fontSize * 4)))
            {
                file.LoadFile(file.FilenameWithExtension);
                Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);

                switch (file.fileType)
                {
                case Params.FileType.menu:
                    loadMenu();
                    Menu.ProcScript(maid, file.FilenameWithExtension);
                    maid.body0.FixMaskFlag();
                    maid.body0.FixVisibleFlag(false);
                    maid.AllProcPropSeqStart();
                    break;

                case Params.FileType.mate:
                    var mate = (MateFile)file;
                    foreach (var slot in Params.MPNtoSlotname[mate.category])
                    {
                        maid.body0.ChangeMaterial(slot, mate.matno, mate.FilenameWithExtension);
                    }
                    break;

                case Params.FileType.model:
                    var model = (ModelFile)file;
                    foreach (var slot in Params.MPNtoSlotname[model.category])
                    {
                        if (slot == "body")
                        {
                            maid.body0.LoadBody_R(model.FilenameWithExtension, maid);
                        }
                        else
                        {
                            maid.body0.AddItem(slot, model.FilenameWithExtension);
                        }
                    }
                    maid.body0.FixMaskFlag();
                    maid.body0.FixVisibleFlag(false);
                    maid.AllProcPropSeqStart();
                    break;

                case Params.FileType.tex:
                    break;

                case Params.FileType.image:
                    var tex = (TexParams)file;
                    if (tex.texFile != null)
                    {
                        if (tex.texFile.LoadFile(tex.FilenameWithExtension))
                        {
                            foreach (var slot in Params.MPNtoSlotname[tex.mateFile.category])
                            {
                                maid.body0.ChangeTex(slot, tex.mateFile.matno, tex.propertyName, tex.filename, null);
                            }
                        }
                    }
                    break;
                }
            }
            GUILayout.EndHorizontal();
            return(val);
        }
Exemplo n.º 22
0
 public override void SetHandIKRotate(string handName, Maid master, Maid slave, string boneTgtname, Vector3 v3HandLOffsetRot)
 {
     //slave.IKTargetToBone(handName, master, boneTgtname, v3HandLOffsetRot, IKCtrlData.IKAttachType.Rotate, false, 0f, boAnime, false);
     slave.IKTargetToBone(handName, master, boneTgtname, v3HandLOffsetRot, IKCtrlData.IKAttachType.Rotate, false, boAnime, false);
 }
Exemplo n.º 23
0
        private void IKInit(Maid slave, XtMasterSlave.MsLinks ms, XtMasterSlave.MsLinkConfig mscfg)
        {
            var fik = slave.body0.IKCtrl.GetNonPublicField <RootMotion.FinalIK.FullBodyBipedIK>("m_FullbodyIK");

            RootMotion.FinalIK.FullBodyBipedIK FullbodyIK = fik;
            var solver = FullbodyIK.solver;

            string[] tgtlist = new string[] { "IKTarget", "BendBone", "ChainRootBone" };

            bool animStop = true; //モーション停止中

            if (ms.doMasterSlave && !mscfg.doStackSlave_PosSyncMode)
            {
                animStop = false;
            }
            else
            {
                Animation anim = slave.body0.m_Bones.GetComponent <Animation>();
                animStop = !anim.isPlaying;
            }

            if (!lastAnimeFNs.ContainsKey(slave) || slave.body0.LastAnimeFN != lastAnimeFNs[slave])
            {
                lastAnimeFNs[slave] = slave.body0.LastAnimeFN;
                animStop            = false;
            }

            solver.spineStiffness           = 1f;   //背骨の硬さ
            solver.pullBodyVertical         = 0.5f; //ボディエフェクター位置補正
            solver.pullBodyHorizontal       = 0f;
            solver.spineMapping.twistWeight = 0f;

            foreach (var e in solver.effectors)
            {
                if (solver.leftHandEffector == e || solver.rightHandEffector == e)
                {
                    // 手のIKは本体側に任せる
                    continue;
                }

                bool donotPin = false;

                if (animStop || donotPin)
                {
                    e.positionWeight = 1f;
                    e.rotationWeight = 0f;
                }
                else
                {
                    e.PinToBone(1f, 0f);
                }

                var tgtname = e.target.gameObject.name;

                if (donotPin)
                {
                    continue;
                }
                else
                {
                    if (tgtlist.Contains(tgtname))
                    {
                        // COM3D2標準ターゲット
                        e.target.transform.position = e.bone.position;
                        e.target.transform.rotation = e.bone.rotation;
                    }
                }
            }

            solver.rightShoulderEffector.positionWeight = 0.95f;
            solver.leftShoulderEffector.positionWeight  = 0.95f;

            solver.bodyEffector.rotationWeight = 1f;

            solver.rightThighEffector.positionWeight = 0.95f;
            solver.leftThighEffector.positionWeight  = 0.95f;

            if (mscfg != null && mscfg.doFinalIKShoulderMove)
            {
                solver.rightShoulderEffector.positionWeight = 0f;
                solver.leftShoulderEffector.positionWeight  = 0f;
            }
            if (mscfg != null && mscfg.doFinalIKThighMove)
            {
                solver.bodyEffector.rotationWeight = 0f;

                solver.rightThighEffector.positionWeight = 0f;
                solver.leftThighEffector.positionWeight  = 0f;
            }

            foreach (var m in solver.limbMappings)
            {
                m.weight = 1f;
                m.maintainRotationWeight = 0f;
            }

            if (mscfg != null)
            {
                solver.rightLegMapping.weight = mscfg.fFinalIKLegWeight; //0.5f;
                solver.leftLegMapping.weight  = mscfg.fFinalIKLegWeight; //0.5f;
            }
            solver.rightLegMapping.maintainRotationWeight = 1f;
            solver.leftLegMapping.maintainRotationWeight  = 1f;
        }
        public void OnGUI()
        {
            if (!visible) return;
            
            GUIStyle winStyle = "box";
            winStyle.fontSize = pv.Font("C1");
            winStyle.alignment = TextAnchor.UpperRight;

            if (sceneLevel == 9)
            {

            }
            else if (sceneLevel == 5 && xmlLoad)
            {
                freeComment = null;
                maid =  GameMain.Instance.CharacterMgr.GetMaid(0);
                if (maid == null) return;

                if (maid.Param != null && maid.Param.status != null && maid.Param.status.free_comment != null)
                {
                    freeComment = maid.Param.status.free_comment;
                }

                if(freeComment != null && Input.GetKey(KeyCode.F4)) {
                    checkFreeComment();
                }

                if (GUI.changed || !oneLoad) getExSaveData();
                    
                if (lastScreenSize != new Vector2(Screen.width, Screen.height))
                {
                    winRect = pv.PropScreenMH(winRect.x, winRect.y, modsSliderWidth, 1f, lastScreenSize);
                    lastScreenSize = new Vector2(Screen.width, Screen.height);
                }
                winRect = GUI.Window(0, winRect, addModsSlider, AddModsSlider.Version, winStyle);
                oneLoad = true;
            }
         }
 // リップシンク(口パク)抑制
 void DisableLipSync(Maid maid)
 {
     bool bMuhyou = ExSaveData.GetBool(maid, PluginName, "MUHYOU", false);
     bool bLipSyncOff = ExSaveData.GetBool(maid, PluginName, "LIPSYNC_OFF", false);
     if (bLipSyncOff || bMuhyou)
     {
         Helper.SetInstanceField(typeof(Maid), maid, "m_bFoceKuchipakuSelfUpdateTime", true);
     }
 }
        public bool RemoveFilter(Maid maid, string slotName, Material mat, Texture2D tex2D)
        {
            var key = CreateKey(MaidHelper.GetGuid(maid), slotName, mat.name, tex2D.name);

            return(_filterParams.Remove(key.ToString()));
        }
        public void SetDelNodes(Maid maid, Dictionary <string, bool> dDelNodes, bool bApply)
        {
            if (!dDelNodes.Any())
            {
                return;
            }

            foreach (var entry in dDelNodes)
            {
                var nodeItem = ACConstants.NodeNames[entry.Key];
                if (entry.Value)   //
                {
                    foreach (var slot in maid.body0.goSlot.GetListParents())
                    {
                        if (slot.obj == null)
                        {
                            continue;
                        }
                        // 強制表示
                        if (slot.m_dicDelNodeBody.ContainsKey(entry.Key))
                        {
                            slot.m_dicDelNodeBody[entry.Key] = true; // entry.Value
                        }
                    }
                }
                else
                {
                    var hasSet = false;
                    foreach (var slotId in nodeItem.slots)
                    {
                        var slot = maid.body0.GetSlot((int)slotId);
                        if (slot.obj == null)
                        {
                            continue;
                        }

                        // slot.boVisible = true;
                        if (slot.m_dicDelNodeBody.ContainsKey(entry.Key))
                        {
                            slot.m_dicDelNodeBody[entry.Key] = false; // entry.Value
                        }
                        hasSet = true;
                        break;
                    }

                    if (hasSet)
                    {
                        continue;
                    }
                    {
                        // もしどこにもない場合はbodyにセット
                        var slot = maid.body0.GetSlot((int)TBody.SlotID.body);
                        if (slot.obj == null)
                        {
                            continue;
                        }

                        //slot.boVisible = true;
                        if (slot.m_dicDelNodeBody.ContainsKey(entry.Key))
                        {
                            slot.m_dicDelNodeBody[entry.Key] = false; // entry.Value
                        }
                    }
                }
            }
            if (bApply)
            {
                FixFlag();
            }
        }
        // スライダー範囲を拡大
        void WideSlider(Maid maid)
        {
            if (!ExSaveData.GetBool(maid, PluginName, "WIDESLIDER", false))
            {
                return;
            }

            TBody tbody = maid.body0;

            string[] PropNames = BoneMorph_PropNames;
            if (tbody == null || tbody.bonemorph == null || tbody.bonemorph.bones == null || PropNames == null)
            {
                return;
            }
            BoneMorph_ boneMorph_ = tbody.bonemorph;

            // スケール変更するボーンのリスト
            Dictionary <string, Vector3> boneScale = new Dictionary <string, Vector3>();

            // ポジション変更するボーンのリスト
            Dictionary <string, Vector3> bonePosition = new Dictionary <string, Vector3>();

            //この配列に記載があるボーンは頭に影響を与えずにTransformを反映させる。
            //ただしボディに繋がっている中のアレは影響を受ける。
            string[] ignoreHeadBones = new string[] { "Bip01 Spine1a" };

            float eyeAngAngle;
            float eyeAngX;
            float eyeAngY;
            {
                float ra = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.angle", 0f);
                float rx = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.x", 0f);
                float ry = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.y", 0f);

                rx += -9f;
                ry += -17f;

                rx /= 1000f;
                ry /= 1000f;

                eyeAngAngle = ra;
                eyeAngX     = rx;
                eyeAngY     = ry;
            }

            Vector3 thiScl = new Vector3(
                1.0f,
                ExSaveData.GetFloat(maid, PluginName, "THISCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "THISCL.width", 1f));

            Vector3 thiPosL;
            Vector3 thiPosR;

            {
                float dx = ExSaveData.GetFloat(maid, PluginName, "THIPOS.x", 0f);
                float dz = ExSaveData.GetFloat(maid, PluginName, "THIPOS.z", 0f);
                float dy = 0.0f;
                thiPosL = new Vector3(dy, dz / 1000f, -dx / 1000f);
                thiPosR = new Vector3(dy, dz / 1000f, dx / 1000f);
            }
            bonePosition["Hip_L"]         = thiPosL;
            bonePosition["Bip01 L Thigh"] = thiPosL;
            bonePosition["Hip_R"]         = thiPosR;
            bonePosition["Bip01 R Thigh"] = thiPosR;

            Vector3 skirtPos;

            {
                float dx = ExSaveData.GetFloat(maid, PluginName, "SKTPOS.x", 0f);
                float dy = ExSaveData.GetFloat(maid, PluginName, "SKTPOS.y", 0f);
                float dz = ExSaveData.GetFloat(maid, PluginName, "SKTPOS.z", 0f);
                skirtPos = new Vector3(-dz / 10f, -dy / 10f, dx / 10f);
            }
            bonePosition["Skirt"] = skirtPos;

            Vector3 muneSubPosL;
            Vector3 muneSubPosR;

            {
                float dx = ExSaveData.GetFloat(maid, PluginName, "MUNESUBPOS.x", 0f);
                float dz = ExSaveData.GetFloat(maid, PluginName, "MUNESUBPOS.z", 0f);
                float dy = ExSaveData.GetFloat(maid, PluginName, "MUNESUBPOS.y", 0f);
                muneSubPosL = new Vector3(-dy / 10f, dz / 10f, -dx / 10f);
                muneSubPosR = new Vector3(-dy / 10f, -dz / 10f, -dx / 10f);
            }
            bonePosition["Mune_L_sub"] = muneSubPosL;
            bonePosition["Mune_R_sub"] = muneSubPosR;

            Vector3 munePosL;
            Vector3 munePosR;

            {
                float dx = ExSaveData.GetFloat(maid, PluginName, "MUNEPOS.x", 0f);
                float dz = ExSaveData.GetFloat(maid, PluginName, "MUNEPOS.z", 0f);
                float dy = ExSaveData.GetFloat(maid, PluginName, "MUNEPOS.y", 0f);
                munePosL = new Vector3(dz / 10f, -dy / 10f, dx / 10f);
                munePosR = new Vector3(dz / 10f, -dy / 10f, -dx / 10f);
            }
            bonePosition["Mune_L"] = munePosL;
            bonePosition["Mune_R"] = munePosR;

            // スケール変更するボーンをリストに一括登録
            SetBoneScaleFromList(boneScale, maid, boneAndPropNameList);

            Transform tEyePosL = null;
            Transform tEyePosR = null;

            float sliderScale = 20f;

            for (int i = boneMorph_.bones.Count - 1; i >= 0; i--)
            {
                BoneMorphLocal boneMorphLocal = boneMorph_.bones[i];
                Vector3        scl            = new Vector3(1f, 1f, 1f);
                Vector3        pos            = boneMorphLocal.pos;
                for (int j = 0; j < (int)PropNames.Length; j++)
                {
                    float s = 1f;
                    switch (j)
                    {
                    case 0:
                        s = boneMorph_.SCALE_Kubi;
                        break;

                    case 1:
                        s = boneMorph_.SCALE_Ude;
                        break;

                    case 2:
                        s = boneMorph_.SCALE_EyeX;
                        break;

                    case 3:
                        s = boneMorph_.SCALE_EyeY;
                        break;

                    case 4:
                        s = boneMorph_.Postion_EyeX * (0.5f + boneMorph_.Postion_EyeY * 0.5f);
                        break;

                    case 5:
                        s = boneMorph_.Postion_EyeY;
                        break;

                    case 6:
                        s = boneMorph_.SCALE_HeadX;
                        break;

                    case 7:
                        s = boneMorph_.SCALE_HeadY;
                        break;

                    case 8:
                        s = boneMorph_.SCALE_DouPer;
                        if (boneMorphLocal.Kahanshin == 0f)
                        {
                            s = 1f - s;
                        }
                        break;

                    case 9:
                        s = boneMorph_.SCALE_Sintyou;
                        break;

                    case 10:
                        s = boneMorph_.SCALE_Koshi;
                        break;

                    case 11:
                        s = boneMorph_.SCALE_Kata;
                        break;

                    case 12:
                        s = boneMorph_.SCALE_West;
                        break;

                    default:
                        s = 1f;
                        break;
                    }

                    if ((boneMorphLocal.atr & 1 << (j & 31)) != 0)
                    {
                        Vector3 v0 = boneMorphLocal.vecs_min[j];
                        Vector3 v1 = boneMorphLocal.vecs_max[j];

                        Vector3 n0 = v0 * sliderScale - v1 * (sliderScale - 1f);
                        Vector3 n1 = v1 * sliderScale - v0 * (sliderScale - 1f);
                        float   f  = (s + sliderScale - 1f) * (1f / (sliderScale * 2.0f - 1f));
                        scl = Vector3.Scale(scl, Vector3.Lerp(n0, n1, f));
                    }

                    if ((boneMorphLocal.atr & 1 << (j + 16 & 31)) != 0)
                    {
                        Vector3 v0 = boneMorphLocal.vecs_min[j + 16];
                        Vector3 v1 = boneMorphLocal.vecs_max[j + 16];

                        Vector3 n0 = v0 * sliderScale - v1 * (sliderScale - 1f);
                        Vector3 n1 = v1 * sliderScale - v0 * (sliderScale - 1f);
                        float   f  = (s + sliderScale - 1f) * (1f / (sliderScale * 2.0f - 1f));
                        pos = Vector3.Scale(pos, Vector3.Lerp(n0, n1, f));
                    }
                }

                Transform linkT = boneMorphLocal.linkT;
                if (linkT == null)
                {
                    continue;
                }

                string name = linkT.name;

                if (name != null && name.Contains("Thigh_SCL_"))
                {
                    boneMorph_.SnityouOutScale = Mathf.Pow(scl.x, 0.9f);
                }

                // リストに登録されているボーンのスケール設定
                if (name != null && boneScale.ContainsKey(name))
                {
                    scl = Vector3.Scale(scl, boneScale[name]);
                }

                // リストに登録されているボーンのポジション設定
                if (name != null && bonePosition.ContainsKey(name))
                {
                    pos += bonePosition[name];
                }

                // ignoreHeadBonesに登録されている場合はヒラエルキーを辿って頭のツリーを無視
                if (name != null && !(ignoreHeadBones.Contains(name) && getHiraerchy(linkT).Contains("_BO_body001/Bip01")))
                {
                    linkT.localScale    = scl;
                    linkT.localPosition = pos;
                }

                if (name != null)
                {
                    if (name == "Eyepos_L")
                    {
                        tEyePosL = linkT;
                    }
                    else if (name == "Eyepos_R")
                    {
                        tEyePosR = linkT;
                    }
                }
            }

            // 目のサイズ・角度変更
            // EyeScaleRotate : 目のサイズと角度変更する CM3D.MaidVoicePich.Plugin.cs の追加メソッド
            // http://pastebin.com/DBuN5Sws
            // その1>>923
            // http://jbbs.shitaraba.net/bbs/read.cgi/game/55179/1438196715/923
            if (tEyePosL != null)
            {
                Transform linkT       = tEyePosL;
                Vector3   localCenter = linkT.localPosition + (new Vector3(0f, eyeAngY, eyeAngX));          // ローカル座標系での回転中心位置
                Vector3   worldCenter = linkT.parent.TransformPoint(localCenter);                           // ワールド座標系での回転中心位置
                Vector3   localAxis   = new Vector3(-1f, 0f, 0f);                                           // ローカル座標系での回転軸
                Vector3   worldAxis   = linkT.TransformDirection(localAxis);                                // ワールド座標系での回転軸

                linkT.localRotation = new Quaternion(-0.00560432f, -0.001345155f, 0.06805823f, 0.9976647f); // 初期の回転量
                linkT.RotateAround(worldCenter, worldAxis, eyeAngAngle);
            }
            if (tEyePosR != null)
            {
                Transform linkT       = tEyePosR;
                Vector3   localCenter = linkT.localPosition + (new Vector3(0f, eyeAngY, -eyeAngX));          // ローカル座標系での回転中心位置
                Vector3   worldCenter = linkT.parent.TransformPoint(localCenter);                            // ワールド座標系での回転中心位置
                Vector3   localAxis   = new Vector3(-1f, 0f, 0f);                                            // ローカル座標系での回転軸
                Vector3   worldAxis   = linkT.TransformDirection(localAxis);                                 // ワールド座標系での回転軸

                linkT.localRotation = new Quaternion(0.9976647f, 0.06805764f, -0.001350592f, -0.005603582f); // 初期の回転量
                linkT.RotateAround(worldCenter, worldAxis, -eyeAngAngle);
            }
        }
        private static IEnumerator exportAllHairMenus(string[] fileNames, bool isModList, int num)
        {
            run[num] = true;
            UnityEngine.Debug.Log("Exporting Menus Start" + fileNames.Length);
            Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);

            if (maid != null)
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    string fileNameFullPath = fileNames[i];
                    bool   isMod            = isModList || fileNameFullPath.IndexOf("mod_") == 0;
                    if (((isMod && includeMods) || (!isMod && !onlyMods)) &&
                        (fileNameFullPath.Contains("hairf") || fileNameFullPath.Contains("hairr") || fileNameFullPath.Contains("hairs") || fileNameFullPath.Contains("hairt")))
                    {
                        string[] filePathSplit = fileNameFullPath.Split('\\');
                        string   fileName      = filePathSplit[filePathSplit.Length - 1];

                        if (!File.Exists(Path.Combine(newMenuPath, fileName)) || overwriteExisting)
                        {
                            MenuObj menu = getMenu(fileNameFullPath);

                            //Only process the file if it is a hair
                            if (new string[] { "hairf", "hairr", "hairs", "hairt" }.Contains(menu.category.ToLower()))
                            {
                                TBody.SlotID slotID = TBody.SlotID.hairAho;
                                MPN          mpnID  = MPN.hairaho;
                                switch (menu.category.ToLower())
                                {
                                case "hairf":
                                    slotID = TBody.SlotID.hairF;
                                    mpnID  = MPN.hairf;
                                    break;

                                case "hairr":
                                    slotID = TBody.SlotID.hairR;
                                    mpnID  = MPN.hairr;
                                    break;

                                case "hairs":
                                    slotID = TBody.SlotID.hairS;
                                    mpnID  = MPN.hairs;
                                    break;

                                case "hairt":
                                    slotID = TBody.SlotID.hairT;
                                    mpnID  = MPN.hairt;
                                    break;
                                }

                                //Cache the current selection
                                string oldFileName = maid.GetProp(mpnID).strFileName;

                                //Set the hair to the file
                                Menu.ProcScript(maid, fileNameFullPath, false);

                                //Export the hair
                                if (everyBone && maid.body0.goSlot[(int)slotID] != null && maid.body0.goSlot[(int)slotID].morph != null && maid.body0.goSlot[(int)slotID].morph.BoneNames != null && maid.body0.goSlot[(int)slotID].morph.BoneNames.Count > 0)
                                {
                                    UnityEngine.Debug.Log("Creating Menu for all bones");
                                    List <HairLengthTargetObj> listTarget = new List <HairLengthTargetObj>();
                                    for (int j = 0; j < maid.body0.goSlot[(int)slotID].morph.BoneNames.Count; j++)
                                    {
                                        string boneName = maid.body0.goSlot[(int)slotID].morph.BoneNames[j];
                                        if (boneName.Contains("yure"))
                                        {
                                            HairLengthTargetObj target = new HairLengthTargetObj();
                                            target.trTarget  = boneName;
                                            target.vScaleMin = new Vector3(0.3f, 1f, 1f);
                                            target.vScaleMax = new Vector3(2f, 1f, 1f);
                                            listTarget.Add(target);
                                        }
                                    }

                                    this1.StartCoroutine(createNewHairMenu(fileName, listTarget, menu, false));
                                }
                                else
                                {
                                    if (slotID != TBody.SlotID.hairAho &&
                                        maid.body0.goSlot[(int)slotID] != null &&
                                        maid.body0.goSlot[(int)slotID].m_HairLengthCtrl != null && maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList != null &&
                                        maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList.ContainsKey("AutoConv") &&
                                        maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList["AutoConv"].listTarget != null &&
                                        maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList["AutoConv"].listTarget.Count != 0)
                                    {
                                        //CM
                                        UnityEngine.Debug.Log("Createing Menu for AutoConv");
                                        List <HairLengthTargetObj> listTarget = new List <HairLengthTargetObj>();
                                        for (int j = 0; j < maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList["AutoConv"].listTarget.Count; j++)
                                        {
                                            TBodySkin.HairLengthCtrl.HairLengthTarget orig = maid.body0.goSlot[(int)slotID].m_HairLengthCtrl.HairLengthGroupList["AutoConv"].listTarget[j];
                                            HairLengthTargetObj target = new HairLengthTargetObj();
                                            target.trTarget  = orig.trTarget.name;
                                            target.vScaleMin = orig.vScaleMin;
                                            target.vScaleMax = orig.vScaleMax;
                                            listTarget.Add(target);
                                        }
                                        this1.StartCoroutine(createNewHairMenu(fileName, listTarget, menu, true));
                                    }
                                    else
                                    {
                                        //COM
                                        //UnityEngine.Debug.Log("Creating Menu for standard");
                                        this1.StartCoroutine(createNewHairMenu(fileName, null, menu, true));
                                    }
                                }

                                //Revert to the old selection
                                Menu.ProcScript(maid, oldFileName, false);
                            }
                        }
                    }
                }
            }
            UnityEngine.Debug.Log("Exporting Menus End" + fileNames.Length);
            run[num] = false;
            yield return(null);
        }
 public void Init(Maid maid)
 {
     this.maid = maid;
     this.StartCoroutine(DisableDefaultAnimIKCo());
 }
Exemplo n.º 31
0
        public override void CopyHandIK(Maid master, Maid slave, XtMasterSlave.v3Offsets[] v3ofs, int num_)
        {
            List <string> listHand = new List <string> {
                "右手", "左手"
            };
            List <IKCtrlData.IKAttachType> listTypes = new List <IKCtrlData.IKAttachType>
            {
                IKCtrlData.IKAttachType.NewPoint, IKCtrlData.IKAttachType.Rotate
            };

            listHand.ToList().ForEach(h =>
            {
                var ikcm = master.body0.IKCtrl.GetIKData(h, IKBend);
                var ikcs = slave.body0.IKCtrl.GetIKData(h, IKBend);
                listTypes.ForEach(t =>
                {
                    var ikm = ikcm.GetIKParam(t);
                    var iks = ikcs.GetIKParam(t);

                    if (!(string.IsNullOrEmpty(ikm.Tgt_AttachName) && ikm.Target == null))
                    {
                        //Console.WriteLine("{0} {1} -> {2} {3} {4}", h, t, ikm.MyType, ikm.Tgt_AttachName, ikm.Target);

                        if (iks.MyType != IKCtrlData.IKAttachType.Rotate)
                        {
                            if (ikm.MyType != IKCtrlData.IKAttachType.Rotate)
                            {
                                iks.ChangePointType(ikm.MyType);
                            }
                        }

                        float fixAngle(float angle)
                        {
                            while (Mathf.Abs(angle) > 360f)
                            {
                                angle = ((!(angle < 0f)) ? (angle - 360f) : (angle + 360f));
                            }
                            return(angle);
                        }

                        if (IkXT.IsIkCtrlO117)
                        {
                            ikcs.SetIKSetting(t, false, ikm.TgtMaid, ikm.Tgt_AttachSlot, ikm.Tgt_AttachName, ikm.AxisTgt, ikm.Target, ikm.TgtOffset, ikm.DoAnimation);
                            //iks.SetIKSetting(ikm.TgtMaid, ikm.Tgt_AttachSlot, ikm.Tgt_AttachName, ikm.AxisTgt, ikm.Target, ikm.TgtOffset, ikm.DoAnimation, ikm.BlendTime);
                        }
                        else
                        {
                            iks.TgtMaid        = ikm.TgtMaid;
                            iks.Tgt_AttachSlot = ikm.Tgt_AttachSlot;
                            iks.Tgt_AttachName = ikm.Tgt_AttachName;
                            iks.Target         = ikm.Target;
                            iks.AxisTgt        = ikm.AxisTgt;
                        }

                        if (iks.IsPointAttach)
                        {
                            iks.TgtOffset = ikm.TgtOffset;
                            if (h == "右手")
                            {
                                iks.TgtOffset += v3ofs[num_].v3HandROffset;
                            }
                            else
                            {
                                iks.TgtOffset += v3ofs[num_].v3HandLOffset;
                            }
                        }
                        else
                        {
                            Vector3 v3rot = Vector3.zero;
                            if (h == "右手")
                            {
                                v3rot = v3ofs[num_].v3HandROffsetRot;
                            }
                            else
                            {
                                v3rot = v3ofs[num_].v3HandLOffsetRot;
                            }

                            iks.TgtOffset.x = fixAngle(ikm.TgtOffset.x + v3rot.x);
                            iks.TgtOffset.y = fixAngle(ikm.TgtOffset.y + v3rot.y);
                            iks.TgtOffset.z = fixAngle(ikm.TgtOffset.z + v3rot.z);
                        }
                    }
                });
            });

            //needInit = true;
        }
 public void SetDelNodes(Maid maid, PresetData preset, bool bApply)
 {
     // if (preset.delNodes == null) return;
     SetDelNodes(maid, preset.delNodes, bApply);
 }
Exemplo n.º 33
0
        public static bool IKBend  = false; //

        public override bool IsNewPointIK(Maid m, string hand = "右手")
        {
            var ikP = m.body0.IKCtrl.GetIKData(hand, IKBend).GetIKParam(IKCtrlData.IKAttachType.Point);

            return(ikP.MyType == IKCtrlData.IKAttachType.NewPoint);
        }
Exemplo n.º 34
0
 public static bool IsValid(Maid m)
 {
     return(m != null && m.body0.trsHead != null && m.Visible);
 }
Exemplo n.º 35
0
        public override void SetHandIKTarget(XtMasterSlave.MsLinkConfig mscfg, string handName, Maid master, Maid slave, int slot_no, string attach_name, Transform target, Vector3 v3HandLOffset)
        {
            /*if (needInit)
             * {
             *  needInit = false;
             *  if (mscfg.doIK159NewPointToDef)
             *      IKInit(slave, mscfg);
             #if DEBUG
             *  else
             *      IKInit4OldPoint(slave);
             #endif
             * }*/

            //slave.IKCtrl.GetIKData(handName, IKBend).SetIKSetting(GetDefType(mscfg), false, master, slot_no, attach_name, null, target, v3HandLOffset, boAnime, 0f);
            slave.IKCtrl.GetIKData(handName, IKBend).SetIKSetting(GetDefType(mscfg), false, master, slot_no, attach_name, null, target, v3HandLOffset, boAnime);

            BipedIKCtrlData ikdata = slave.IKCtrl.GetIKData <BipedIKCtrlData>(handName, IKBend);

            ikdata.CorrectType = BipedIKCtrlData.BorderCorrectType.Bone;
        }
 // まばたき制限
 void Mabataki(Maid maid)
 {
     float mabatakiVal = (float)Helper.GetInstanceField(typeof(Maid), maid, "MabatakiVal");
     float f = Mathf.Clamp01(1f - ExSaveData.GetFloat(maid, PluginName, "MABATAKI", 1f));
     float mMin = Mathf.Asin(f);
     float mMax = (float)Math.PI - mMin;
     mMin = Mathf.Pow(mMin / (float)Math.PI, 0.5f);
     mMax = Mathf.Pow(mMax / (float)Math.PI, 0.5f);
     mabatakiVal = Mathf.Clamp(mabatakiVal, mMin, mMax);
     if (ExSaveData.GetBool(maid, PluginName, "MUHYOU", false))
     {
         // 無表情の場合、常に目を固定
         mabatakiVal = mMin;
     }
     Helper.SetInstanceField(typeof(Maid), maid, "MabatakiVal", mabatakiVal);
 }
Exemplo n.º 37
0
        private void IKInit2(Maid slave)
        {
            var fik = slave.body0.IKCtrl.GetNonPublicField <RootMotion.FinalIK.FullBodyBipedIK>("m_FullbodyIK");

            RootMotion.FinalIK.FullBodyBipedIK FullbodyIK = fik;
            var solver = FullbodyIK.solver;

            string[] tgtlist  = new string[] { "IKTarget", "BendBone", "ChainRootBone" };
            string[] bendlist = new string[] { "BendBone", };

            /*
             #if DEBUG
             * solver.spineStiffness = 1f;      //背骨の硬さ
             * //solver.rightLegMapping.weight = 0f;
             * //solver.leftLegMapping.weight = 0f;
             * if (!solver.bodyEffector.target || solver.bodyEffector.target.gameObject.name != bodytgt)
             *  solver.bodyEffector.target = new GameObject(bodytgt).transform;
             * solver.bodyEffector.positionWeight = 1f;
             * solver.bodyEffector.rotationWeight = 1f;
             * solver.rightShoulderEffector.positionWeight = 0.95f;
             * solver.leftShoulderEffector.positionWeight = 0.95f;
             * solver.rightShoulderEffector.rotationWeight = 0.5f;
             * solver.leftShoulderEffector.rotationWeight = 0.5f;
             *
             * solver.leftThighEffector.positionWeight = 1f;
             * solver.leftThighEffector.rotationWeight = 0.5f;
             * solver.rightThighEffector.positionWeight = 1f;
             * solver.rightThighEffector.rotationWeight = 0.5f;
             * solver.leftFootEffector.positionWeight = 1.0f;
             * solver.rightFootEffector.positionWeight = 1.0f;
             *
             * if (!solver.rightThighEffector.target || solver.rightThighEffector.target.gameObject.name != bodytgt)
             *  solver.rightThighEffector.target = new GameObject(bodytgt).transform;
             * if (!solver.leftThighEffector.target || solver.leftThighEffector.target.gameObject.name != bodytgt)
             *  solver.leftThighEffector.target = new GameObject(bodytgt).transform;
             *
             * if (!solver.rightFootEffector.target || solver.rightFootEffector.target.gameObject.name != bodytgt)
             *  solver.rightFootEffector.target = new GameObject(bodytgt).transform;
             * if (!solver.leftFootEffector.target || solver.leftFootEffector.target.gameObject.name != bodytgt)
             *  solver.leftFootEffector.target = new GameObject(bodytgt).transform;
             *
             * solver.rightLegMapping.weight = 0.2f;
             * solver.leftLegMapping.weight = 0.2f;
             * //Sync(solver.leftArmChain.bendConstraint.bendGoal.transform, solver.leftArmMapping.bone2);
             * //Sync(solver.rightArmChain.bendConstraint.bendGoal.transform, solver.rightArmMapping.bone2);
             * foreach (var e in solver.effectors)
             * {
             *  Sync(e);
             *  var tgtname = e.target.gameObject.name;
             *
             *  if (tgtlist.Contains(tgtname) || tgtname == bodytgt)
             *  {
             *      // COM3D2標準ターゲット
             *      e.target.transform.position = e.bone.position;
             *      e.target.transform.rotation = e.bone.rotation;
             *  }
             *  else if (bendlist.Contains(tgtname))
             *  {
             *      // COM3D2標準ターゲット
             *      e.target.transform.position = e.bone.position;
             *      e.target.transform.rotation = e.bone.rotation;
             *  }
             * }
             * return;
             #endif
             *
             */
            solver.spineStiffness     = 1f;   //背骨の硬さ
            solver.pullBodyVertical   = 0.5f; //ボディエフェクター位置補正
            solver.pullBodyHorizontal = 0f;

            foreach (var e in solver.effectors)
            {
                e.PinToBone(1f, 0f);
#if DEBUG
                e.PinToBone(1f, 1f);
#endif
                var tgtname = e.target.gameObject.name;

                if (tgtlist.Contains(tgtname))
                {
                    // COM3D2標準ターゲット
                    e.target.transform.position = e.bone.position;
                    e.target.transform.rotation = e.bone.rotation;
                }
            }
            solver.rightShoulderEffector.positionWeight = 0.95f;
            solver.leftShoulderEffector.positionWeight  = 0.95f;
            solver.bodyEffector.rotationWeight          = 1f;

            solver.rightLegMapping.maintainRotationWeight = 0f;
            solver.leftLegMapping.maintainRotationWeight  = 0f;
            solver.rightLegMapping.weight = 0f;
            solver.leftLegMapping.weight  = 0f;

            solver.rightArmMapping.maintainRotationWeight = 0f;
            solver.leftArmMapping.maintainRotationWeight  = 0f;
            solver.rightArmMapping.weight = 1f;
            solver.leftArmMapping.weight  = 1f;
        }
 // リップシンク強度指定
 void SetLipSyncIntensity(Maid maid, TBody tbody)
 {
     if (!ExSaveData.GetBool(maid, PluginName, "LIPSYNC_INTENISTY", false))
     {
         return;
     }
     float f1 = Mathf.Clamp01(ExSaveData.GetFloat(maid, PluginName, "LIPSYNC_INTENISTY.value", 1f));
     maid.VoicePara_1 = f1 * 0.5f;
     maid.VoicePara_2 = f1 * 0.074f;
     maid.VoicePara_3 = f1 * 0.5f;
     maid.VoicePara_4 = f1 * 0.05f;
     if (f1 < 0.01f)
     {
         maid.voice_ao_f2 = 0;
     }
 }
Exemplo n.º 39
0
        private void IKInitTest(Maid slave, string handName)
        {
            var fik = slave.body0.IKCtrl.GetNonPublicField <RootMotion.FinalIK.FullBodyBipedIK>("m_FullbodyIK");

            RootMotion.FinalIK.FullBodyBipedIK FullbodyIK = fik;

            var solver = FullbodyIK.solver;

            if (handName.Contains("右"))
            {
                //solver.rightLegMapping.weight = 0f;
                //solver.spineMapping.twistWeight = 0f;

                //m_FullbodyIK.references.root = slave.gameObject.transform;
                //solver.SetToReferences(FullbodyIK.references, null);
                solver.spineStiffness     = 1f;
                solver.pullBodyVertical   = 0f;
                solver.pullBodyHorizontal = 0f;

                if (Input.GetKey(KeyCode.LeftAlt))
                {
                    solver.spineStiffness   = 0f;
                    solver.pullBodyVertical = 1f;
                }
                foreach (var e in solver.effectors)
                {
                    if (Input.GetKey(KeyCode.RightAlt))
                    {
                        e.PinToBone(0.25f, 1f);
                    }
                    else if (Input.GetKey(KeyCode.RightShift))
                    {
                        e.PinToBone(0.5f, 0f);
                    }
                    else if (Input.GetKey(KeyCode.RightControl))
                    {
                        e.PinToBone(0f, 1f);
                    }
                    else
                    {
                        e.PinToBone(1f, 1f);
                    }
                }
                solver.rightLegMapping.maintainRotationWeight = 1f;
                solver.leftLegMapping.maintainRotationWeight  = 1f;

                if (Input.GetKey(KeyCode.Space))
                {
                    solver.rightLegMapping.weight = 1f;
                }
                else if (Input.GetKey(KeyCode.Keypad0))
                {
                    solver.rightLegMapping.weight = 0f;
                }
                else
                {
                    solver.rightLegMapping.weight = 0.5f;
                }

                /*Sync(solver.bodyEffector);
                 * Sync(solver.rightFootEffector);
                 * Sync(solver.rightThighEffector);
                 * Sync(solver.rightShoulderEffector);
                 * WeightZero(solver.rightFootEffector);
                 * WeightZero(solver.rightThighEffector);
                 * WeightZero(solver.rightShoulderEffector);*/
            }
            else
            {
                solver.leftLegMapping.maintainRotationWeight = 1f;
                if (Input.GetKey(KeyCode.Space))
                {
                    solver.leftLegMapping.weight = 1f;
                }
                else if (Input.GetKey(KeyCode.Keypad0))
                {
                    solver.leftLegMapping.weight = 0f;
                }
                else
                {
                    solver.leftLegMapping.weight = 0.5f;
                }

                /*Sync(solver.leftFootEffector);
                 * Sync(solver.leftThighEffector);
                 * Sync(solver.leftShoulderEffector);
                 * WeightZero(solver.leftFootEffector);
                 * WeightZero(solver.leftThighEffector);
                 * WeightZero(solver.leftShoulderEffector);*/
            }
        }
 static TemplateFile Get(Maid maid, string PluginName)
 {
     return(Get(ExSaveData.Get(maid, PluginName, "FACE_SCRIPT_TEMPLATE", null)));
 }
 // 瞳サイズ変更
 void EyeBall(Maid maid)
 {
     TBody tbody = maid.body0;
     if (tbody != null && tbody.trsEyeL != null && tbody.trsEyeR != null)
     {
         float w = ExSaveData.GetFloat(maid, PluginName, "EYEBALL.width", 1f);
         float h = ExSaveData.GetFloat(maid, PluginName, "EYEBALL.height", 1f);
         tbody.trsEyeL.localScale = new Vector3(1f, h, w);
         tbody.trsEyeR.localScale = new Vector3(1f, h, w);
     }
 }
 public void SetMaskSlots(Maid maid, PresetData preset)
 {
     SetMaskSlots(maid, preset.slots);
 }
        public FilterParam GetFilter(Maid maid, string slotName, string matName, string texName)
        {
            var key = CreateKey(MaidHelper.GetGuid(maid), slotName, matName, texName);

            return(_filterParams.Get(key.ToString()));
        }
        // ForeArmFix : 前腕の歪みを修正する CM3D.MaidVoicePitch.Plugin.cs の追加メソッド
        // CM3D.MaidVoicePitch.Plugin を適用しメイドのフリーコメント欄に #FARMFIX# の記述で前腕の歪みを修正する。
        // 前腕歪みバグを修正
        void ForeArmFix(Maid maid)
        {
            if (!ExSaveData.GetBool(maid, PluginName, "FARMFIX", false))
            {
                return;
            }

            BoneMorph_ bm_ = maid.body0.bonemorph;
            List<Transform> tListFAL = new List<Transform>();
            List<Transform> tListFAR = new List<Transform>();
            float sclUAx = -1f;

            for (int i = 0; i < bm_.bones.Count; i++)
            {
                if (bm_.bones[i].linkT == null) continue;
                if (bm_.bones[i].linkT.name == "Bip01 L Forearm") tListFAL.Add(bm_.bones[i].linkT);
                if (bm_.bones[i].linkT.name == "Bip01 R Forearm") tListFAR.Add(bm_.bones[i].linkT);
                if (sclUAx < 0f && bm_.bones[i].linkT.name == "Bip01 L UpperArm") sclUAx = bm_.bones[i].linkT.localScale.x;
            }
            if (sclUAx < 0f || tListFAL.Count < 1 || tListFAR.Count < 1) return;

            Vector3 sclUA = new Vector3(sclUAx, 1f, 1f);

            Vector3 antisclUA_d = new Vector3(1f / sclUAx - 1f, 0f, 0f);

            Vector3 eaFAL = tListFAL[0].localRotation.eulerAngles;
            Vector3 eaFAR = tListFAR[0].localRotation.eulerAngles;

            Quaternion antirotFAL = Quaternion.Euler(eaFAL - new Vector3(180f, 180f, 180f));
            Quaternion antirotFAR = Quaternion.Euler(eaFAR - new Vector3(180f, 180f, 180f));
            Vector3 sclFAL_d = antirotFAL * antisclUA_d;
            Vector3 sclFAR_d = antirotFAR * antisclUA_d;

            Vector3 antisclFAL = new Vector3(1f, 1f, 1f) + new Vector3(Mathf.Abs(sclFAL_d.x), Mathf.Abs(sclFAL_d.y), Mathf.Abs(sclFAL_d.z));
            Vector3 antisclFAR = new Vector3(1f, 1f, 1f) + new Vector3(Mathf.Abs(sclFAR_d.x), Mathf.Abs(sclFAR_d.y), Mathf.Abs(sclFAR_d.z));

            foreach (Transform t in tListFAL) t.localScale = Vector3.Scale(antisclFAL, sclUA);
            foreach (Transform t in tListFAR) t.localScale = Vector3.Scale(antisclFAR, sclUA);
        }
 void SetBoneScale(Dictionary<string, Vector3> dictionary, string boneName, Maid maid, string propName)
 {
         dictionary[boneName] = new Vector3(
 ExSaveData.GetFloat(maid, PluginName, propName + ".height", 1f),
 ExSaveData.GetFloat(maid, PluginName, propName + ".depth", 1f),
 ExSaveData.GetFloat(maid, PluginName, propName + ".width", 1f));
 }
//        private FilterParam GetFilterParam(Material material, TextureEdit texEdit) {
//
//            var tex2d = material.GetTexture(texEdit.propName) as Texture2D;
//            if (tex2d == null || string.IsNullOrEmpty(tex2d.name)) {
//                return null;
//            }
//            var key = new StringBuilder();
//            key.Append(texEdit.slotName).Append('/').Append(material.name).Append('/').Append(tex2d.name);
//            rerturn filterParams.GetOrAdd(key.ToString());
//        }

        private FilterParam GetFilterParam(Maid maid, string slotName, Material material, string propName)
        {
            var key = GetKey(maid, slotName, material, propName);

            return(_filterParams.GetOrAdd(key));
        }
 // 目と口の表情変化をやめる
 void DisableFaceAnime(Maid maid)
 {
     bool bMuhyou = ExSaveData.GetBool(maid, PluginName, "MUHYOU", false);
     bool bHyoujouOff = ExSaveData.GetBool(maid, PluginName, "HYOUJOU_OFF", false);
     if (bHyoujouOff || bMuhyou)
     {
         maid.FaceAnime("", 0f, 0);
     }
 }
 public bool IsValidTarget(Maid maid, string slotName, Material material, string propName)
 {
     return(GetKey(maid, slotName, material, propName) != null);
 }
        /// <summary>
        /// エディットシーン用の状態更新
        /// </summary>
        void EditSceneMaidUpdate(Maid maid)
        {
            if (maid == null || !maid.Visible)
            {
                return;
            }

            bool bMuhyou = ExSaveData.GetBool(maid, PluginName, "MUHYOU", false);
            bool bLipSyncOff = ExSaveData.GetBool(maid, PluginName, "LIPSYNC_OFF", false);
            if (bLipSyncOff || bMuhyou)
            {
                // 何もしない
            }
            else
            {
                // エディットシーンではリップシンクを強制的に復活させる
                Helper.SetInstanceField(typeof(Maid), maid, "m_bFoceKuchipakuSelfUpdateTime", false);
            }
        }
Exemplo n.º 50
0
        private void SetPersonal(Maid maid, object personalId)
        {
            int id = Convert.ToInt32(personalId);

            maid.status.SetPersonal(id);
        }
 // 目を常時カメラに向ける
 void EyeToCam(Maid maid, TBody tbody)
 {
     float fEyeToCam = ExSaveData.GetFloat(maid, PluginName, "EYETOCAM", 0f);
     if (fEyeToCam < -0.5f)
     {
         tbody.boEyeToCam = false;
     }
     else if (fEyeToCam > 0.5f)
     {
         tbody.boEyeToCam = true;
     }
 }
Exemplo n.º 52
0
 private void SetContract(Maid maid, int contract)
 {
     maid.status.contract = (Contract)contract;
 }
 // 顔を常時カメラに向ける
 void HeadToCam(Maid maid, TBody tbody)
 {
     float fHeadToCam = ExSaveData.GetFloat(maid, PluginName, "HEADTOCAM", 0f);
     if (fHeadToCam < -0.5f)
     {
         tbody.boHeadToCam = false;
     }
     else if (fHeadToCam > 0.5f)
     {
         tbody.boHeadToCam = true;
     }
 }
Exemplo n.º 54
0
 private void SetCurSeikeiken(Maid maid, int seikeiken)
 {
     maid.status.seikeiken = (Seikeiken)seikeiken;
 }
 // 瞳の角度を目の角度に合わせて補正
 void RotatePupil(Maid maid, TBody tbody)
 {
     /*
                 //  注意:TBody.MoveHeadAndEye内で trsEye[L,R].localRotation が上書きされているため、
                 //  この値は TBody.MoveHeadAndEyeが呼ばれるたびに書き換える必要がある
                 float eyeAng = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.angle", 0f);
                 Vector3 eea = (Vector3)Helper.GetInstanceField(typeof(TBody), tbody, "EyeEulerAngle");
                 tbody.trsEyeL.localRotation = tbody.quaDefEyeL * Quaternion.Euler(eyeAng, eea.x * -0.2f, eea.z * -0.1f);
                 tbody.trsEyeR.localRotation = tbody.quaDefEyeR * Quaternion.Euler(-eyeAng, eea.x * 0.2f, eea.z * 0.1f);
     */
 }
Exemplo n.º 56
0
 private void SetInitSeikeiken(Maid maid, int seikeiken)
 {
     maid.status.initSeikeiken = (Seikeiken)seikeiken;
 }
        // スライダー範囲を拡大
        void WideSlider(Maid maid)
        {
            if (!ExSaveData.GetBool(maid, PluginName, "WIDESLIDER", false))
            {
                return;
            }

            TBody tbody = maid.body0;
            string[] PropNames = BoneMorph_PropNames;
            if (tbody == null || tbody.bonemorph == null || tbody.bonemorph.bones == null || PropNames == null)
            {
                return;
            }
            BoneMorph_ boneMorph_ = tbody.bonemorph;

            Vector3 eyeScl;
            {
                float aspectRatioMin = 0.1f;
                float aspectRatioMax = 10f;
                float aspectRatio = Mathf.Clamp(ExSaveData.GetFloat(maid, PluginName, "EYE_RATIO", 1f), aspectRatioMin, aspectRatioMax);

                float aspectW = 1f;
                float aspectH = 1f;
                if (aspectRatio >= 1f)
                {
                    // 1以上の場合、横幅は固定で、高さを小さくする
                    aspectW = 1f;
                    aspectH = 1f / aspectRatio;
                }
                else
                {
                    // 1未満の場合、高さは固定で、横幅を小さくする
                    aspectW = 1f * aspectRatio;
                    aspectH = 1f;
                }

                eyeScl = new Vector3(1.00f, aspectH, aspectW);
            }

            float eyeAngAngle;
            float eyeAngX;
            float eyeAngY;
            {
                float ra = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.angle", 0f);
                float rx = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.x", 0f);
                float ry = ExSaveData.GetFloat(maid, PluginName, "EYE_ANG.y", 0f);

                rx += -9f;
                ry += -17f;

                rx /= 1000f;
                ry /= 1000f;

                eyeAngAngle = ra;
                eyeAngX = rx;
                eyeAngY = ry;
            }

            Vector3 thiScl = new Vector3(
                1.0f,
                ExSaveData.GetFloat(maid, PluginName, "THISCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "THISCL.width", 1f));

            Vector3 thiPosL;
            Vector3 thiPosR;
            {
                float dx = ExSaveData.GetFloat(maid, PluginName, "THIPOS.x", 0f);
                float dz = ExSaveData.GetFloat(maid, PluginName, "THIPOS.z", 0f);
                float dy = 0.0f;
                thiPosL = new Vector3(dy, dz / 1000f, -dx / 1000f);
                thiPosR = new Vector3(dy, dz / 1000f, dx / 1000f);
            }

            // 骨盤
            Vector3 pelvisScl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "PELSCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "PELSCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "PELSCL.width", 1f));

            // スカート
            Vector3 sktScl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "SKTSCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "SKTSCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "SKTSCL.width", 1f));

            // 胴(下腹部周辺)
            Vector3 spineScl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "SPISCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "SPISCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "SPISCL.width", 1f));

            // 胴0a(腹部周辺)
            Vector3 spine0aScl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "S0ASCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S0ASCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S0ASCL.width", 1f));

            // 胴1_(みぞおち周辺)
            Vector3 spine1Scl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "S1_SCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S1_SCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S1_SCL.width", 1f));

            // 胴1a(首・肋骨周辺)
            Vector3 spine1aScl = new Vector3(
                ExSaveData.GetFloat(maid, PluginName, "S1ASCL.height", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S1ASCL.depth", 1f),
                ExSaveData.GetFloat(maid, PluginName, "S1ASCL.width", 1f));

            Transform tEyePosL = null;
            Transform tEyePosR = null;

            float sliderScale = 20f;
            for (int i = boneMorph_.bones.Count - 1; i >= 0; i--)
            {
                BoneMorphLocal boneMorphLocal = boneMorph_.bones[i];
                Vector3 scl = new Vector3(1f, 1f, 1f);
                Vector3 pos = boneMorphLocal.pos;
                for (int j = 0; j < (int)PropNames.Length; j++)
                {
                    float s = 1f;
                    switch (j)
                    {
                        case 0:
                            s = boneMorph_.SCALE_Kubi;
                            break;
                        case 1:
                            s = boneMorph_.SCALE_Ude;
                            break;
                        case 2:
                            s = boneMorph_.SCALE_Eye;
                            break;
                        case 3:
                            s = boneMorph_.Postion_EyeX * (0.5f + boneMorph_.Postion_EyeY * 0.5f);
                            break;
                        case 4:
                            s = boneMorph_.Postion_EyeY;
                            break;
                        case 5:
                            s = boneMorph_.SCALE_HeadX;
                            break;
                        case 6:
                            s = boneMorph_.SCALE_HeadY;
                            break;
                        case 7:
                            s = boneMorph_.SCALE_DouPer;
                            if (boneMorphLocal.Kahanshin == 0f)
                            {
                                s = 1f - s;
                            }
                            break;
                        case 8:
                            s = boneMorph_.SCALE_Sintyou;
                            break;
                        case 9:
                            s = boneMorph_.SCALE_Koshi;
                            break;
                        case 10:
                            s = boneMorph_.SCALE_Kata;
                            break;
                        case 11:
                            s = boneMorph_.SCALE_West;
                            break;
                        default:
                            s = 1f;
                            break;
                    }

                    if ((boneMorphLocal.atr & 1 << (j & 31)) != 0)
                    {
                        Vector3 v0 = boneMorphLocal.vecs_min[j];
                        Vector3 v1 = boneMorphLocal.vecs_max[j];

                        Vector3 n0 = v0 * sliderScale - v1 * (sliderScale - 1f);
                        Vector3 n1 = v1 * sliderScale - v0 * (sliderScale - 1f);
                        float f = (s + sliderScale - 1f) * (1f / (sliderScale * 2.0f - 1f));
                        scl = Vector3.Scale(scl, Vector3.Lerp(n0, n1, f));
                    }

                    if ((boneMorphLocal.atr & 1 << (j + 16 & 31)) != 0)
                    {
                        Vector3 v0 = boneMorphLocal.vecs_min[j + 16];
                        Vector3 v1 = boneMorphLocal.vecs_max[j + 16];

                        Vector3 n0 = v0 * sliderScale - v1 * (sliderScale - 1f);
                        Vector3 n1 = v1 * sliderScale - v0 * (sliderScale - 1f);
                        float f = (s + sliderScale - 1f) * (1f / (sliderScale * 2.0f - 1f));
                        pos = Vector3.Scale(pos, Vector3.Lerp(n0, n1, f));
                    }
                }

                Transform linkT = boneMorphLocal.linkT;
                if (linkT == null)
                {
                    continue;
                }

                string name = linkT.name;

                if (name != null && name.Contains("Thigh_SCL_"))
                {
                    boneMorph_.SnityouOutScale = Mathf.Pow(scl.x, 0.9f);
                }

                if (name == null)
                {
                    // 何もしない
                }
                else if (name == "Eyepos_L")
                {
                    scl = Vector3.Scale(scl, eyeScl);
                }
                else if (name == "Eyepos_R")
                {
                    scl = Vector3.Scale(scl, eyeScl);
                }
                else if (name == "Hip_L")
                {
                    scl = Vector3.Scale(scl, pelvisScl);
                    pos += thiPosL;
                }
                else if (name == "Hip_R")
                {
                    scl = Vector3.Scale(scl, pelvisScl);
                    pos += thiPosR;
                }
                else if (name == "Skirt")
                {
                    scl = Vector3.Scale(scl, sktScl);
                }
                else if (name == "Bip01 L Thigh")
                {
                    scl = Vector3.Scale(scl, thiScl);
                    pos += thiPosL;
                }
                else if (name == "Bip01 R Thigh")
                {
                    scl = Vector3.Scale(scl, thiScl);
                    pos += thiPosR;
                }
                else if (name == "Bip01 Pelvis_SCL_")
                {
                    scl = Vector3.Scale(scl, pelvisScl);
                }
                else if (name == "Bip01 Spine_SCL_")
                {
                    scl = Vector3.Scale(scl, spineScl);
                }
                else if (name == "Bip01 Spine0a_SCL_")
                {
                    scl = Vector3.Scale(scl, spine0aScl);
                }
                else if (name == "Bip01 Spine1_SCL_")
                {
                    scl = Vector3.Scale(scl, spine1Scl);
                }
                else if (name == "Bip01 Spine1a_SCL_")
                {
                    scl = Vector3.Scale(scl, spine1aScl);
                }

                linkT.localPosition = pos;
                linkT.localScale = scl;

                if (name != null)
                {
                    if (name == "Eyepos_L")
                    {
                        tEyePosL = linkT;
                    }
                    else if (name == "Eyepos_R")
                    {
                        tEyePosR = linkT;
                    }
                }
            }

            // 目のサイズ・角度変更
            // EyeScaleRotate : 目のサイズと角度変更する CM3D.MaidVoicePich.Plugin.cs の追加メソッド
            // http://pastebin.com/DBuN5Sws
            // その1>>923
            // http://jbbs.shitaraba.net/bbs/read.cgi/game/55179/1438196715/923
            if (tEyePosL != null)
            {
                Transform linkT = tEyePosL;
                Vector3 localCenter = linkT.localPosition + (new Vector3(0f, eyeAngY, eyeAngX)); // ローカル座標系での回転中心位置
                Vector3 worldCenter = linkT.parent.TransformPoint(localCenter);         // ワールド座標系での回転中心位置
                Vector3 localAxis = new Vector3(-1f, 0f, 0f);                       // ローカル座標系での回転軸
                Vector3 worldAxis = linkT.TransformDirection(localAxis);               // ワールド座標系での回転軸

                linkT.localRotation = new Quaternion(-0.00560432f, -0.001345155f, 0.06805823f, 0.9976647f);    // 初期の回転量
                linkT.RotateAround(worldCenter, worldAxis, eyeAngAngle);
            }
            if (tEyePosR != null)
            {
                Transform linkT = tEyePosR;
                Vector3 localCenter = linkT.localPosition + (new Vector3(0f, eyeAngY, -eyeAngX));    // ローカル座標系での回転中心位置
                Vector3 worldCenter = linkT.parent.TransformPoint(localCenter);             // ワールド座標系での回転中心位置
                Vector3 localAxis = new Vector3(-1f, 0f, 0f);                           // ローカル座標系での回転軸
                Vector3 worldAxis = linkT.TransformDirection(localAxis);                   // ワールド座標系での回転軸

                linkT.localRotation = new Quaternion(0.9976647f, 0.06805764f, -0.001350592f, -0.005603582f);   // 初期の回転量
                linkT.RotateAround(worldCenter, worldAxis, -eyeAngAngle);
            }
        }
Exemplo n.º 58
0
        private void SetNightWork(Maid maid, object id)
        {
            int workId = Convert.ToInt32(id);

            maid.status.nightWorkId = workId;
        }
        public void Update()
        {
            fPassedTimeOnLevel += Time.deltaTime;

            if (sceneLevel == 5 && xmlLoad)
            {
                if (!initCompleted && (fPassedTimeOnLevel - fLastInitTime > 1f))
                { 
                    fLastInitTime = fPassedTimeOnLevel;
                    maid =  GameMain.Instance.CharacterMgr.GetMaid(0);
                    if (maid == null) return;
                    initCompleted = initModsSliderNGUI();
                }
                if (!initCompleted) return;

                if (Input.GetKeyDown(KeyCode.F5))
                {
                     visible = !visible;
                     goAMSPanel.SetActive(visible);
                }
            }
        }
Exemplo n.º 60
0
        private Dict ReadMaidData(Maid maid)
        {
            if (maid == null || maid.status == null)
            {
                return(null);
            }

            var result = new Dict();

            var props = new Dict();

            result["properties"] = props;

            foreach (var getter in maidGetters)
            {
                if (maidSetters.ContainsKey(getter.Key))
                {
                    if (getter.Value.ReturnType.IsEnum)
                    {
                        props[getter.Key] = (int)getter.Value.Invoke(maid.status, new object[0]);
                    }
                    else
                    {
                        props[getter.Key] = getter.Value.Invoke(maid.status, new object[0]);
                    }
                }
            }

            foreach (var field in maidFields)
            {
                if (field.Value.FieldType.IsEnum)
                {
                    props[field.Key] = (int)field.Value.GetValue(maid.status);
                }
                else
                {
                    props[field.Key] = field.Value.GetValue(maid.status);
                }
            }

            props["personal"]                = maid.status.personal?.id ?? 0;
            props["current_job_class_id"]    = maid.status.selectedJobClass?.data?.id ?? 0;
            props["current_yotogi_class_id"] = maid.status.selectedYotogiClass?.data?.id ?? 0;

            var workLevels     = new Dictionary <int, object>();
            var workPlayCounts = new Dictionary <int, object>();

            foreach (int dataId in maid.status.workDatas.GetKeyArray())
            {
                var workData = maid.status.workDatas[dataId];
                workLevels[dataId]     = workData.level;
                workPlayCounts[dataId] = workData.playCount;
            }

            result["work_levels"]      = workLevels;
            result["work_play_counts"] = workPlayCounts;

            var propLocks = new Dict();

            result["prop_locks"] = propLocks;

            foreach (var propLock in maidLockList[maid.status.guid])
            {
                propLocks[propLock.Key] = propLock.Value;
            }

            var bonusProps = new Dict();

            result["bonus_properties"] = bonusProps;

            foreach (FieldInfo fieldInfo in bonusStatusFields)
            {
                bonusProps[fieldInfo.Name] = fieldInfo.GetValue(bonusStatusField.GetValue(maid.status));
            }

            var jobData = new Dict();

            result["job_class_data"] = jobData;

            foreach (var classData in maid.status.jobClass.datas.GetValueArray())
            {
                jobData[classData.data.id.ToString()] = new Dict {
                    ["level"] = classData.level, ["cur_exp"] = classData.cur_exp
                }
            }
            ;

            var yotogiData = new Dict();

            result["yotogi_class_data"] = yotogiData;

            foreach (var classData in maid.status.yotogiClass.datas.GetValueArray())
            {
                yotogiData[classData.data.id.ToString()] = new Dict {
                    ["level"] = classData.level, ["cur_exp"] = classData.cur_exp
                }
            }
            ;

            result["yotogi_skill_data"] = ReadYotogiSkillData(maid);

            result["feature_ids"]    = maid.status.features.GetValueArray().Select(f => f.id).ToArray();
            result["propensity_ids"] = maid.status.propensitys.GetValueArray().Select(f => f.id).ToArray();

            Texture2D thum = maid.GetThumIcon();

            result["maid_thumbnail"] = thum?.EncodeToPNG();

            result["guid"] = maid.status.guid;

            return(result);
        }