using System; using System.Collections; using System.Collections.Generic; using RootMotion.FinalIK; using UnityEngine; using wf; public class IKManager : MonoBehaviour { public static Dictionary> CreateBoneDic(Maid maid) { if (maid == null) { return null; } NDebug.Assert(maid.body0 != null, "[body0] it does not end load."); string text = (!maid.boMAN) ? "Bip01" : "ManBip"; Dictionary> dictionary = new Dictionary>(); dictionary.Add(IKManager.BoneType.TopFixed, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text).parent.gameObject)); dictionary.Add(IKManager.BoneType.Root, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text).gameObject)); dictionary.Add(IKManager.BoneType.Head, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Head").gameObject)); dictionary.Add(IKManager.BoneType.Neck, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Neck").gameObject)); dictionary.Add(IKManager.BoneType.Pelvis, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Pelvis").gameObject)); dictionary.Add(IKManager.BoneType.Spine0, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Spine1, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine0a").gameObject)); dictionary.Add(IKManager.BoneType.Spine2, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine1").gameObject)); dictionary.Add(IKManager.BoneType.Spine3, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine1a").gameObject)); } else { dictionary.Add(IKManager.BoneType.Spine1, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine1").gameObject)); dictionary.Add(IKManager.BoneType.Spine2, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " Spine2").gameObject)); } dictionary.Add(IKManager.BoneType.Mouth, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Mouth").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Bust_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Mune_R").gameObject)); dictionary.Add(IKManager.BoneType.Bust_R_Sub, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Mune_R_sub").gameObject)); dictionary.Add(IKManager.BoneType.Nipple_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Nipple_R").gameObject)); } dictionary.Add(IKManager.BoneType.Clavicle_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Clavicle").gameObject)); dictionary.Add(IKManager.BoneType.UpperArm_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R UpperArm").gameObject)); dictionary.Add(IKManager.BoneType.Forearm_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Forearm").gameObject)); dictionary.Add(IKManager.BoneType.Hand_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Hand").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Bust_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Mune_L").gameObject)); dictionary.Add(IKManager.BoneType.Bust_L_Sub, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Mune_L_sub").gameObject)); dictionary.Add(IKManager.BoneType.Nipple_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Nipple_L").gameObject)); } dictionary.Add(IKManager.BoneType.Clavicle_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Clavicle").gameObject)); dictionary.Add(IKManager.BoneType.UpperArm_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L UpperArm").gameObject)); dictionary.Add(IKManager.BoneType.Forearm_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Forearm").gameObject)); dictionary.Add(IKManager.BoneType.Hand_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Hand").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Hip_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Hip_R").gameObject)); } dictionary.Add(IKManager.BoneType.Thigh_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Thigh").gameObject)); dictionary.Add(IKManager.BoneType.Calf_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Calf").gameObject)); dictionary.Add(IKManager.BoneType.Foot_R, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " R Foot").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Hip_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone("Hip_L").gameObject)); } dictionary.Add(IKManager.BoneType.Thigh_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Thigh").gameObject)); dictionary.Add(IKManager.BoneType.Calf_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Calf").gameObject)); dictionary.Add(IKManager.BoneType.Foot_L, new KeyValuePair(IKManager.BoneSetType.Body, maid.body0.GetBone(text + " L Foot").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_Root_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger0").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_0_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger01").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_1_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger02").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_Root_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger1").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_0_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger11").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_1_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger12").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_Root_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger2").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_0_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger21").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_1_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger22").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_Root_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger3").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_0_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger31").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_1_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger32").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_Root_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger4").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_0_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger41").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_1_R, new KeyValuePair(IKManager.BoneSetType.RightArmFinger, maid.body0.GetBone(text + " R Finger42").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger0").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_0_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger01").gameObject)); dictionary.Add(IKManager.BoneType.Finger0_1_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger02").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger1").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_0_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger11").gameObject)); dictionary.Add(IKManager.BoneType.Finger1_1_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger12").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger2").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_0_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger21").gameObject)); dictionary.Add(IKManager.BoneType.Finger2_1_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger22").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger3").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_0_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger31").gameObject)); dictionary.Add(IKManager.BoneType.Finger3_1_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger32").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger4").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_0_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger41").gameObject)); dictionary.Add(IKManager.BoneType.Finger4_1_L, new KeyValuePair(IKManager.BoneSetType.LeftArmFinger, maid.body0.GetBone(text + " L Finger42").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe0_Root_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe2").gameObject)); dictionary.Add(IKManager.BoneType.Toe0_0_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe21").gameObject)); } dictionary.Add(IKManager.BoneType.Toe1_Root_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe1").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe1_0_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe11").gameObject)); } dictionary.Add(IKManager.BoneType.Toe2_Root_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe0").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe2_0_R, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " R Toe01").gameObject)); } if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe0_Root_L, new KeyValuePair(IKManager.BoneSetType.RightLegFinger, maid.body0.GetBone(text + " L Toe2").gameObject)); dictionary.Add(IKManager.BoneType.Toe0_0_L, new KeyValuePair(IKManager.BoneSetType.LeftLegFinger, maid.body0.GetBone(text + " L Toe21").gameObject)); } dictionary.Add(IKManager.BoneType.Toe1_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftLegFinger, maid.body0.GetBone(text + " L Toe1").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe1_0_L, new KeyValuePair(IKManager.BoneSetType.LeftLegFinger, maid.body0.GetBone(text + " L Toe11").gameObject)); } dictionary.Add(IKManager.BoneType.Toe2_Root_L, new KeyValuePair(IKManager.BoneSetType.LeftLegFinger, maid.body0.GetBone(text + " L Toe0").gameObject)); if (!maid.boMAN) { dictionary.Add(IKManager.BoneType.Toe2_0_L, new KeyValuePair(IKManager.BoneSetType.LeftLegFinger, maid.body0.GetBone(text + " L Toe01").gameObject)); } return dictionary; } public void Awake() { } public void SetMaid(Maid target_maid) { if (this.bone_dic_.Count != 0) { return; } StopWatch stopWatch = new StopWatch(); this.maid = target_maid; if (this.maid == null) { return; } NDebug.Assert(this.maid.body0 != null, "[body0] it does not end load."); this.cache_bone_data_ = this.maid.gameObject.GetComponent(); if (this.cache_bone_data_ == null) { this.cache_bone_data_ = this.maid.gameObject.AddComponent(); this.cache_bone_data_.CreateCache(this.maid.body0.GetBone("Bip01")); } this.bone_dic_ = IKManager.CreateBoneDic(this.maid); List> list = new List>(); Transform transform = this.bone_dic_[IKManager.BoneType.TopFixed].Value.transform; foreach (KeyValuePair> keyValuePair in this.bone_dic_) { Transform transform2 = keyValuePair.Value.Value.transform; int num = 0; while (!(transform2 == transform)) { transform2 = transform2.parent; num++; } list.Add(new KeyValuePair(num, keyValuePair.Key)); } list.Sort((KeyValuePair a, KeyValuePair b) => a.Key - b.Key); this.sort_bone_list_ = new List>(); foreach (KeyValuePair keyValuePair2 in list) { this.sort_bone_list_.Add(new KeyValuePair(keyValuePair2.Value, this.bone_dic_[keyValuePair2.Value].Value)); } this.limb_control_list_ = new List(); IEnumerator enumerator3 = Enum.GetValues(typeof(LimbControl.Type)).GetEnumerator(); try { while (enumerator3.MoveNext()) { object obj = enumerator3.Current; LimbControl.Type type = (LimbControl.Type)obj; LimbControl limbControl = base.gameObject.AddComponent(); limbControl.Initialize(this, type); this.limb_control_list_.Add(limbControl); } } finally { IDisposable disposable; if ((disposable = (enumerator3 as IDisposable)) != null) { disposable.Dispose(); } } this.root_drag_point_ = IKManager.CreateIKDragPoint(this.GetBone(IKManager.BoneType.Root), this.maid); this.root_drag_point_.PositonCorrectionEnabled = false; this.root_drag_point_.cur_drag_event = delegate() { this.root_drag_point_.target_ik_point_trans.position = this.root_drag_point_.transform.position; }; this.root_drag_point_.drag_end_event = delegate() { this.HistoryPush(); }; this.AddLimitComponen(); this.gizmo_render_list_ = new List(); this.gizmo_render_dic_ = new Dictionary(); foreach (KeyValuePair> keyValuePair3 in this.bone_dic_) { GameObject gameObject = new GameObject(); gameObject.transform.SetParent(base.transform, false); gameObject.name = keyValuePair3.Value.ToString(); GizmoRenderTarget gizmoRenderTarget = gameObject.AddComponent(); gizmoRenderTarget.ik_mgr = this; this.gizmo_render_list_.Add(gizmoRenderTarget); this.gizmo_render_dic_.Add(keyValuePair3.Key, gizmoRenderTarget); gizmoRenderTarget.target_trans = keyValuePair3.Value.Value.transform; gizmoRenderTarget.offsetScale = 0.2f; gizmoRenderTarget.lineRSelectedThick = 0.2f; RotationLimitHinge component = keyValuePair3.Value.Value.GetComponent(); if (component != null) { Vector3 axis = component.axis; if (axis.x != 0f && axis.y == 0f && axis.z == 0f) { gizmoRenderTarget.VisibleRotateY = (gizmoRenderTarget.VisibleRotateZ = false); } else if (axis.x == 0f && axis.y != 0f && axis.z == 0f) { gizmoRenderTarget.VisibleRotateX = (gizmoRenderTarget.VisibleRotateZ = false); } else if (axis.x == 0f && axis.y == 0f && axis.z != 0f) { gizmoRenderTarget.VisibleRotateX = (gizmoRenderTarget.VisibleRotateY = false); } } } this.finger_blend_ = base.gameObject.AddComponent(); this.finger_blend_.SetIKManager(this); FingerBlend.BaseFinger right_arm_finger = this.finger_blend_.right_arm_finger; bool enabled = false; this.finger_blend_.left_arm_finger.enabled = enabled; right_arm_finger.enabled = enabled; FingerBlend.BaseFinger right_leg_finger = this.finger_blend_.right_leg_finger; enabled = false; this.finger_blend_.left_leg_finger.enabled = enabled; right_leg_finger.enabled = enabled; } public void Flip() { if (IKManager.notFlipTypes == null || IKManager.notFlipTypes.Count <= 0) { IKManager.notFlipTypes.Add(IKManager.BoneType.TopFixed); IKManager.notFlipTypes.Add(IKManager.BoneType.Head); IKManager.notFlipTypes.Add(IKManager.BoneType.Bust_R); IKManager.notFlipTypes.Add(IKManager.BoneType.Bust_L); for (int i = 27; i <= 68; i++) { IKManager.notFlipTypes.Add((IKManager.BoneType)i); } for (int j = 69; j <= 73; j++) { IKManager.notFlipTypes.Add((IKManager.BoneType)j); } } if (IKManager.swapFlipDic == null || IKManager.swapFlipDic.Count <= 0) { IKManager.swapFlipDic.Add(IKManager.BoneType.Clavicle_R, IKManager.BoneType.Clavicle_L); IKManager.swapFlipDic.Add(IKManager.BoneType.UpperArm_R, IKManager.BoneType.UpperArm_L); IKManager.swapFlipDic.Add(IKManager.BoneType.Forearm_R, IKManager.BoneType.Forearm_L); IKManager.swapFlipDic.Add(IKManager.BoneType.Thigh_R, IKManager.BoneType.Thigh_L); IKManager.swapFlipDic.Add(IKManager.BoneType.Calf_R, IKManager.BoneType.Calf_L); IKManager.swapFlipDic.Add(IKManager.BoneType.Hand_R, IKManager.BoneType.Hand_L); IKManager.swapFlipDic.Add(IKManager.BoneType.Foot_R, IKManager.BoneType.Foot_L); List> list = new List>(); foreach (KeyValuePair keyValuePair in IKManager.swapFlipDic) { list.Add(new KeyValuePair(keyValuePair.Value, keyValuePair.Key)); } foreach (KeyValuePair keyValuePair2 in list) { IKManager.swapFlipDic.Add(keyValuePair2.Key, keyValuePair2.Value); } } Dictionary dictionary = new Dictionary(); for (int k = 0; k <= 68; k++) { IKManager.BoneType boneType = (IKManager.BoneType)k; if (!IKManager.notFlipTypes.Contains(boneType)) { Transform transform = this.bone_dic_[boneType].Value.transform; dictionary.Add(boneType, transform.rotation.eulerAngles); } } Quaternion rotation = Quaternion.identity; Vector3 vector = Vector3.zero; for (int l = 0; l < this.sort_bone_list_.Count; l++) { IKManager.BoneType key = this.sort_bone_list_[l].Key; if (!IKManager.notFlipTypes.Contains(key)) { if (dictionary.ContainsKey(key)) { vector = dictionary[key]; if (key == IKManager.BoneType.Root) { rotation = Quaternion.Euler(360f - (vector.x + 270f) - 270f, 360f - (vector.y + 90f) - 90f, 360f - vector.z); } else { if (IKManager.swapFlipDic.ContainsKey(key)) { vector = dictionary[IKManager.swapFlipDic[key]]; } rotation = Quaternion.Euler(360f - vector.x, 360f - (vector.y + 90f) - 90f, vector.z); } this.bone_dic_[key].Value.transform.rotation = rotation; } } } byte[] binary = this.finger_blend_.right_arm_finger.GetBinary(); byte[] binary2 = this.finger_blend_.left_arm_finger.GetBinary(); this.finger_blend_.right_arm_finger.SetBinary(binary2, true); this.finger_blend_.left_arm_finger.SetBinary(binary, true); binary = this.finger_blend_.right_leg_finger.GetBinary(); binary2 = this.finger_blend_.left_leg_finger.GetBinary(); this.finger_blend_.right_leg_finger.SetBinary(binary2, true); this.finger_blend_.left_leg_finger.SetBinary(binary, true); } public void SetRotateVisibleBone(IKManager.BoneType bone_type, bool visible) { this.gizmo_render_dic_[bone_type].Visible = visible; } public void SetRotateVisibleBoneSet(IKManager.BoneSetType bone_set_type, bool visible) { HashSet hashSet = new HashSet(); foreach (KeyValuePair> keyValuePair in this.bone_dic_) { KeyValuePair value = keyValuePair.Value; if (value.Key == bone_set_type) { hashSet.Add(value.Value.transform); } } for (int i = 0; i < this.gizmo_render_list_.Count; i++) { if (hashSet.Contains(this.gizmo_render_list_[i].target_trans)) { this.gizmo_render_list_[i].Visible = visible; } } } public void SetTransAxisVisibleBoneSet(IKManager.BoneSetType bone_set_type, bool visible) { HashSet hashSet = new HashSet(); switch (bone_set_type) { case IKManager.BoneSetType.Body: hashSet.Add(LimbControl.Type.Arm_L); hashSet.Add(LimbControl.Type.Arm_R); hashSet.Add(LimbControl.Type.Foot_L); hashSet.Add(LimbControl.Type.Foot_R); break; case IKManager.BoneSetType.RightArmFinger: for (int i = 2; i <= 6; i++) { hashSet.Add((LimbControl.Type)i); } break; case IKManager.BoneSetType.LeftArmFinger: for (int j = 12; j <= 16; j++) { hashSet.Add((LimbControl.Type)j); } break; case IKManager.BoneSetType.RightLegFinger: for (int k = 7; k <= 9; k++) { hashSet.Add((LimbControl.Type)k); } break; case IKManager.BoneSetType.LeftLegFinger: for (int l = 17; l <= 19; l++) { hashSet.Add((LimbControl.Type)l); } break; } foreach (LimbControl limbControl in this.limb_control_list_) { if (hashSet.Contains(limbControl.type)) { limbControl.visible = visible; } } } public void SetTransAxisVisibleRoot(bool visible) { this.root_drag_point_.visible = visible; } public void OnDestroy() { if (this.root_drag_point_ != null) { UnityEngine.Object.Destroy(this.root_drag_point_.gameObject); } foreach (LimbControl obj in this.limb_control_list_) { UnityEngine.Object.Destroy(obj); } foreach (GizmoRenderTarget gizmoRenderTarget in this.gizmo_render_list_) { UnityEngine.Object.Destroy(gizmoRenderTarget.gameObject); } this.gizmo_render_dic_.Clear(); if (this.maid != null) { UnityEngine.Object.Destroy(this.cache_bone_data_); GameObject gameObject = GameObject.Find("IKDragPointParent/" + this.maid.status.guid); if (gameObject != null) { UnityEngine.Object.Destroy(gameObject.gameObject); } } if (this.finger_blend_ != null) { UnityEngine.Object.Destroy(this.finger_blend_); } } public void HistoryNew() { if (this.undo_backup_list_.Count == 0) { this.HistoryClear(); this.HistoryPush(); } } public void HistoryClear() { this.undo_backup_list_.Clear(); this.history_point = 0; } public void HistoryPush() { if (this.maid == null) { return; } byte[] frameBinary = this.cache_bone_data.GetFrameBinary(true, true); if (this.undo_backup_list_.Count == 0 || frameBinary != this.undo_backup_list_[this.undo_backup_list_.Count - 1]) { if (this.history_point < this.undo_backup_list_.Count) { this.undo_backup_list_.RemoveRange(this.history_point, this.undo_backup_list_.Count - this.history_point); } this.undo_backup_list_.Add(frameBinary); this.history_point++; if (200 <= this.undo_backup_list_.Count) { this.undo_backup_list_.RemoveAt(0); this.history_point--; } } } public bool HistoryUndo() { if (this.history_point <= 1) { return false; } this.history_point--; this.cache_bone_data.SetFrameBinary(this.undo_backup_list_[this.history_point - 1]); return true; } public bool HistoryRedo() { if (this.undo_backup_list_.Count <= this.history_point) { return false; } this.history_point++; this.cache_bone_data.SetFrameBinary(this.undo_backup_list_[this.history_point - 1]); return true; } public GameObject GetBone(IKManager.BoneType bone_type) { return (!this.bone_dic_.ContainsKey(bone_type)) ? null : this.bone_dic_[bone_type].Value; } public CacheBoneDataArray cache_bone_data { get { return this.cache_bone_data_; } } public Maid maid { get; private set; } public FingerBlend finger_blend { get { return this.finger_blend_; } } private void AddLimitComponen() { Action action = delegate(IKManager.BoneType target_bone, Vector3 axis, float limit, float twist_limit) { Transform transform = this.GetBone(target_bone).gameObject.transform; Quaternion localRotation = transform.localRotation; transform.localRotation = Quaternion.identity; RotationLimitAngle rotationLimitAngle = transform.gameObject.AddComponent(); rotationLimitAngle.axis = axis; rotationLimitAngle.limit = limit; rotationLimitAngle.twistLimit = twist_limit; transform.localRotation = localRotation; rotationLimitAngle.enabled = false; }; Action action2 = delegate(IKManager.BoneType target_bone, Vector3 axis, Vector2 min_max) { Transform transform = this.GetBone(target_bone).gameObject.transform; Quaternion localRotation = transform.localRotation; transform.localRotation = Quaternion.identity; RotationLimitHinge rotationLimitHinge = transform.gameObject.AddComponent(); rotationLimitHinge.axis = axis; rotationLimitHinge.min = min_max.x; rotationLimitHinge.max = min_max.y; transform.localRotation = localRotation; rotationLimitHinge.enabled = false; }; action(IKManager.BoneType.Neck, new Vector3(-1f, 0f, 0f), 85f, 80f); action2(IKManager.BoneType.Forearm_L, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Forearm_R, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Calf_L, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Calf_R, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger0_0_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger1_0_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger2_0_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger3_0_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger4_0_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger0_0_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger1_0_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger2_0_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger3_0_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger4_0_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger0_1_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger1_1_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger2_1_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger3_1_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger4_1_L, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger0_1_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger1_1_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger2_1_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger3_1_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Finger4_1_R, new Vector3(0f, 0f, -1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe0_0_L, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe0_0_R, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe1_0_L, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe1_0_R, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe2_0_L, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); action2(IKManager.BoneType.Toe2_0_R, new Vector3(0f, 0f, 1f), new Vector2(0f, 170f)); } public static IKDragPoint CreateIKDragPoint(GameObject obj, Maid maid) { GameObject gameObject = GameObject.Find("IKDragPointParent"); if (gameObject == null) { gameObject = new GameObject("IKDragPointParent"); } List list = new List(); for (int i = 0; i < gameObject.transform.childCount; i++) { if (gameObject.transform.GetChild(i).childCount == 0 && gameObject.transform.GetChild(i).name != maid.status.guid) { list.Add(gameObject.transform.GetChild(i).gameObject); } } foreach (GameObject obj2 in list) { UnityEngine.Object.DestroyImmediate(obj2); } GameObject gameObject2 = GameObject.Find("IKDragPointParent/" + maid.status.guid); if (gameObject2 == null) { GameObject gameObject3 = new GameObject(maid.status.guid); gameObject3.transform.SetParent(gameObject.transform, false); gameObject = gameObject3; } else { gameObject = gameObject2; } GameObject gameObject4 = GameObject.Find("IKDragPointParent/" + maid.status.guid + "/IKDragPoint_" + obj.name); if (gameObject4 != null) { return gameObject4.GetComponent(); } GameObject gameObject5 = new GameObject("IKDragPoint_" + obj.name); gameObject5.transform.parent = gameObject.transform; IKDragPoint ikdragPoint = gameObject5.AddComponent(); ikdragPoint.SetTargetIKPoint(obj); WorldTransformAxis worldTransformAxis = PhotoWindowManager.CreateWorldTransformAxis(gameObject5, true, true); ikdragPoint.SetWorldTransformAxis(worldTransformAxis); return ikdragPoint; } private static HashSet notFlipTypes = new HashSet(); private static Dictionary swapFlipDic = new Dictionary(); private Dictionary> bone_dic_ = new Dictionary>(); private List> sort_bone_list_ = new List>(); private CacheBoneDataArray cache_bone_data_; private List limb_control_list_; private List gizmo_render_list_; private Dictionary gizmo_render_dic_; private FingerBlend finger_blend_; private IKDragPoint root_drag_point_; private List undo_backup_list_ = new List(); private int history_point; public enum BoneType { TopFixed, Root, Head, Neck, Pelvis, Spine0, Spine1, Spine2, Spine3, Bust_R, Clavicle_R, UpperArm_R, Forearm_R, Hand_R, Hip_R, Thigh_R, Calf_R, Foot_R, Bust_L, Clavicle_L, UpperArm_L, Forearm_L, Hand_L, Hip_L, Thigh_L, Calf_L, Foot_L, Finger0_Root_R, Finger0_0_R, Finger0_1_R, Finger1_Root_R, Finger1_0_R, Finger1_1_R, Finger2_Root_R, Finger2_0_R, Finger2_1_R, Finger3_Root_R, Finger3_0_R, Finger3_1_R, Finger4_Root_R, Finger4_0_R, Finger4_1_R, Finger0_Root_L, Finger0_0_L, Finger0_1_L, Finger1_Root_L, Finger1_0_L, Finger1_1_L, Finger2_Root_L, Finger2_0_L, Finger2_1_L, Finger3_Root_L, Finger3_0_L, Finger3_1_L, Finger4_Root_L, Finger4_0_L, Finger4_1_L, Toe0_Root_R, Toe0_0_R, Toe1_Root_R, Toe1_0_R, Toe2_Root_R, Toe2_0_R, Toe0_Root_L, Toe0_0_L, Toe1_Root_L, Toe1_0_L, Toe2_Root_L, Toe2_0_L, Mouth, Bust_L_Sub, Bust_R_Sub, Nipple_L, Nipple_R } public enum BoneSetType { Body, RightArmFinger, LeftArmFinger, RightLegFinger, LeftLegFinger } }