FullBodyIKCtrl.cs 20 KB

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