FullBodyIKCtrl.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using RootMotion.FinalIK;
  5. using UnityEngine;
  6. public class FullBodyIKCtrl : MonoBehaviour
  7. {
  8. private HeightIKCtrlData m_MouthIKData
  9. {
  10. get
  11. {
  12. return (!this.m_strIKDataPair.ContainsKey("口")) ? null : ((HeightIKCtrlData)this.m_strIKDataPair["口"]);
  13. }
  14. }
  15. public Transform BodyTarget { get; private set; }
  16. public bool IsUpdateEnd { get; private set; }
  17. public BodyCtrlData BodyCtrlData
  18. {
  19. get
  20. {
  21. return this.m_BodyCtrlData;
  22. }
  23. }
  24. public TBody TgtBody
  25. {
  26. get
  27. {
  28. return this.m_TgtBody;
  29. }
  30. }
  31. public Maid TgtMaid
  32. {
  33. get
  34. {
  35. return this.m_TgtBody.maid;
  36. }
  37. }
  38. public FullBodyBipedIK FullbodyIK
  39. {
  40. get
  41. {
  42. return this.m_FullbodyIK;
  43. }
  44. }
  45. public Transform IKTgtRoot
  46. {
  47. get
  48. {
  49. return this.m_IKTgtRoot;
  50. }
  51. }
  52. public IKEffector BodyEffector
  53. {
  54. get
  55. {
  56. return this.m_FullbodyIK.solver.bodyEffector;
  57. }
  58. }
  59. public Dictionary<string, IKCtrlData> strIKDataPair
  60. {
  61. get
  62. {
  63. return this.m_strIKDataPair;
  64. }
  65. }
  66. public bool IsIKExec
  67. {
  68. get
  69. {
  70. return this.m_strIKDataPair.Any((KeyValuePair<string, IKCtrlData> ik) => ik.Value.IsIKExec) && this.IKActive;
  71. }
  72. }
  73. private void Update()
  74. {
  75. this.IsUpdateEnd = false;
  76. if (this.BodyCtrlData.IsIKExec && this.IKActive)
  77. {
  78. this.TgtMaid.SetPos(this.BodyCtrlData.OrijinMaidPos);
  79. if (this.BodyCtrlData.DoAllOffset)
  80. {
  81. GameMain.Instance.CharacterMgr.SetCharaAllPos(this.BodyCtrlData.OrijinAllPos);
  82. }
  83. }
  84. }
  85. private void OnDestroy()
  86. {
  87. if (this.m_IKTgtRoot)
  88. {
  89. UnityEngine.Object.Destroy(this.m_IKTgtRoot);
  90. }
  91. }
  92. private BodyCtrlData SafeAddBodyCtrlData(string key_str)
  93. {
  94. BodyCtrlData bodyCtrlData = new BodyCtrlData(this);
  95. if (this.m_strIKDataPair.ContainsKey(key_str))
  96. {
  97. this.m_strIKDataPair[key_str] = bodyCtrlData;
  98. }
  99. else
  100. {
  101. this.m_strIKDataPair.Add(key_str, bodyCtrlData);
  102. }
  103. this.m_BodyCtrlData = bodyCtrlData;
  104. return (BodyCtrlData)this.m_strIKDataPair[key_str];
  105. }
  106. private BipedIKCtrlData SafeAddFullbodyIKData(string key_str, IKEffector effector, FBIKChain chain, IKMappingLimb ik_mapping, IKEffector sub_effector, bool use_old = false)
  107. {
  108. BipedIKCtrlData value = new BipedIKCtrlData(effector, chain, ik_mapping, this, effector.bone, sub_effector, use_old);
  109. if (this.m_strIKDataPair.ContainsKey(key_str))
  110. {
  111. this.m_strIKDataPair[key_str] = value;
  112. }
  113. else
  114. {
  115. this.m_strIKDataPair.Add(key_str, value);
  116. }
  117. this.m_FullbodyDataList.Add((BipedIKCtrlData)this.m_strIKDataPair[key_str]);
  118. return (BipedIKCtrlData)this.m_strIKDataPair[key_str];
  119. }
  120. private CCDIKCtrlData SafeAddCCDIKData(string key_str, ref CCDIK ccd_ik, bool weight_fade, bool attach_ik, IKManager.BoneType boneType, bool affect_height)
  121. {
  122. if (ccd_ik)
  123. {
  124. UnityEngine.Object.DestroyImmediate(ccd_ik);
  125. }
  126. ccd_ik = this.IKTgtRoot.gameObject.AddComponent<CCDIK>();
  127. CCDIKCtrlData value = (!affect_height) ? new CCDIKCtrlData(ccd_ik, this.GetChainBonesToInit(boneType), this, weight_fade, attach_ik) : new HeightIKCtrlData(ccd_ik, this.GetChainBonesToInit(boneType), this, weight_fade, attach_ik);
  128. if (this.m_strIKDataPair.ContainsKey(key_str))
  129. {
  130. this.m_strIKDataPair[key_str] = value;
  131. }
  132. else
  133. {
  134. this.m_strIKDataPair.Add(key_str, value);
  135. }
  136. this.m_CCDDataList.Add((CCDIKCtrlData)this.m_strIKDataPair[key_str]);
  137. return (CCDIKCtrlData)this.m_strIKDataPair[key_str];
  138. }
  139. private FABRIKCtrlData SafeAddFABRIKData(string key_str, ref FABRIK fabr_ik, bool weight_fade, bool attach_ik, IKManager.BoneType boneType, bool affect_height)
  140. {
  141. if (fabr_ik)
  142. {
  143. UnityEngine.Object.DestroyImmediate(fabr_ik);
  144. }
  145. fabr_ik = this.IKTgtRoot.gameObject.AddComponent<FABRIK>();
  146. FABRIKCtrlData value = new FABRIKCtrlData(fabr_ik, this.GetChainBonesToInit(boneType), this, attach_ik);
  147. if (this.m_strIKDataPair.ContainsKey(key_str))
  148. {
  149. this.m_strIKDataPair[key_str] = value;
  150. }
  151. else
  152. {
  153. this.m_strIKDataPair.Add(key_str, value);
  154. }
  155. this.m_FABRDataList.Add((FABRIKCtrlData)this.m_strIKDataPair[key_str]);
  156. return (FABRIKCtrlData)this.m_strIKDataPair[key_str];
  157. }
  158. public void LateIKUpdate()
  159. {
  160. this.IKUpdate();
  161. this.TgtBody.AutoTwist();
  162. for (int i = 0; i < this.TgtBody.goSlot.Count; i++)
  163. {
  164. if (this.TgtBody.goSlot[i].obj != null)
  165. {
  166. this.TgtBody.goSlot[i].CopyTrans();
  167. }
  168. this.TgtBody.goSlot[i].Update();
  169. }
  170. }
  171. public void Init()
  172. {
  173. this.m_TgtBody = base.GetComponent<TBody>();
  174. if (!this.m_IKTgtRoot)
  175. {
  176. this.m_IKTgtRoot = new GameObject("IK Target Root").transform;
  177. this.m_IKTgtRoot.SetParent(this.m_TgtBody.m_trBones, false);
  178. }
  179. if (!this.TgtMaid.boMAN)
  180. {
  181. this.m_STRoot = this.m_TgtBody.m_trBones.Find("ST_Root");
  182. }
  183. if (this.m_FullbodyIK)
  184. {
  185. UnityEngine.Object.DestroyImmediate(this.m_FullbodyIK);
  186. }
  187. this.m_FullbodyIK = this.m_IKTgtRoot.gameObject.AddComponent<FullBodyBipedIK>();
  188. this.m_Mouth = new GameObject("Mouth").transform;
  189. this.m_Mouth.SetParent(this.TgtBody.trsHead, false);
  190. this.m_Mouth.localEulerAngles = new Vector3(-90f, 90f, 0f);
  191. if (!this.TgtMaid.boMAN)
  192. {
  193. this.m_NippleL = new GameObject("Nipple_L").transform;
  194. this.m_NippleL.SetParent(CMT.SearchObjName(this.TgtBody.m_trBones, "Mune_L_sub", true), false);
  195. this.m_NippleR = new GameObject("Nipple_R").transform;
  196. this.m_NippleR.SetParent(CMT.SearchObjName(this.TgtBody.m_trBones, "Mune_R_sub", true), false);
  197. }
  198. this.m_FullbodyDataList.Clear();
  199. this.m_CCDDataList.Clear();
  200. this.m_ForearmCalfIKList.Clear();
  201. this.m_FABRDataList.Clear();
  202. this.m_IKBoneDic = IKManager.CreateBoneDic(this.TgtMaid);
  203. this.m_FullbodyIK.references.root = this.m_TgtBody.m_trBones;
  204. this.m_FullbodyIK.references.pelvis = this.GetIKBone(IKManager.BoneType.Root);
  205. if (!this.TgtMaid.boMAN)
  206. {
  207. this.m_FullbodyIK.references.spine = new Transform[]
  208. {
  209. this.m_IKBoneDic[IKManager.BoneType.Spine0].Value.transform,
  210. this.m_IKBoneDic[IKManager.BoneType.Spine3].Value.transform
  211. };
  212. }
  213. else
  214. {
  215. this.m_FullbodyIK.references.spine = new Transform[]
  216. {
  217. this.m_IKBoneDic[IKManager.BoneType.Spine0].Value.transform,
  218. this.m_IKBoneDic[IKManager.BoneType.Spine2].Value.transform
  219. };
  220. }
  221. this.m_FullbodyIK.references.head = this.GetIKBone(IKManager.BoneType.Head);
  222. this.m_FullbodyIK.references.leftUpperArm = this.GetIKBone(IKManager.BoneType.UpperArm_L);
  223. this.m_FullbodyIK.references.leftForearm = this.GetIKBone(IKManager.BoneType.Forearm_L);
  224. this.m_FullbodyIK.references.leftHand = this.GetIKBone(IKManager.BoneType.Hand_L);
  225. this.m_FullbodyIK.references.rightUpperArm = this.GetIKBone(IKManager.BoneType.UpperArm_R);
  226. this.m_FullbodyIK.references.rightForearm = this.GetIKBone(IKManager.BoneType.Forearm_R);
  227. this.m_FullbodyIK.references.rightHand = this.GetIKBone(IKManager.BoneType.Hand_R);
  228. this.m_FullbodyIK.references.leftThigh = this.GetIKBone(IKManager.BoneType.Thigh_L);
  229. this.m_FullbodyIK.references.leftCalf = this.GetIKBone(IKManager.BoneType.Calf_L);
  230. this.m_FullbodyIK.references.leftFoot = this.GetIKBone(IKManager.BoneType.Foot_L);
  231. this.m_FullbodyIK.references.rightThigh = this.GetIKBone(IKManager.BoneType.Thigh_R);
  232. this.m_FullbodyIK.references.rightCalf = this.GetIKBone(IKManager.BoneType.Calf_R);
  233. this.m_FullbodyIK.references.rightFoot = this.GetIKBone(IKManager.BoneType.Foot_R);
  234. this.m_FullbodyIK.solver.SetToReferences(this.m_FullbodyIK.references, null);
  235. this.m_FullbodyIK.fixTransforms = false;
  236. foreach (IKEffector ikeffector in this.m_FullbodyIK.solver.effectors)
  237. {
  238. ikeffector.positionWeight = 0f;
  239. ikeffector.rotationWeight = 0f;
  240. }
  241. foreach (FBIKChain fbikchain in this.m_FullbodyIK.solver.chain)
  242. {
  243. fbikchain.bendConstraint.weight = 0f;
  244. }
  245. this.m_BodyCtrlData = this.SafeAddBodyCtrlData("体全体");
  246. this.SafeAddFullbodyIKData("左手", this.m_FullbodyIK.solver.leftHandEffector, this.m_FullbodyIK.solver.leftArmChain, this.m_FullbodyIK.solver.leftArmMapping, this.m_FullbodyIK.solver.leftShoulderEffector, true);
  247. this.SafeAddFullbodyIKData("右手", this.m_FullbodyIK.solver.rightHandEffector, this.m_FullbodyIK.solver.rightArmChain, this.m_FullbodyIK.solver.rightArmMapping, this.m_FullbodyIK.solver.rightShoulderEffector, true);
  248. this.SafeAddFullbodyIKData("左足", this.m_FullbodyIK.solver.leftFootEffector, this.m_FullbodyIK.solver.leftLegChain, this.m_FullbodyIK.solver.leftLegMapping, this.m_FullbodyIK.solver.leftThighEffector, false);
  249. this.SafeAddFullbodyIKData("右足", this.m_FullbodyIK.solver.rightFootEffector, this.m_FullbodyIK.solver.rightLegChain, this.m_FullbodyIK.solver.rightLegMapping, this.m_FullbodyIK.solver.rightThighEffector, false);
  250. this.SafeAddCCDIKData("口", ref this.m_MouthIK, true, true, IKManager.BoneType.Mouth, true);
  251. this.m_ForearmCalfIKList.Add(this.SafeAddFABRIKData("右肘", ref this.m_ForearmRIK, false, true, IKManager.BoneType.Forearm_R, false));
  252. this.m_ForearmCalfIKList.Add(this.SafeAddFABRIKData("左肘", ref this.m_ForearmLIK, false, true, IKManager.BoneType.Forearm_L, false));
  253. this.m_ForearmCalfIKList.Add(this.SafeAddFABRIKData("右膝", ref this.m_CalfRIK, false, true, IKManager.BoneType.Calf_R, false));
  254. this.m_ForearmCalfIKList.Add(this.SafeAddFABRIKData("左膝", ref this.m_CalfLIK, false, true, IKManager.BoneType.Calf_L, false));
  255. if (!this.BodyTarget)
  256. {
  257. Transform transform = this.m_IKTgtRoot.Find(this.BodyEffector.bone.name);
  258. transform = new GameObject(this.BodyEffector.bone.name).transform;
  259. transform.SetParent(this.m_IKTgtRoot, false);
  260. this.BodyTarget = new GameObject("IKTarget").transform;
  261. this.BodyTarget.SetParent(transform, false);
  262. }
  263. this.BodyEffector.target = this.BodyTarget;
  264. this.m_FullbodyIK.enabled = false;
  265. }
  266. public void IKUpdate()
  267. {
  268. if (this.TgtMaid.boMAN)
  269. {
  270. this.m_Mouth.localPosition = new Vector3(-0.013f, 0.1115f, 0f);
  271. }
  272. else
  273. {
  274. this.AttachPointTransCpy(this.m_Mouth, "head", "歯", false);
  275. this.AttachPointTransCpy(this.m_NippleL, "body", "乳首左", false);
  276. this.AttachPointTransCpy(this.m_NippleR, "body", "乳首右", false);
  277. }
  278. this.BodyEffector.positionWeight = 0f;
  279. this.BodyTarget.position = this.BodyEffector.bone.position;
  280. this.DoHeightCover = false;
  281. this.IsUpdateLate = false;
  282. if (!this.IKActive)
  283. {
  284. return;
  285. }
  286. bool flag = false;
  287. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  288. {
  289. ikctrlData.ApplyIKSetting();
  290. flag |= ikctrlData.IsIKExec;
  291. }
  292. if (!this.IsUpdateLate && (flag || this.AllForceIK))
  293. {
  294. this.SolverUpdate();
  295. }
  296. }
  297. public void SolverUpdate()
  298. {
  299. this.IsUpdateEnd = true;
  300. Action postSolverUpdate = this.PostSolverUpdate;
  301. this.PostSolverUpdate = null;
  302. if (this.BodyCtrlData.IsIKExec)
  303. {
  304. this.BodyCtrlData.Update();
  305. }
  306. bool flag = this.m_FullbodyDataList.Any((BipedIKCtrlData data) => data.IsIKExec && !data.OldIkExec);
  307. if (this.m_MouthIKData.IsIKExec)
  308. {
  309. this.m_MouthIKData.Update();
  310. }
  311. flag |= (this.BodyEffector.positionWeight == 1f);
  312. if (flag)
  313. {
  314. Vector3 position = this.m_FullbodyIK.references.spine[0].InverseTransformPoint(this.m_FullbodyIK.references.spine[1].position);
  315. this.m_FullbodyIK.solver.Update();
  316. if (this.GetIKData("右足").IsIKExec || this.GetIKData("左足").IsIKExec)
  317. {
  318. this.m_FullbodyIK.references.spine[1].position = this.m_FullbodyIK.references.spine[0].TransformPoint(position);
  319. }
  320. }
  321. for (int i = 0; i < this.m_ForearmCalfIKList.Count; i++)
  322. {
  323. if (this.m_ForearmCalfIKList[i].IsIKExec)
  324. {
  325. this.m_ForearmCalfIKList[i].Update();
  326. }
  327. }
  328. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  329. {
  330. ikctrlData.LateUpdate();
  331. }
  332. if (postSolverUpdate != null)
  333. {
  334. postSolverUpdate();
  335. }
  336. }
  337. public void AttachPointTransCpy(Transform trans, string slot_name, string attach_name, bool scale_cpy = false)
  338. {
  339. int slotNo = this.TgtBody.GetSlotNo(slot_name);
  340. if (this.TgtBody.goSlot[slotNo].morph == null)
  341. {
  342. return;
  343. }
  344. Vector3 position;
  345. Quaternion rotation;
  346. Vector3 localScale;
  347. this.TgtBody.goSlot[slotNo].morph.GetAttachPoint(attach_name, out position, out rotation, out localScale, false);
  348. trans.position = position;
  349. trans.rotation = rotation;
  350. if (scale_cpy)
  351. {
  352. trans.localScale = localScale;
  353. }
  354. }
  355. public Transform GetIKBone(IKManager.BoneType boneType)
  356. {
  357. return (!this.m_IKBoneDic.ContainsKey(boneType)) ? null : this.m_IKBoneDic[boneType].Value.transform;
  358. }
  359. public Transform[] GetChainBonesToInit(IKManager.BoneType boneType)
  360. {
  361. Transform[] result = new Transform[0];
  362. switch (boneType)
  363. {
  364. case IKManager.BoneType.Forearm_R:
  365. result = new Transform[]
  366. {
  367. this.GetIKBone(IKManager.BoneType.Clavicle_R),
  368. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  369. this.GetIKBone(IKManager.BoneType.Forearm_R)
  370. };
  371. break;
  372. case IKManager.BoneType.Hand_R:
  373. result = new Transform[]
  374. {
  375. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  376. this.GetIKBone(IKManager.BoneType.Forearm_R),
  377. this.GetIKBone(IKManager.BoneType.Hand_R)
  378. };
  379. break;
  380. default:
  381. switch (boneType)
  382. {
  383. case IKManager.BoneType.Head:
  384. if (!this.TgtMaid.boMAN)
  385. {
  386. result = new Transform[]
  387. {
  388. this.GetIKBone(IKManager.BoneType.Spine0),
  389. this.GetIKBone(IKManager.BoneType.Spine1),
  390. this.GetIKBone(IKManager.BoneType.Spine2),
  391. this.GetIKBone(IKManager.BoneType.Spine3),
  392. this.GetIKBone(IKManager.BoneType.Neck),
  393. this.GetIKBone(IKManager.BoneType.Head)
  394. };
  395. }
  396. else
  397. {
  398. result = new Transform[]
  399. {
  400. this.GetIKBone(IKManager.BoneType.Spine0),
  401. this.GetIKBone(IKManager.BoneType.Spine1),
  402. this.GetIKBone(IKManager.BoneType.Spine2),
  403. this.GetIKBone(IKManager.BoneType.Neck),
  404. this.GetIKBone(IKManager.BoneType.Head)
  405. };
  406. }
  407. break;
  408. case IKManager.BoneType.Neck:
  409. if (!this.TgtMaid.boMAN)
  410. {
  411. result = new Transform[]
  412. {
  413. this.GetIKBone(IKManager.BoneType.Spine0),
  414. this.GetIKBone(IKManager.BoneType.Spine1),
  415. this.GetIKBone(IKManager.BoneType.Spine2),
  416. this.GetIKBone(IKManager.BoneType.Spine3),
  417. this.GetIKBone(IKManager.BoneType.Neck)
  418. };
  419. }
  420. else
  421. {
  422. result = new Transform[]
  423. {
  424. this.GetIKBone(IKManager.BoneType.Spine0),
  425. this.GetIKBone(IKManager.BoneType.Spine1),
  426. this.GetIKBone(IKManager.BoneType.Spine2),
  427. this.GetIKBone(IKManager.BoneType.Neck)
  428. };
  429. }
  430. break;
  431. default:
  432. switch (boneType)
  433. {
  434. case IKManager.BoneType.Mouth:
  435. if (!this.TgtMaid.boMAN)
  436. {
  437. result = new Transform[]
  438. {
  439. this.GetIKBone(IKManager.BoneType.Spine0),
  440. this.GetIKBone(IKManager.BoneType.Spine1),
  441. this.GetIKBone(IKManager.BoneType.Spine2),
  442. this.GetIKBone(IKManager.BoneType.Spine3),
  443. this.GetIKBone(IKManager.BoneType.Neck),
  444. this.GetIKBone(IKManager.BoneType.Head),
  445. this.GetIKBone(IKManager.BoneType.Mouth)
  446. };
  447. }
  448. else
  449. {
  450. result = new Transform[]
  451. {
  452. this.GetIKBone(IKManager.BoneType.Spine0),
  453. this.GetIKBone(IKManager.BoneType.Spine1),
  454. this.GetIKBone(IKManager.BoneType.Spine2),
  455. this.GetIKBone(IKManager.BoneType.Neck),
  456. this.GetIKBone(IKManager.BoneType.Head),
  457. this.GetIKBone(IKManager.BoneType.Mouth)
  458. };
  459. }
  460. break;
  461. case IKManager.BoneType.Nipple_L:
  462. if (!this.TgtMaid.boMAN)
  463. {
  464. result = new Transform[]
  465. {
  466. this.GetIKBone(IKManager.BoneType.Bust_L),
  467. this.GetIKBone(IKManager.BoneType.Bust_L_Sub),
  468. this.GetIKBone(IKManager.BoneType.Nipple_L)
  469. };
  470. }
  471. break;
  472. case IKManager.BoneType.Nipple_R:
  473. if (!this.TgtMaid.boMAN)
  474. {
  475. result = new Transform[]
  476. {
  477. this.GetIKBone(IKManager.BoneType.Bust_R),
  478. this.GetIKBone(IKManager.BoneType.Bust_R_Sub),
  479. this.GetIKBone(IKManager.BoneType.Nipple_R)
  480. };
  481. }
  482. break;
  483. }
  484. break;
  485. case IKManager.BoneType.Spine2:
  486. result = new Transform[]
  487. {
  488. this.GetIKBone(IKManager.BoneType.Spine0),
  489. this.GetIKBone(IKManager.BoneType.Spine1),
  490. this.GetIKBone(IKManager.BoneType.Spine2)
  491. };
  492. break;
  493. case IKManager.BoneType.Spine3:
  494. if (!this.TgtMaid.boMAN)
  495. {
  496. result = new Transform[]
  497. {
  498. this.GetIKBone(IKManager.BoneType.Spine0),
  499. this.GetIKBone(IKManager.BoneType.Spine1),
  500. this.GetIKBone(IKManager.BoneType.Spine2),
  501. this.GetIKBone(IKManager.BoneType.Spine3)
  502. };
  503. }
  504. break;
  505. }
  506. break;
  507. case IKManager.BoneType.Calf_R:
  508. result = new Transform[]
  509. {
  510. this.GetIKBone(IKManager.BoneType.Thigh_R),
  511. this.GetIKBone(IKManager.BoneType.Calf_R)
  512. };
  513. break;
  514. case IKManager.BoneType.Foot_R:
  515. result = new Transform[]
  516. {
  517. this.GetIKBone(IKManager.BoneType.Thigh_R),
  518. this.GetIKBone(IKManager.BoneType.Calf_R),
  519. this.GetIKBone(IKManager.BoneType.Foot_R)
  520. };
  521. break;
  522. case IKManager.BoneType.Forearm_L:
  523. result = new Transform[]
  524. {
  525. this.GetIKBone(IKManager.BoneType.Clavicle_L),
  526. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  527. this.GetIKBone(IKManager.BoneType.Forearm_L)
  528. };
  529. break;
  530. case IKManager.BoneType.Hand_L:
  531. result = new Transform[]
  532. {
  533. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  534. this.GetIKBone(IKManager.BoneType.Forearm_L),
  535. this.GetIKBone(IKManager.BoneType.Hand_L)
  536. };
  537. break;
  538. case IKManager.BoneType.Calf_L:
  539. result = new Transform[]
  540. {
  541. this.GetIKBone(IKManager.BoneType.Thigh_L),
  542. this.GetIKBone(IKManager.BoneType.Calf_L)
  543. };
  544. break;
  545. case IKManager.BoneType.Foot_L:
  546. result = new Transform[]
  547. {
  548. this.GetIKBone(IKManager.BoneType.Thigh_L),
  549. this.GetIKBone(IKManager.BoneType.Calf_L),
  550. this.GetIKBone(IKManager.BoneType.Foot_L)
  551. };
  552. break;
  553. }
  554. return result;
  555. }
  556. public IKCtrlData GetIKData(string tag_name)
  557. {
  558. if (this.m_strIKDataPair.ContainsKey(tag_name))
  559. {
  560. return this.m_strIKDataPair[tag_name];
  561. }
  562. return null;
  563. }
  564. public T GetIKData<T>(string tag_name) where T : IKCtrlData
  565. {
  566. if (this.m_strIKDataPair.ContainsKey(tag_name) && this.m_strIKDataPair[tag_name] is T)
  567. {
  568. return this.m_strIKDataPair[tag_name] as T;
  569. }
  570. return (T)((object)null);
  571. }
  572. public Transform GetSTFlagObj(string name)
  573. {
  574. return this.m_STRoot.Find(name);
  575. }
  576. [SerializeField]
  577. private TBody m_TgtBody;
  578. [SerializeField]
  579. private Transform m_IKTgtRoot;
  580. [SerializeField]
  581. private Transform m_STRoot;
  582. [SerializeField]
  583. private FullBodyBipedIK m_FullbodyIK;
  584. private CCDIK m_MouthIK;
  585. private CCDIK m_MuneLIK;
  586. private CCDIK m_MuneRIK;
  587. private FABRIK m_ForearmLIK;
  588. private FABRIK m_ForearmRIK;
  589. private FABRIK m_CalfLIK;
  590. private FABRIK m_CalfRIK;
  591. private Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>> m_IKBoneDic = new Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>>();
  592. [SerializeField]
  593. private BodyCtrlData m_BodyCtrlData;
  594. [SerializeField]
  595. private List<BipedIKCtrlData> m_FullbodyDataList = new List<BipedIKCtrlData>();
  596. [SerializeField]
  597. private List<CCDIKCtrlData> m_CCDDataList = new List<CCDIKCtrlData>();
  598. [SerializeField]
  599. private List<FABRIKCtrlData> m_FABRDataList = new List<FABRIKCtrlData>();
  600. private Transform m_NippleL;
  601. private Transform m_NippleR;
  602. private Transform m_Mouth;
  603. private Dictionary<string, IKCtrlData> m_strIKDataPair = new Dictionary<string, IKCtrlData>();
  604. private List<FABRIKCtrlData> m_ForearmCalfIKList = new List<FABRIKCtrlData>();
  605. public bool IKActive = true;
  606. public bool DoHeightCover;
  607. public bool IsUpdateLate;
  608. public Action PostSolverUpdate;
  609. public bool AllForceIK;
  610. }