using System; using System.Collections.Generic; using System.Text; using UnityEngine; public class BoneMorph_ { public void Init() { if (this.bones != null) { for (int i = this.bones.Count - 1; i >= 0; i--) { BoneMorphLocal boneMorphLocal = this.bones[i]; if (boneMorphLocal.linkT != null) { boneMorphLocal.linkT.localPosition = boneMorphLocal.pos; } } } this.bones = new List(); } public void Uninit() { this.m_listBoneMorphPos.Clear(); this.m_listBoneMorphScl.Clear(); this.m_listBoneMorphRot.Clear(); } public void InitBoneMorphEdit(Transform t, MPN f_mpn, TBody.SlotID f_slot) { TBodySkin slot = t.GetComponentsInParent(true)[0].GetSlot((int)f_slot); this.InitBoneMorphEdit(t, f_mpn, f_slot, slot); } public void InitBoneMorphEdit(Transform t, MPN f_mpn, TBody.SlotID f_slot, TBodySkin tbskin) { this.m_tbSkin = tbskin; Func func = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => f.strPropName == propertyName); this.m_listBoneMorphPos.Add(new BoneMorph_.BoneMorphPos(propertyName, boneTrans)); return this.m_listBoneMorphPos[this.m_listBoneMorphPos.Count - 1]; }; Func func2 = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => f.strPropName == propertyName); this.m_listBoneMorphRot.Add(new BoneMorph_.BoneMorphRotatio(propertyName, boneTrans)); return this.m_listBoneMorphRot[this.m_listBoneMorphRot.Count - 1]; }; Func func3 = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => f.strPropName == propertyName); this.m_listBoneMorphScl.Add(new BoneMorph_.BoneMorphScl(propertyName, boneTrans)); return this.m_listBoneMorphScl[this.m_listBoneMorphScl.Count - 1]; }; if (f_mpn == MPN.head && f_slot == TBody.SlotID.head) { Transform transform = CMT.SearchObjName(t, "Ear_L", false); bool flag = transform != null; if (flag) { this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => f.strPropName == "MayuY"); if (this.m_tbSkin.PartsVersion < 120) { HashSet gp001AddPropNames = new HashSet(new string[] { "MayuLongL", "MayuLongR" }); this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => gp001AddPropNames.Contains(f.strPropName)); } } else { HashSet gp001AddPropNames = new HashSet(new string[] { "Earrot_L", "Earrot_R", "Earscl_L", "Earscl_R", "Nosepos", "Nosescl", "Mayupos_L", "Mayupos_R", "Mayurot_L", "Mayurot_R", "MayuLongL", "MayuLongR" }); this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => gp001AddPropNames.Contains(f.strPropName)); } if (transform != null) { func2("Earrot_L", transform); func3("Earscl_L", transform); } Transform transform2 = CMT.SearchObjName(t, "Ear_R", false); if (transform2 != null) { func2("Earrot_R", transform2); func3("Earscl_R", transform2); } Transform transform3 = CMT.SearchObjName(t, "Nose", false); if (transform3 != null) { func("Nosepos", transform3); func3("Nosescl", transform3); } Transform transform4 = CMT.SearchObjName(t, "Mayupos", false); if (transform4 != null) { func("MayuY", transform4); } Transform transform5 = CMT.SearchObjName(t, "Mayupos_L", false); if (transform5 != null) { func("Mayupos_L", transform5); func2("Mayurot_L", transform5); } Transform transform6 = CMT.SearchObjName(t, "Mayupos_R", false); if (transform6 != null) { func("Mayupos_R", transform6); func2("Mayurot_R", transform6); } Transform transform7 = CMT.SearchObjName(t, "Eye_L", false); if (transform7 != null) { func("EyeBallPosXL", transform7); BoneMorph_.BoneMorphPos boneMorphPos = func("EyeBallPosYL", transform7); boneMorphPos.m_vAddMin += new Vector3(0.00325f, -0.005f, 0f); boneMorphPos.m_vAddMax += new Vector3(0f, 0.004f, 0f); BoneMorph_.BoneMorphScl boneMorphScl = func3("EyeBallSclXL", transform7); boneMorphScl.m_vAddMin += new Vector3(0f, -0.3f, -0.3f); boneMorphScl.m_vAddMax += new Vector3(0f, 0.1f, 0.1f); boneMorphScl = func3("EyeBallSclYL", transform7); boneMorphScl.m_vAddMin += new Vector3(0f, -0.3f, -0.3f); boneMorphScl.m_vAddMax += new Vector3(0f, 0.1f, 0.1f); } Transform transform8 = CMT.SearchObjName(t, "Eye_R", false); if (transform8 != null) { func("EyeBallPosXR", transform8); BoneMorph_.BoneMorphPos boneMorphPos2 = func("EyeBallPosYR", transform8); boneMorphPos2.m_vAddMin += new Vector3(0.00325f, 0.005f, 0f); boneMorphPos2.m_vAddMax += new Vector3(0f, -0.004f, 0f); BoneMorph_.BoneMorphScl boneMorphScl2 = func3("EyeBallSclXR", transform8); boneMorphScl2.m_vAddMin += new Vector3(0f, -0.3f, -0.3f); boneMorphScl2.m_vAddMax += new Vector3(0f, 0.1f, 0.1f); boneMorphScl2 = func3("EyeBallSclYR", transform8); boneMorphScl2.m_vAddMin += new Vector3(0f, -0.3f, -0.3f); boneMorphScl2.m_vAddMax += new Vector3(0f, 0.1f, 0.1f); } if (120 <= tbskin.PartsVersion) { Transform transform9 = CMT.SearchObjName(t, "Mayupos_L", false); Transform transform10 = CMT.SearchObjName(t, "Mayupos_R", false); if (transform9 != null && transform10 != null) { BoneMorph_.BoneMorphScl boneMorphScl3 = func3("MayuLongL", transform9); boneMorphScl3.m_vAddMin += new Vector3(0f, 0f, -0.25f); boneMorphScl3.m_vAddMax += new Vector3(0f, 0f, 0.25f); BoneMorph_.BoneMorphScl boneMorphScl4 = func3("MayuLongR", transform10); boneMorphScl4.m_vAddMin += new Vector3(0f, 0f, -0.25f); boneMorphScl4.m_vAddMax += new Vector3(0f, 0f, 0.25f); } } } } public void DelBoneMorphEdit(MPN f_mpn, TBody.SlotID f_slot) { if (f_mpn == MPN.head && f_slot == TBody.SlotID.head) { HashSet removeTargetPropNames = new HashSet(new string[] { "Earrot_L", "Earrot_R", "Earscl_L", "Earscl_R", "Nosepos", "Nosescl", "MayuY", "Mayupos_L", "Mayupos_R", "Mayurot_L", "Mayurot_R", "EyeBallPosXL", "EyeBallPosYL", "EyeBallSclXL", "EyeBallSclXR", "EyeBallPosXR", "EyeBallPosYR", "EyeBallSclYL", "EyeBallSclYR", "MayuLongL", "MayuLongR" }); this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => removeTargetPropNames.Contains(f.strPropName)); this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => removeTargetPropNames.Contains(f.strPropName)); this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => removeTargetPropNames.Contains(f.strPropName)); } } private void AddRoot_lp(Transform t, int level = 0, float Kahanshin = 0f) { string name = t.name; if (name.Contains("Thigh")) { Kahanshin = 1f; } BoneMorphLocal boneMorphLocal = null; List list = null; if (BoneMorph.dic2.TryGetValue(name, out list)) { for (int i = 0; i < list.Count; i++) { BoneMorph.BoneProp boneProp = list[i]; if (boneMorphLocal == null) { boneMorphLocal = new BoneMorphLocal(); boneMorphLocal.atr = 0L; boneMorphLocal.linkT = t; boneMorphLocal.pos = t.localPosition; boneMorphLocal.Kahanshin = Kahanshin; } int nIndex = boneProp.nIndex; if (boneProp.bExistM) { boneMorphLocal.atr |= 1L << nIndex; boneMorphLocal.vecs_min[nIndex] = boneProp.vMinM; boneMorphLocal.vecs_max[nIndex] = boneProp.vMaxM; } if (boneProp.bExistP) { boneMorphLocal.atr |= 1L << nIndex + 32; boneMorphLocal.vecs_min[nIndex + 32] = boneProp.vMinP; boneMorphLocal.vecs_max[nIndex + 32] = boneProp.vMaxP; } boneMorphLocal.props.Add(boneProp.strProp); } } if (boneMorphLocal != null) { this.bones.Add(boneMorphLocal); } for (int j = 0; j < t.childCount; j++) { this.AddRoot_lp(t.GetChild(j), level + 1, Kahanshin); } } public void AddRoot(Transform root) { this.AddRoot_lp(root, 0, 0f); } public void ChangeMorphPosValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { BoneMorph_.BoneMorphPos boneMorphPos = this.m_listBoneMorphPos.Find((BoneMorph_.BoneMorphPos f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName); if (boneMorphPos != null) { boneMorphPos.m_vAddMin = boneMorphPos.trBone.localPosition + f_fAddMin; boneMorphPos.m_vAddMax = boneMorphPos.trBone.localPosition + f_fAddMax; } } public void ChangeMorphSclValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { BoneMorph_.BoneMorphScl boneMorphScl = this.m_listBoneMorphScl.Find((BoneMorph_.BoneMorphScl f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName); if (boneMorphScl != null) { boneMorphScl.m_vAddMin = boneMorphScl.trBone.localScale + f_fAddMin; boneMorphScl.m_vAddMax = boneMorphScl.trBone.localScale + f_fAddMax; } } public void ChangeMorphRotatioValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { BoneMorph_.BoneMorphRotatio boneMorphRotatio = this.m_listBoneMorphRot.Find((BoneMorph_.BoneMorphRotatio f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName); if (boneMorphRotatio != null) { boneMorphRotatio.m_vAddMin = boneMorphRotatio.m_vDefRotate * Quaternion.Euler(f_fAddMin); boneMorphRotatio.m_vAddMax = boneMorphRotatio.m_vDefRotate * Quaternion.Euler(f_fAddMax); } } public void Blend() { for (int i = this.bones.Count - 1; i >= 0; i--) { BoneMorphLocal boneMorphLocal = this.bones[i]; Vector3 vector = new Vector3(1f, 1f, 1f); Vector3 vector2 = boneMorphLocal.pos; for (int j = 0; j < BoneMorph.PropNames.Length; j++) { float num = 1f; if (j == 0) { num = this.SCALE_Kubi; } if (j == 1) { num = this.SCALE_Ude; } if (j == 2) { num = this.SCALE_EyeX; } if (j == 3) { num = this.SCALE_EyeY; } if (j == 4) { num = this.Postion_EyeX * (0.5f + this.Postion_EyeY * 0.5f); } if (j == 5) { num = this.Postion_EyeY; } if (j == 6) { num = this.SCALE_HeadX; } if (j == 7) { num = this.SCALE_HeadY; } if (j == 8) { num = this.SCALE_DouPer; if (boneMorphLocal.Kahanshin == 0f) { num = 1f - num; } } if (j == 9) { num = this.SCALE_Sintyou; } if (j == 10) { num = this.SCALE_Koshi; } if (j == 11) { num = this.SCALE_Kata; } if (j == 12) { num = this.SCALE_West; } if ((boneMorphLocal.atr & 1L << j) != 0L) { vector = Vector3.Scale(vector, Vector3.Lerp(boneMorphLocal.vecs_min[j], boneMorphLocal.vecs_max[j], num)); } if ((boneMorphLocal.atr & 1L << 32 + j) != 0L) { vector2 = Vector3.Scale(vector2, Vector3.Lerp(boneMorphLocal.vecs_min[j + 32], boneMorphLocal.vecs_max[j + 32], num)); } } if (boneMorphLocal.linkT.name.Contains("Thigh_SCL_")) { this.SnityouOutScale = Mathf.Pow(vector.x, 0.9f); } boneMorphLocal.linkT.localPosition = vector2; boneMorphLocal.linkT.localScale = vector; } for (int k = 0; k < this.m_listBoneMorphPos.Count; k++) { BoneMorph_.BoneMorphPos boneMorphPos = this.m_listBoneMorphPos[k]; if (boneMorphPos.strPropName == "Nosepos") { boneMorphPos.trBone.localPosition = boneMorphPos.Lerp(this.POS_Nose); } else if (boneMorphPos.strPropName == "MayuY") { boneMorphPos.trBone.localPosition = boneMorphPos.Lerp(this.POS_MayuY); } else if (boneMorphPos.strPropName == "Mayupos_L" || boneMorphPos.strPropName == "Mayupos_R") { Vector3 vector3 = boneMorphPos.Lerp(this.POS_MayuY); float x = boneMorphPos.m_vAddMin.x; boneMorphPos.m_vAddMin = new Vector3(boneMorphPos.m_vAddMax.x, boneMorphPos.m_vAddMin.y, boneMorphPos.m_vAddMin.z); boneMorphPos.m_vAddMax = new Vector3(x, boneMorphPos.m_vAddMax.y, boneMorphPos.m_vAddMax.z); Vector3 vector4 = boneMorphPos.Lerp(this.POS_MayuX); x = boneMorphPos.m_vAddMax.x; boneMorphPos.m_vAddMax = new Vector3(boneMorphPos.m_vAddMin.x, boneMorphPos.m_vAddMax.y, boneMorphPos.m_vAddMax.z); boneMorphPos.m_vAddMin = new Vector3(x, boneMorphPos.m_vAddMin.y, boneMorphPos.m_vAddMin.z); float x2 = vector4.x + vector3.x - boneMorphPos.m_vDefPos.x; boneMorphPos.trBone.localPosition = new Vector3(x2, vector3.y, vector4.z); } else if (boneMorphPos.strPropName == "EyeBallPosYL" || boneMorphPos.strPropName == "EyeBallPosYR") { boneMorphPos.trBone.localPosition = ((this.EyeBallPosY > 0.5f) ? Vector3.Lerp(boneMorphPos.m_vDefPos, boneMorphPos.m_vAddMax, (this.EyeBallPosY - 0.5f) / 0.5f) : Vector3.Lerp(boneMorphPos.m_vAddMin, boneMorphPos.m_vDefPos, this.EyeBallPosY / 0.5f)); } } for (int l = 0; l < this.m_listBoneMorphScl.Count; l++) { BoneMorph_.BoneMorphScl boneMorphScl = this.m_listBoneMorphScl[l]; if (boneMorphScl.strPropName == "Earscl_L" || boneMorphScl.strPropName == "Earscl_R") { boneMorphScl.trBone.localScale = boneMorphScl.Lerp(this.SCALE_Ear); } else if (boneMorphScl.strPropName == "Nosescl") { boneMorphScl.trBone.localScale = boneMorphScl.Lerp(this.SCALE_Nose); } else if (boneMorphScl.strPropName == "EyeBallSclXL" || boneMorphScl.strPropName == "EyeBallSclXR") { float z = (this.EyeBallSclX >= 0.5f) ? Mathf.Lerp(boneMorphScl.m_vDefScl.z, boneMorphScl.m_vAddMax.z, (this.EyeBallSclX - 0.5f) / 0.5f) : Mathf.Lerp(boneMorphScl.m_vAddMin.z, boneMorphScl.m_vDefScl.z, this.EyeBallSclX / 0.5f); Vector3 localScale = boneMorphScl.trBone.localScale; localScale.z = z; boneMorphScl.trBone.localScale = localScale; } else if (boneMorphScl.strPropName == "EyeBallSclYL" || boneMorphScl.strPropName == "EyeBallSclYR") { float y = (this.EyeBallSclY >= 0.5f) ? Mathf.Lerp(boneMorphScl.m_vDefScl.y, boneMorphScl.m_vAddMax.y, (this.EyeBallSclY - 0.5f) / 0.5f) : Mathf.Lerp(boneMorphScl.m_vAddMin.y, boneMorphScl.m_vDefScl.y, this.EyeBallSclY / 0.5f); Vector3 localScale2 = boneMorphScl.trBone.localScale; localScale2.y = y; boneMorphScl.trBone.localScale = localScale2; } else if (boneMorphScl.strPropName == "MayuLongL" || boneMorphScl.strPropName == "MayuLongR") { boneMorphScl.trBone.localScale = boneMorphScl.Lerp(this.MayuLong); } } foreach (BoneMorph_.BoneMorphRotatio boneMorphRotatio in this.m_listBoneMorphRot) { if (boneMorphRotatio.strPropName == "Earrot_L" || boneMorphRotatio.strPropName == "Earrot_R") { boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Ear); } if (boneMorphRotatio.strPropName == "Mayurot_L" || boneMorphRotatio.strPropName == "Mayurot_R") { boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Mayu); } } if (this.Yorime <= 0.5f) { this.m_tbSkin.body.m_editYorime = 2f * ((this.Yorime - 0.5f) / 0.5f); } else { this.m_tbSkin.body.m_editYorime = 5f * ((this.Yorime - 0.5f) / 0.5f); } } private TextAsset textUserDef1; public float SCALE_Sintyou = 1f; public float SCALE_Koshi = 1f; public float SCALE_DouPer; public float SCALE_Kata = 1f; public float SCALE_West = 1f; public float SCALE_EyeX = 1f; public float SCALE_EyeY = 1f; public float Postion_EyeX = 1f; public float Postion_EyeY = 1f; public float EyeBallPosX = 0.5f; public float EyeBallPosY = 0.5f; public float EyeBallSclX = 0.5f; public float EyeBallSclY = 0.5f; public float SCALE_Kubi = 1f; public float SCALE_Ude = 1f; public float SCALE_HeadX = 1f; public float SCALE_HeadY = 1f; public float POS_Nose = 0.5f; public float SCALE_Nose = 0.5f; public float ROT_Ear = 0.5f; public float SCALE_Ear = 0.5f; public float POS_MayuX = 0.5f; public float POS_MayuY = 0.5f; public float ROT_Mayu = 0.5f; public List bones; public float SnityouOutScale = 1f; private bool m_bMayuOffs; public float MayuLong = 0.5f; public float Yorime = 0.5f; private List m_listBoneMorphPos = new List(); private List m_listBoneMorphScl = new List(); private List m_listBoneMorphRot = new List(); private TBodySkin m_tbSkin; private static StringBuilder sbMinM = new StringBuilder(32); private static StringBuilder sbMinP = new StringBuilder(32); private static StringBuilder sbMaxM = new StringBuilder(32); private static StringBuilder sbMaxP = new StringBuilder(32); private class BoneMorphPos { public BoneMorphPos(string f_strPropName, Transform f_trBone) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vAddMin = (this.m_vAddMax = (this.m_vDefPos = f_trBone.localPosition)); } public BoneMorphPos(string f_strPropName, Transform f_trBone, Vector3 f_vAddMin, Vector3 f_vAddMax) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vDefPos = f_trBone.localPosition; this.m_vAddMin = this.m_vDefPos + f_vAddMin; this.m_vAddMax = this.m_vDefPos + f_vAddMax; } public Vector3 Lerp(float t) { return BoneMorph_.BoneMorphPos.Lerp(this.m_vAddMin, this.m_vDefPos, this.m_vAddMax, t); } public static Vector3 Lerp(Vector3 min, Vector3 def, Vector3 max, float t) { float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f); return (t > 0.5f) ? Vector3.Lerp(def, max, t2) : Vector3.Lerp(min, def, t2); } public static float Lerp(float min, float def, float max, float t) { float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f); return (t > 0.5f) ? Mathf.Lerp(def, max, t2) : Mathf.Lerp(min, def, t2); } public string strPropName; public Transform trBone; public Vector3 m_vDefPos; public Vector3 m_vAddMin; public Vector3 m_vAddMax; } private class BoneMorphScl { public BoneMorphScl(string f_strPropName, Transform f_trBone) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vAddMin = (this.m_vAddMax = (this.m_vDefScl = f_trBone.localScale)); } public BoneMorphScl(string f_strPropName, Transform f_trBone, Vector3 f_vAddMin, Vector3 f_vAddMax) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vDefScl = f_trBone.localScale; this.m_vAddMin = this.m_vDefScl + f_vAddMin; this.m_vAddMax = this.m_vDefScl + f_vAddMax; } public Vector3 Lerp(float t) { return BoneMorph_.BoneMorphPos.Lerp(this.m_vAddMin, this.m_vDefScl, this.m_vAddMax, t); } public string strPropName; public Transform trBone; public Vector3 m_vDefScl; public Vector3 m_vAddMin; public Vector3 m_vAddMax; } private class BoneMorphRotatio { public BoneMorphRotatio(string f_strPropName, Transform f_trBone) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vAddMin = (this.m_vAddMax = (this.m_vDefRotate = f_trBone.localRotation)); } public BoneMorphRotatio(string f_strPropName, Transform f_trBone, Quaternion f_vAddMin, Quaternion f_vAddMax) { this.strPropName = f_strPropName; this.trBone = f_trBone; this.m_vDefRotate = f_trBone.localRotation; this.m_vAddMin = this.m_vDefRotate * f_vAddMin; this.m_vAddMax = this.m_vDefRotate * f_vAddMax; } public Quaternion Lerp(float t) { return BoneMorph_.BoneMorphRotatio.Lerp(this.m_vAddMin, this.m_vDefRotate, this.m_vAddMax, t); } public static Quaternion Lerp(Quaternion min, Quaternion def, Quaternion max, float t) { float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f); return (t > 0.5f) ? Quaternion.Lerp(def, max, t2) : Quaternion.Lerp(min, def, t2); } public string strPropName; public Transform trBone; public Quaternion m_vDefRotate; public Quaternion m_vAddMin; public Quaternion m_vAddMax; } }