using System; using System.Collections.Generic; using UnityEngine; public class TMorphBone : BoneMorph_ { public float GetDistanceToSkinByAngle(string groupName, float ratio, float angle, out float defaultDistance) { return this.m_boneDistanceToSkinMgr.GetDistanceToSkinByAngle(groupName, ratio, angle, out defaultDistance); } public override void Init() { } public override void Init(TBodySkin tbskin, MPN f_mpn, TBody.SlotID f_slot) { this.m_tbSkin = tbskin; Transform t = tbskin.obj_tr; this.UninitItem(f_mpn, f_slot); Func func = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphPos.RemoveAll((TMorphBone.BoneMorphPos f) => f.strPropName == propertyName); this.m_listBoneMorphPos.Add(new TMorphBone.BoneMorphPos(propertyName, boneTrans)); return this.m_listBoneMorphPos[this.m_listBoneMorphPos.Count - 1]; }; Func func2 = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphRot.RemoveAll((TMorphBone.BoneMorphRotatio f) => f.strPropName == propertyName); this.m_listBoneMorphRot.Add(new TMorphBone.BoneMorphRotatio(propertyName, boneTrans)); return this.m_listBoneMorphRot[this.m_listBoneMorphRot.Count - 1]; }; Func func3 = delegate(string propertyName, Transform boneTrans) { this.m_listBoneMorphScl.RemoveAll((TMorphBone.BoneMorphScl f) => f.strPropName == propertyName); this.m_listBoneMorphScl.Add(new TMorphBone.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((TMorphBone.BoneMorphPos f) => f.strPropName == "MayuY"); } 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" }); this.m_listBoneMorphPos.RemoveAll((TMorphBone.BoneMorphPos f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphRot.RemoveAll((TMorphBone.BoneMorphRotatio f) => gp001AddPropNames.Contains(f.strPropName)); this.m_listBoneMorphScl.RemoveAll((TMorphBone.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); TMorphBone.BoneMorphPos boneMorphPos = func("EyeBallPosYL", transform7); boneMorphPos.m_vAddMin += new Vector3(0.00325f, -0.005f, 0f); boneMorphPos.m_vAddMax += new Vector3(0f, 0.004f, 0f); TMorphBone.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); TMorphBone.BoneMorphPos boneMorphPos2 = func("EyeBallPosYR", transform8); boneMorphPos2.m_vAddMin += new Vector3(0.00325f, 0.005f, 0f); boneMorphPos2.m_vAddMax += new Vector3(0f, -0.004f, 0f); TMorphBone.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) { TMorphBone.BoneMorphScl boneMorphScl3 = func3("MayuLongL", transform9); boneMorphScl3.m_vAddMin += new Vector3(0f, 0f, -0.25f); boneMorphScl3.m_vAddMax += new Vector3(0f, 0f, 0.25f); TMorphBone.BoneMorphScl boneMorphScl4 = func3("MayuLongR", transform10); boneMorphScl4.m_vAddMin += new Vector3(0f, 0f, -0.25f); boneMorphScl4.m_vAddMax += new Vector3(0f, 0f, 0.25f); } } } if (f_mpn == MPN.body) { t = tbskin.body.m_trBones.Find("Bip01"); foreach (BoneMorphDefine.LinkProp linkProp in ((!tbskin.body.maid.boMAN) ? BoneMorphDefine.m_linkedBoneMaidDef : BoneMorphDefine.m_linkedBoneManDef)) { Transform transform11 = CMT.SearchObjName(t, linkProp.myName, false); Transform transform12 = CMT.SearchObjName(t, linkProp.virtualParent, false); this.m_linkedBones.Add(new TMorphBone.LinkedBone(transform11, transform11.parent, transform12, linkProp.calcPos, linkProp.calcScale)); if (transform11.name.Contains("_IK_") && transform11.name.Contains("_tgt")) { this.IKTargetBoneCtrlDic[transform11] = new IKTargetBoneCtrl(transform11, transform12); } } this.m_boneDistanceToSkinMgr = new BoneDistanceToSkinMgr((TMorphSkin)tbskin.morph, tbskin.m_OriVert.skinThick, t); } } public override void Uninit() { this.m_listBoneMorphPos.Clear(); this.m_listBoneMorphScl.Clear(); this.m_listBoneMorphRot.Clear(); this.IKTargetBoneCtrlDic.Clear(); this.m_linkedBones.Clear(); this.m_boneDistanceToSkinMgr = null; } private void UninitItem() { if (this.m_boneMorph != null) { for (int i = this.m_boneMorph.Count - 1; i >= 0; i--) { TMorphBone.BoneMorphLocal boneMorphLocal = this.m_boneMorph[i]; if (boneMorphLocal.linkT != null) { boneMorphLocal.linkT.localPosition = boneMorphLocal.defaultLocalPos; boneMorphLocal.linkT.localScale = boneMorphLocal.defaultLocalScale; boneMorphLocal.linkT.localRotation = boneMorphLocal.defautLocalRot; } } } this.m_boneMorph = new List(); } public override void UninitItem(MPN f_mpn, TBody.SlotID f_slot) { this.UninitItem(); 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" }); this.m_listBoneMorphPos.RemoveAll((TMorphBone.BoneMorphPos f) => removeTargetPropNames.Contains(f.strPropName)); this.m_listBoneMorphRot.RemoveAll((TMorphBone.BoneMorphRotatio f) => removeTargetPropNames.Contains(f.strPropName)); this.m_listBoneMorphScl.RemoveAll((TMorphBone.BoneMorphScl f) => removeTargetPropNames.Contains(f.strPropName)); } } public override void AddRoot(Transform root) { this.AddRoot_lp(root, false); } private void AddRoot_lp(Transform t, bool Kahanshin = false) { string name = t.name; if (name.IndexOf("_AC_") == 0) { return; } if (name.Contains("Thigh")) { Kahanshin = true; } TMorphBone.BoneMorphLocal boneMorphLocal = null; List list = null; if (((!this.m_tbSkin.body.boMAN) ? BoneMorphDefine.m_dicMaid : BoneMorphDefine.m_dicMan).TryGetValue(name, out list)) { TMorphBone.LinkedBone linkedBone = this.m_linkedBones.Find((TMorphBone.LinkedBone a) => a.my.name == name); for (int i = 0; i < list.Count; i++) { BoneMorphDefine.BoneProp boneProp = list[i]; if (boneMorphLocal == null) { boneMorphLocal = new TMorphBone.BoneMorphLocal { linkT = t, defaultLocalPos = t.localPosition, defaultLocalScale = t.localScale, defautLocalRot = t.localRotation, Kahanshin = Kahanshin, linkedBone = linkedBone }; } int nIndex = boneProp.nIndex; if (boneProp.bExistS) { boneMorphLocal.atrs[nIndex] = true; boneMorphLocal.vecs_min[nIndex] = boneProp.vMinS; boneMorphLocal.vecs_max[nIndex] = boneProp.vMaxS; } if (boneProp.bExistP) { boneMorphLocal.atrs[nIndex + TMorphBone.PROP_MAX] = true; boneMorphLocal.vecs_min[nIndex + TMorphBone.PROP_MAX] = boneProp.vMinP; boneMorphLocal.vecs_max[nIndex + TMorphBone.PROP_MAX] = boneProp.vMaxP; } if (boneProp.bExistR) { boneMorphLocal.atrs[nIndex + TMorphBone.PROP_MAX * 2] = true; boneMorphLocal.vecs_axis[nIndex] = boneProp.vRotAxis; boneMorphLocal.f_min[nIndex] = boneProp.fMinR; boneMorphLocal.f_max[nIndex] = boneProp.fMaxR; } boneMorphLocal.props.Add(boneProp.strProp); } } if (boneMorphLocal != null) { this.m_boneMorph.Add(boneMorphLocal); } for (int j = 0; j < t.childCount; j++) { this.AddRoot_lp(t.GetChild(j), Kahanshin); } } public override void ChangeMorphPosValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { TMorphBone.BoneMorphPos boneMorphPos = this.m_listBoneMorphPos.Find((TMorphBone.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 override void ChangeMorphSclValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { TMorphBone.BoneMorphScl boneMorphScl = this.m_listBoneMorphScl.Find((TMorphBone.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 override void ChangeMorphRotatioValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax) { TMorphBone.BoneMorphRotatio boneMorphRotatio = this.m_listBoneMorphRot.Find((TMorphBone.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 override void Blend() { for (int i = 0; i < this.m_boneMorph.Count; i++) { TMorphBone.BoneMorphLocal boneMorphLocal = this.m_boneMorph[i]; Vector3 vector = boneMorphLocal.defaultLocalScale; Vector3 vector2 = boneMorphLocal.defaultLocalPos; Quaternion quaternion = boneMorphLocal.defautLocalRot; Vector3 a = vector; if (boneMorphLocal.linkedBone != null) { boneMorphLocal.linkedBone.Update(true); if (boneMorphLocal.linkedBone.calcScale) { vector = (a = boneMorphLocal.linkedBone.my.localScale); } if (boneMorphLocal.linkedBone.calcPos) { vector2 = boneMorphLocal.linkedBone.my.localPosition; } } bool flag = false; for (int j = 0; j < BoneMorphDefine.PropNames.Length; j++) { float num = 1f; MPN mpn = BoneMorphDefine.PropNames[j]; if (mpn == MPN.KubiScl) { num = this.SCALE_Kubi; } if (mpn == MPN.UdeScl) { num = this.SCALE_Ude; } if (mpn == MPN.EyeSclX) { num = this.SCALE_EyeX; } if (mpn == MPN.EyeSclY) { num = this.SCALE_EyeY; } if (mpn == MPN.EyePosX) { num = this.POS_EyeX * (0.5f + this.POS_EyeY * 0.5f); } if (mpn == MPN.EyePosY) { num = this.POS_EyeY; } if (mpn == MPN.HeadX) { num = this.SCALE_HeadX; } if (mpn == MPN.HeadY) { num = this.SCALE_HeadY; } if (mpn == MPN.DouPer) { num = this.SCALE_DouPer; if (!boneMorphLocal.Kahanshin) { num = 1f - num; } } if (mpn == MPN.sintyou) { num = this.SCALE_Sintyou; } if (mpn == MPN.kata) { num = this.SCALE_Kata; } if (mpn == MPN.MunePosX) { num = this.MunePosX; } if (mpn == MPN.MunePosY) { num = this.MunePosY; } if (mpn == MPN.MuneThick) { num = this.MuneThick; } if (mpn == MPN.MuneLong) { num = this.MuneLong; } if (mpn == MPN.MuneDir) { num = this.MuneDir; } if (mpn == MPN.DouThick1X) { num = this.DouThick1X; } if (mpn == MPN.DouThick1Y) { num = this.DouThick1Y; } if (mpn == MPN.DouThick2X) { num = this.DouThick2X; } if (mpn == MPN.DouThick2Y) { num = this.DouThick2Y; } if (mpn == MPN.DouThick3X) { num = this.DouThick3X; } if (mpn == MPN.DouThick3Y) { num = this.DouThick3Y; } if (mpn == MPN.ShoulderThick) { num = this.ShoulderThick; } if (mpn == MPN.UpperArmThickX) { num = this.UpperArmThickX; } if (mpn == MPN.UpperArmThickY) { num = this.UpperArmThickY; } if (mpn == MPN.LowerArmThickX) { num = this.LowerArmThickX; } if (mpn == MPN.LowerArmThickY) { num = this.LowerArmThickY; } if (mpn == MPN.ElbowThickX) { num = this.ElbowThickX; } if (mpn == MPN.ElbowThickY) { num = this.ElbowThickY; } if (mpn == MPN.NeckThickX) { num = this.NeckThickX; } if (mpn == MPN.NeckThickY) { num = this.NeckThickY; } if (mpn == MPN.HandSize) { num = this.HandSize; } if (mpn == MPN.DouThick4X) { num = this.DouThick4X; } if (mpn == MPN.DouThick4Y) { num = this.DouThick4Y; } if (mpn == MPN.DouThick5X) { num = this.DouThick5X; } if (mpn == MPN.DouThick5Y) { num = this.DouThick5Y; } if (mpn == MPN.WaistPos) { num = this.WaistPos; } if (mpn == MPN.HipRot) { num = this.HipRot; } if (mpn == MPN.ThighThickX) { num = this.ThighThickX; } if (mpn == MPN.ThighThickY) { num = this.ThighThickY; } if (mpn == MPN.KneeThickX) { num = this.KneeThickX; } if (mpn == MPN.KneeThickY) { num = this.KneeThickY; } if (mpn == MPN.CalfThickX) { num = this.CalfThickX; } if (mpn == MPN.CalfThickY) { num = this.CalfThickY; } if (mpn == MPN.AnkleThickX) { num = this.AnkleThickX; } if (mpn == MPN.AnkleThickY) { num = this.AnkleThickY; } if (mpn == MPN.FootSize) { num = this.FootSize; } if (mpn == MPN.UpperArmLowerThickX) { num = this.UpperArmLowerThickX; } if (mpn == MPN.UpperArmLowerThickY) { num = this.UpperArmLowerThickY; } if (mpn == MPN.WristThickX) { num = this.WristThickX; } if (mpn == MPN.WristThickY) { num = this.WristThickY; } if (mpn == MPN.ClavicleThick) { num = this.ClavicleThick; } if (mpn == MPN.ShoulderTension) { num = this.ShoulderTension; } if (mpn == MPN.ThighLowerThickX) { num = this.ThighLowerThickX; } if (mpn == MPN.ThighLowerThickY) { num = this.ThighLowerThickY; } if (mpn == MPN.ThighShin) { num = this.ThighShin; } if (boneMorphLocal.atrs[j]) { Vector3 b = Vector3.Lerp(boneMorphLocal.vecs_min[j], boneMorphLocal.vecs_max[j], num); vector = Vector3.Scale(vector, b); if (mpn != MPN.ThighShin) { a = Vector3.Scale(a, b); } } if (boneMorphLocal.atrs[j + TMorphBone.PROP_MAX]) { vector2 = Vector3.Scale(vector2, Vector3.Lerp(boneMorphLocal.vecs_min[j + TMorphBone.PROP_MAX], boneMorphLocal.vecs_max[j + TMorphBone.PROP_MAX], num)); } if (boneMorphLocal.atrs[j + TMorphBone.PROP_MAX * 2]) { quaternion = Quaternion.AngleAxis(boneMorphLocal.f_min[j] + (boneMorphLocal.f_max[j] - boneMorphLocal.f_min[j]) * num, boneMorphLocal.vecs_axis[j]) * quaternion; flag = true; } } if (boneMorphLocal.linkT.name.Contains("Thigh_SCL_")) { this.SnityouOutScale = Mathf.Pow(a.x, 0.9f); } boneMorphLocal.linkT.localPosition = vector2; boneMorphLocal.linkT.localScale = vector; if (flag) { boneMorphLocal.linkT.localRotation = quaternion; } } for (int k = 0; k < this.m_linkedBones.Count; k++) { this.m_linkedBones[k].Update(false); } foreach (TMorphBone.BoneMorphPos boneMorphPos in this.m_listBoneMorphPos) { 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)); } } foreach (TMorphBone.BoneMorphScl boneMorphScl in this.m_listBoneMorphScl) { 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 (TMorphBone.BoneMorphRotatio boneMorphRotatio in this.m_listBoneMorphRot) { if (boneMorphRotatio.strPropName == "Earrot_L" || boneMorphRotatio.strPropName == "Earrot_R") { boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Ear); } else if (boneMorphRotatio.strPropName == "Mayurot_L" || boneMorphRotatio.strPropName == "Mayurot_R") { boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Mayu); } } this.m_tbSkin.body.m_editYorime = 5f * ((this.Yorime - 0.5f) / 0.5f); this.m_tbSkin.body.m_editEyeRotX = 10f * ((this.HitomiRot - 0.5f) / 0.5f); } public void UpdateBoneDistanceToSkin() { if (this.m_boneDistanceToSkinMgr != null) { this.m_boneDistanceToSkinMgr.Update(); } } public void UpdateIKTargetBone() { foreach (IKTargetBoneCtrl iktargetBoneCtrl in this.IKTargetBoneCtrlDic.Values) { iktargetBoneCtrl.Update(); } } public float POS_EyeX = 1f; public float POS_EyeY = 1f; public float MunePosX = 0.5f; public float MunePosY = 0.5f; public float MuneThick = 0.5f; public float MuneLong = 0.5f; public float MuneDir = 0.5f; public float DouThick1X = 0.5f; public float DouThick1Y = 0.5f; public float DouThick2X = 0.5f; public float DouThick2Y = 0.5f; public float DouThick3X = 0.5f; public float DouThick3Y = 0.5f; public float ShoulderThick = 0.5f; public float UpperArmThickX = 0.5f; public float UpperArmThickY = 0.5f; public float LowerArmThickX = 0.5f; public float LowerArmThickY = 0.5f; public float ElbowThickX = 0.5f; public float ElbowThickY = 0.5f; public float NeckThickX = 0.5f; public float NeckThickY = 0.5f; public float HandSize = 0.5f; public float DouThick4X = 0.5f; public float DouThick4Y = 0.5f; public float DouThick5X = 0.5f; public float DouThick5Y = 0.5f; public float WaistPos = 0.5f; public float HipRot = 0.5f; public float ThighThickX = 0.5f; public float ThighThickY = 0.5f; public float KneeThickX = 0.5f; public float KneeThickY = 0.5f; public float CalfThickX = 0.5f; public float CalfThickY = 0.5f; public float AnkleThickX = 0.5f; public float AnkleThickY = 0.5f; public float FootSize = 0.5f; public float UpperArmLowerThickX = 0.5f; public float UpperArmLowerThickY = 0.5f; public float WristThickX = 0.5f; public float WristThickY = 0.5f; public float ClavicleThick = 0.5f; public float ShoulderTension = 0.5f; public float ThighLowerThickX = 0.5f; public float ThighLowerThickY = 0.5f; public float ThighShin = 0.5f; public float HitomiRot = 0.5f; private static readonly int PROP_MAX = BoneMorphDefine.PropNames.Length; public List m_boneMorph; private List m_linkedBones = new List(); private List m_listBoneMorphPos = new List(); private List m_listBoneMorphScl = new List(); private List m_listBoneMorphRot = new List(); private TBodySkin m_tbSkin; private Dictionary IKTargetBoneCtrlDic = new Dictionary(); private BoneDistanceToSkinMgr m_boneDistanceToSkinMgr; public class LinkedBone { public LinkedBone(Transform my_, Transform realParent_, Transform virtualParent_, bool calcPos_ = true, bool calcScale_ = true) { this.my = my_; this.realPanret = realParent_; this.virtualParent = virtualParent_; this.defaultPos = this.my.localPosition; this.defaultScale = this.my.localScale; this.bindPoseVirtualParent = virtualParent_.worldToLocalMatrix * realParent_.localToWorldMatrix; this.localPointOnRealParent = realParent_.InverseTransformPoint(this.my.position); this.localVectorOnRealParentRight = realParent_.InverseTransformVector(this.my.right); this.localVectorOnRealParentUp = realParent_.InverseTransformVector(this.my.up); this.localVectorOnRealParentForward = realParent_.InverseTransformVector(this.my.forward); this.calcPos = calcPos_; this.calcScale = calcScale_; } public void Update(bool firstTime) { if (firstTime) { this.updated = true; } else if (!firstTime && this.updated) { this.updated = false; return; } if (this.calcPos) { this.my.localPosition = this.defaultPos; } if (this.calcScale) { this.my.localScale = this.defaultScale; } Vector3 vector = Vector3.zero; if (this.calcPos) { vector = this.bindPoseVirtualParent.MultiplyPoint(this.localPointOnRealParent); vector = this.realPanret.InverseTransformPoint(this.virtualParent.TransformPoint(vector)); } if (this.calcScale) { Vector3 vector2 = this.bindPoseVirtualParent.MultiplyVector(this.localVectorOnRealParentRight); vector2 = this.realPanret.InverseTransformVector(this.virtualParent.TransformVector(vector2)); Vector3 vector3 = this.bindPoseVirtualParent.MultiplyVector(this.localVectorOnRealParentUp); vector3 = this.realPanret.InverseTransformVector(this.virtualParent.TransformVector(vector3)); Vector3 vector4 = this.bindPoseVirtualParent.MultiplyVector(this.localVectorOnRealParentForward); vector4 = this.realPanret.InverseTransformVector(this.virtualParent.TransformVector(vector4)); this.my.localScale = new Vector3(vector2.magnitude, vector3.magnitude, vector4.magnitude); } if (this.calcPos) { this.my.localPosition = vector; } } public Transform my; private Transform realPanret; private Transform virtualParent; private Matrix4x4 bindPoseVirtualParent; private Vector3 localPointOnRealParent; private Vector3 localVectorOnRealParentRight; private Vector3 localVectorOnRealParentUp; private Vector3 localVectorOnRealParentForward; private Vector3 defaultPos; private Vector3 defaultScale; public bool calcPos = true; public bool calcScale = true; private bool updated; } public class BoneMorphLocal { public Vector3 defaultLocalScale; public Vector3 defaultLocalPos; public Quaternion defautLocalRot; public Transform linkT; public bool[] atrs = new bool[TMorphBone.PROP_MAX * 3]; public bool Kahanshin; public List props = new List(); public Vector3[] vecs_min = new Vector3[TMorphBone.PROP_MAX * 2]; public Vector3[] vecs_max = new Vector3[TMorphBone.PROP_MAX * 2]; public Vector3[] vecs_axis = new Vector3[TMorphBone.PROP_MAX]; public float[] f_min = new float[TMorphBone.PROP_MAX]; public float[] f_max = new float[TMorphBone.PROP_MAX]; public TMorphBone.LinkedBone linkedBone; public string linkTname; } 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 TMorphBone.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 TMorphBone.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 TMorphBone.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; } }