FullBodyIKCtrl.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  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. public Transform BodyTarget { get; private set; }
  9. public bool IsUpdateEnd { get; private set; }
  10. public BodyCtrlData BodyCtrlData
  11. {
  12. get
  13. {
  14. return this.m_BodyCtrlData;
  15. }
  16. }
  17. public TBody TgtBody
  18. {
  19. get
  20. {
  21. return this.m_TgtBody;
  22. }
  23. }
  24. public Maid TgtMaid
  25. {
  26. get
  27. {
  28. return this.m_TgtBody.maid;
  29. }
  30. }
  31. public FullBodyBipedIK FullbodyIK
  32. {
  33. get
  34. {
  35. return this.m_FullbodyIK;
  36. }
  37. }
  38. public Transform IKTgtRoot
  39. {
  40. get
  41. {
  42. return this.m_IKTgtRoot;
  43. }
  44. }
  45. public IKEffector BodyEffector
  46. {
  47. get
  48. {
  49. return this.m_FullbodyIK.solver.bodyEffector;
  50. }
  51. }
  52. public Dictionary<string, IKCtrlData> strIKDataPair
  53. {
  54. get
  55. {
  56. return this.m_strIKDataPair;
  57. }
  58. }
  59. public bool IsIKExec
  60. {
  61. get
  62. {
  63. return this.m_strIKDataPair.Any((KeyValuePair<string, IKCtrlData> ik) => ik.Value.IsIKExec) && this.IKActive;
  64. }
  65. }
  66. public bool IsSelfIKAttach
  67. {
  68. get
  69. {
  70. return this.m_strIKDataPair.Any((KeyValuePair<string, IKCtrlData> ik) => ik.Value.IsSelfIKAttach) && 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.GetIKData<BipedIKCtrlData>("左足", false).Chain.pull = 0f;
  256. this.GetIKData<BipedIKCtrlData>("右足", false).Chain.pull = 0f;
  257. if (!this.BodyTarget)
  258. {
  259. Transform transform = this.m_IKTgtRoot.Find(this.BodyEffector.bone.name);
  260. transform = new GameObject(this.BodyEffector.bone.name).transform;
  261. transform.SetParent(this.m_IKTgtRoot, false);
  262. this.BodyTarget = new GameObject("IKTarget").transform;
  263. this.BodyTarget.SetParent(transform, false);
  264. }
  265. this.BodyEffector.target = this.BodyTarget;
  266. this.BodyEffector.effectChildNodes = false;
  267. this.m_FullbodyIK.enabled = false;
  268. }
  269. public void IKUpdate()
  270. {
  271. this.BodyEffector.positionWeight = 0f;
  272. this.BodyTarget.position = this.BodyEffector.bone.position;
  273. this.DoHeightCover = false;
  274. this.IsUpdateLate = false;
  275. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  276. {
  277. ikctrlData.ApplyIKSetting();
  278. }
  279. if (!this.IsUpdateLate && (this.IsIKExec || this.AllForceIK))
  280. {
  281. this.SolverUpdate();
  282. }
  283. }
  284. public void SolverUpdate()
  285. {
  286. this.IsUpdateEnd = true;
  287. Action postSolverUpdate = this.PostSolverUpdate;
  288. this.PostSolverUpdate = null;
  289. if (this.IKActive)
  290. {
  291. if (this.BodyCtrlData.IsIKExec)
  292. {
  293. this.BodyCtrlData.Update();
  294. }
  295. bool flag = this.m_FullbodyDataList.Any((BipedIKCtrlData data) => data.IsIKExec && !data.OldIkExec);
  296. flag |= (this.BodyEffector.positionWeight == 1f);
  297. if (flag)
  298. {
  299. Vector3 localPosition = this.m_FullbodyIK.references.spine[1].localPosition;
  300. this.m_FullbodyIK.solver.Update();
  301. this.m_FullbodyIK.references.spine[1].localPosition = localPosition;
  302. }
  303. }
  304. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  305. {
  306. ikctrlData.LateUpdate();
  307. }
  308. if (this.IKActive && postSolverUpdate != null)
  309. {
  310. postSolverUpdate();
  311. }
  312. }
  313. public void AttachPointTransCpy(Transform trans, string slot_name, string attach_name, bool scale_cpy = false)
  314. {
  315. int slotNo = this.TgtBody.GetSlotNo(slot_name);
  316. if (this.TgtBody.goSlot[slotNo].morph == null)
  317. {
  318. return;
  319. }
  320. Vector3 position;
  321. Quaternion rotation;
  322. Vector3 localScale;
  323. this.TgtBody.goSlot[slotNo].morph.GetAttachPoint(attach_name, out position, out rotation, out localScale, false);
  324. trans.position = position;
  325. trans.rotation = rotation;
  326. if (scale_cpy)
  327. {
  328. trans.localScale = localScale;
  329. }
  330. }
  331. public Transform GetIKBone(IKManager.BoneType boneType)
  332. {
  333. return (!this.m_IKBoneDic.ContainsKey(boneType)) ? null : this.m_IKBoneDic[boneType].Value.transform;
  334. }
  335. public Transform[] GetChainBonesToInit(IKManager.BoneType boneType)
  336. {
  337. Transform[] result = new Transform[0];
  338. switch (boneType)
  339. {
  340. case IKManager.BoneType.Forearm_R:
  341. result = new Transform[]
  342. {
  343. this.GetIKBone(IKManager.BoneType.Clavicle_R),
  344. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  345. this.GetIKBone(IKManager.BoneType.Forearm_R)
  346. };
  347. break;
  348. case IKManager.BoneType.Hand_R:
  349. result = new Transform[]
  350. {
  351. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  352. this.GetIKBone(IKManager.BoneType.Forearm_R),
  353. this.GetIKBone(IKManager.BoneType.Hand_R)
  354. };
  355. break;
  356. default:
  357. switch (boneType)
  358. {
  359. case IKManager.BoneType.Head:
  360. if (!this.TgtMaid.boMAN)
  361. {
  362. result = new Transform[]
  363. {
  364. this.GetIKBone(IKManager.BoneType.Spine0),
  365. this.GetIKBone(IKManager.BoneType.Spine1),
  366. this.GetIKBone(IKManager.BoneType.Spine2),
  367. this.GetIKBone(IKManager.BoneType.Spine3),
  368. this.GetIKBone(IKManager.BoneType.Neck),
  369. this.GetIKBone(IKManager.BoneType.Head)
  370. };
  371. }
  372. else
  373. {
  374. result = new Transform[]
  375. {
  376. this.GetIKBone(IKManager.BoneType.Spine0),
  377. this.GetIKBone(IKManager.BoneType.Spine1),
  378. this.GetIKBone(IKManager.BoneType.Spine2),
  379. this.GetIKBone(IKManager.BoneType.Neck),
  380. this.GetIKBone(IKManager.BoneType.Head)
  381. };
  382. }
  383. break;
  384. case IKManager.BoneType.Neck:
  385. if (!this.TgtMaid.boMAN)
  386. {
  387. result = new Transform[]
  388. {
  389. this.GetIKBone(IKManager.BoneType.Spine0),
  390. this.GetIKBone(IKManager.BoneType.Spine1),
  391. this.GetIKBone(IKManager.BoneType.Spine2),
  392. this.GetIKBone(IKManager.BoneType.Spine3),
  393. this.GetIKBone(IKManager.BoneType.Neck)
  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. };
  405. }
  406. break;
  407. default:
  408. switch (boneType)
  409. {
  410. case IKManager.BoneType.Mouth:
  411. if (!this.TgtMaid.boMAN)
  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.Spine3),
  419. this.GetIKBone(IKManager.BoneType.Neck),
  420. this.GetIKBone(IKManager.BoneType.Head),
  421. this.GetIKBone(IKManager.BoneType.Mouth)
  422. };
  423. }
  424. else
  425. {
  426. result = new Transform[]
  427. {
  428. this.GetIKBone(IKManager.BoneType.Spine0),
  429. this.GetIKBone(IKManager.BoneType.Spine1),
  430. this.GetIKBone(IKManager.BoneType.Spine2),
  431. this.GetIKBone(IKManager.BoneType.Neck),
  432. this.GetIKBone(IKManager.BoneType.Head),
  433. this.GetIKBone(IKManager.BoneType.Mouth)
  434. };
  435. }
  436. break;
  437. case IKManager.BoneType.Nipple_L:
  438. if (!this.TgtMaid.boMAN)
  439. {
  440. result = new Transform[]
  441. {
  442. this.GetIKBone(IKManager.BoneType.Bust_L),
  443. this.GetIKBone(IKManager.BoneType.Bust_L_Sub),
  444. this.GetIKBone(IKManager.BoneType.Nipple_L)
  445. };
  446. }
  447. break;
  448. case IKManager.BoneType.Nipple_R:
  449. if (!this.TgtMaid.boMAN)
  450. {
  451. result = new Transform[]
  452. {
  453. this.GetIKBone(IKManager.BoneType.Bust_R),
  454. this.GetIKBone(IKManager.BoneType.Bust_R_Sub),
  455. this.GetIKBone(IKManager.BoneType.Nipple_R)
  456. };
  457. }
  458. break;
  459. }
  460. break;
  461. case IKManager.BoneType.Spine2:
  462. result = new Transform[]
  463. {
  464. this.GetIKBone(IKManager.BoneType.Spine0),
  465. this.GetIKBone(IKManager.BoneType.Spine1),
  466. this.GetIKBone(IKManager.BoneType.Spine2)
  467. };
  468. break;
  469. case IKManager.BoneType.Spine3:
  470. if (!this.TgtMaid.boMAN)
  471. {
  472. result = new Transform[]
  473. {
  474. this.GetIKBone(IKManager.BoneType.Spine0),
  475. this.GetIKBone(IKManager.BoneType.Spine1),
  476. this.GetIKBone(IKManager.BoneType.Spine2),
  477. this.GetIKBone(IKManager.BoneType.Spine3)
  478. };
  479. }
  480. break;
  481. }
  482. break;
  483. case IKManager.BoneType.Calf_R:
  484. result = new Transform[]
  485. {
  486. this.GetIKBone(IKManager.BoneType.Thigh_R),
  487. this.GetIKBone(IKManager.BoneType.Calf_R)
  488. };
  489. break;
  490. case IKManager.BoneType.Foot_R:
  491. result = new Transform[]
  492. {
  493. this.GetIKBone(IKManager.BoneType.Thigh_R),
  494. this.GetIKBone(IKManager.BoneType.Calf_R),
  495. this.GetIKBone(IKManager.BoneType.Foot_R)
  496. };
  497. break;
  498. case IKManager.BoneType.Forearm_L:
  499. result = new Transform[]
  500. {
  501. this.GetIKBone(IKManager.BoneType.Clavicle_L),
  502. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  503. this.GetIKBone(IKManager.BoneType.Forearm_L)
  504. };
  505. break;
  506. case IKManager.BoneType.Hand_L:
  507. result = new Transform[]
  508. {
  509. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  510. this.GetIKBone(IKManager.BoneType.Forearm_L),
  511. this.GetIKBone(IKManager.BoneType.Hand_L)
  512. };
  513. break;
  514. case IKManager.BoneType.Calf_L:
  515. result = new Transform[]
  516. {
  517. this.GetIKBone(IKManager.BoneType.Thigh_L),
  518. this.GetIKBone(IKManager.BoneType.Calf_L)
  519. };
  520. break;
  521. case IKManager.BoneType.Foot_L:
  522. result = new Transform[]
  523. {
  524. this.GetIKBone(IKManager.BoneType.Thigh_L),
  525. this.GetIKBone(IKManager.BoneType.Calf_L),
  526. this.GetIKBone(IKManager.BoneType.Foot_L)
  527. };
  528. break;
  529. }
  530. return result;
  531. }
  532. public IKCtrlData GetIKData(string tag_name, bool flagcheck = false)
  533. {
  534. if (this.m_strIKDataPair.ContainsKey(tag_name))
  535. {
  536. return this.m_strIKDataPair[tag_name];
  537. }
  538. if (this.m_ForearmCalfIKList.ContainsKey(tag_name))
  539. {
  540. if (flagcheck)
  541. {
  542. this.m_ForearmCalfIKList[tag_name].IsBendIK = true;
  543. }
  544. return this.m_ForearmCalfIKList[tag_name];
  545. }
  546. if (this.m_SholderThighIKList.ContainsKey(tag_name))
  547. {
  548. if (flagcheck)
  549. {
  550. this.m_SholderThighIKList[tag_name].IsRootIK = true;
  551. }
  552. return this.m_SholderThighIKList[tag_name];
  553. }
  554. return null;
  555. }
  556. public T GetIKData<T>(string tag_name, bool flagcheck = false) where T : IKCtrlData
  557. {
  558. IKCtrlData ikdata = this.GetIKData(tag_name, flagcheck);
  559. if (ikdata != null && ikdata is T)
  560. {
  561. return ikdata as T;
  562. }
  563. return (T)((object)null);
  564. }
  565. public Transform GetSTFlagObj(string name)
  566. {
  567. if (this.m_NameFlagObjpair.ContainsKey(name))
  568. {
  569. return this.m_NameFlagObjpair[name];
  570. }
  571. Transform transform = this.m_STRoot.Find(name);
  572. if (!transform)
  573. {
  574. transform = this.TgtBody.GetBone(name);
  575. if (!transform)
  576. {
  577. Debug.LogErrorFormat("{0}は存在しません", new object[]
  578. {
  579. name
  580. });
  581. return null;
  582. }
  583. }
  584. this.m_NameFlagObjpair.Add(name, transform);
  585. return transform;
  586. }
  587. [SerializeField]
  588. private TBody m_TgtBody;
  589. [SerializeField]
  590. private Transform m_IKTgtRoot;
  591. [SerializeField]
  592. private Transform m_STRoot;
  593. [SerializeField]
  594. private FullBodyBipedIK m_FullbodyIK;
  595. private CCDIK m_MouthIK;
  596. private CCDIK m_MuneLIK;
  597. private CCDIK m_MuneRIK;
  598. private FABRIK m_ForearmLIK;
  599. private FABRIK m_ForearmRIK;
  600. private FABRIK m_CalfLIK;
  601. private FABRIK m_CalfRIK;
  602. private Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>> m_IKBoneDic = new Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>>();
  603. [SerializeField]
  604. private BodyCtrlData m_BodyCtrlData;
  605. [SerializeField]
  606. private List<BipedIKCtrlData> m_FullbodyDataList = new List<BipedIKCtrlData>();
  607. [SerializeField]
  608. private List<CCDIKCtrlData> m_CCDDataList = new List<CCDIKCtrlData>();
  609. [SerializeField]
  610. private List<FABRIKCtrlData> m_FABRDataList = new List<FABRIKCtrlData>();
  611. private Transform m_NippleL;
  612. private Transform m_NippleR;
  613. private Transform m_Mouth;
  614. private Dictionary<string, IKCtrlData> m_strIKDataPair = new Dictionary<string, IKCtrlData>();
  615. private Dictionary<string, BipedIKCtrlData> m_ForearmCalfIKList = new Dictionary<string, BipedIKCtrlData>();
  616. private Dictionary<string, BipedIKCtrlData> m_SholderThighIKList = new Dictionary<string, BipedIKCtrlData>();
  617. private Dictionary<string, Transform> m_NameFlagObjpair = new Dictionary<string, Transform>();
  618. public bool IKActive = true;
  619. public bool DoHeightCover;
  620. public bool IsUpdateLate;
  621. public Action PostSolverUpdate;
  622. public bool AllForceIK;
  623. public float BlendTime = 0.5f;
  624. }