FullBodyIKCtrl.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  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_SpineLength = (this.m_FullbodyIK.references.spine[0].position - this.m_FullbodyIK.references.spine[1].position).magnitude;
  227. this.m_FullbodyIK.references.head = this.GetIKBone(IKManager.BoneType.Head);
  228. this.m_FullbodyIK.references.leftUpperArm = this.GetIKBone(IKManager.BoneType.UpperArm_L);
  229. this.m_FullbodyIK.references.leftForearm = this.GetIKBone(IKManager.BoneType.Forearm_L);
  230. this.m_FullbodyIK.references.leftHand = this.GetIKBone(IKManager.BoneType.Hand_L);
  231. this.m_FullbodyIK.references.rightUpperArm = this.GetIKBone(IKManager.BoneType.UpperArm_R);
  232. this.m_FullbodyIK.references.rightForearm = this.GetIKBone(IKManager.BoneType.Forearm_R);
  233. this.m_FullbodyIK.references.rightHand = this.GetIKBone(IKManager.BoneType.Hand_R);
  234. this.m_FullbodyIK.references.leftThigh = this.GetIKBone(IKManager.BoneType.Thigh_L);
  235. this.m_FullbodyIK.references.leftCalf = this.GetIKBone(IKManager.BoneType.Calf_L);
  236. this.m_FullbodyIK.references.leftFoot = this.GetIKBone(IKManager.BoneType.Foot_L);
  237. this.m_FullbodyIK.references.rightThigh = this.GetIKBone(IKManager.BoneType.Thigh_R);
  238. this.m_FullbodyIK.references.rightCalf = this.GetIKBone(IKManager.BoneType.Calf_R);
  239. this.m_FullbodyIK.references.rightFoot = this.GetIKBone(IKManager.BoneType.Foot_R);
  240. this.m_FullbodyIK.solver.SetToReferences(this.m_FullbodyIK.references, null);
  241. this.m_FullbodyIK.fixTransforms = false;
  242. foreach (IKEffector ikeffector in this.m_FullbodyIK.solver.effectors)
  243. {
  244. ikeffector.positionWeight = 0f;
  245. ikeffector.rotationWeight = 0f;
  246. }
  247. foreach (FBIKChain fbikchain in this.m_FullbodyIK.solver.chain)
  248. {
  249. fbikchain.bendConstraint.weight = 0f;
  250. }
  251. this.m_BodyCtrlData = this.SafeAddBodyCtrlData("体全体");
  252. this.SafeAddFullbodyIKData("左手", "左肘", "左肩", this.m_FullbodyIK.solver.leftHandEffector, this.m_FullbodyIK.solver.leftArmChain, this.m_FullbodyIK.solver.leftArmMapping, this.m_FullbodyIK.solver.leftShoulderEffector, true);
  253. this.SafeAddFullbodyIKData("右手", "右肘", "右肩", this.m_FullbodyIK.solver.rightHandEffector, this.m_FullbodyIK.solver.rightArmChain, this.m_FullbodyIK.solver.rightArmMapping, this.m_FullbodyIK.solver.rightShoulderEffector, true);
  254. this.SafeAddFullbodyIKData("左足", "左膝", "左腿", this.m_FullbodyIK.solver.leftFootEffector, this.m_FullbodyIK.solver.leftLegChain, this.m_FullbodyIK.solver.leftLegMapping, this.m_FullbodyIK.solver.leftThighEffector, false);
  255. this.SafeAddFullbodyIKData("右足", "右膝", "右腿", this.m_FullbodyIK.solver.rightFootEffector, this.m_FullbodyIK.solver.rightLegChain, this.m_FullbodyIK.solver.rightLegMapping, this.m_FullbodyIK.solver.rightThighEffector, false);
  256. this.GetIKData<BipedIKCtrlData>("左足", false).Chain.pull = 0f;
  257. this.GetIKData<BipedIKCtrlData>("右足", false).Chain.pull = 0f;
  258. this.SafeAddCCDIKData("口", ref this.m_MouthIK, true, true, IKManager.BoneType.Mouth, true);
  259. if (!this.BodyTarget)
  260. {
  261. Transform transform = this.m_IKTgtRoot.Find(this.BodyEffector.bone.name);
  262. transform = new GameObject(this.BodyEffector.bone.name).transform;
  263. transform.SetParent(this.m_IKTgtRoot, false);
  264. this.BodyTarget = new GameObject("IKTarget").transform;
  265. this.BodyTarget.SetParent(transform, false);
  266. }
  267. this.BodyEffector.target = this.BodyTarget;
  268. this.BodyEffector.effectChildNodes = false;
  269. this.m_FullbodyIK.enabled = false;
  270. }
  271. public void IKUpdate()
  272. {
  273. if (this.TgtMaid.boMAN)
  274. {
  275. this.m_Mouth.localPosition = new Vector3(-0.013f, 0.1115f, 0f);
  276. }
  277. else
  278. {
  279. this.AttachPointTransCpy(this.m_Mouth, "head", "歯", false);
  280. this.AttachPointTransCpy(this.m_NippleL, "body", "乳首左", false);
  281. this.AttachPointTransCpy(this.m_NippleR, "body", "乳首右", false);
  282. }
  283. this.BodyEffector.positionWeight = 0f;
  284. this.BodyTarget.position = this.BodyEffector.bone.position;
  285. this.DoHeightCover = false;
  286. this.IsUpdateLate = false;
  287. if (!this.IKActive)
  288. {
  289. return;
  290. }
  291. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  292. {
  293. ikctrlData.ApplyIKSetting();
  294. }
  295. if (!this.IsUpdateLate && (this.IsIKExec || this.AllForceIK))
  296. {
  297. this.SolverUpdate();
  298. }
  299. }
  300. public void SolverUpdate()
  301. {
  302. this.IsUpdateEnd = true;
  303. Action postSolverUpdate = this.PostSolverUpdate;
  304. this.PostSolverUpdate = null;
  305. if (this.BodyCtrlData.IsIKExec)
  306. {
  307. this.BodyCtrlData.Update();
  308. }
  309. bool flag = this.m_FullbodyDataList.Any((BipedIKCtrlData data) => data.IsIKExec && !data.OldIkExec);
  310. if (this.m_MouthIKData.IsIKExec)
  311. {
  312. this.m_MouthIKData.Update();
  313. }
  314. flag |= (this.BodyEffector.positionWeight == 1f);
  315. if (flag)
  316. {
  317. Vector3 normalized = this.m_FullbodyIK.references.spine[0].InverseTransformPoint(this.m_FullbodyIK.references.spine[1].position).normalized;
  318. this.m_FullbodyIK.solver.Update();
  319. this.m_FullbodyIK.references.spine[1].position = this.m_FullbodyIK.references.spine[0].TransformPoint(normalized * this.m_SpineLength);
  320. }
  321. foreach (IKCtrlData ikctrlData in this.m_strIKDataPair.Values)
  322. {
  323. ikctrlData.LateUpdate();
  324. }
  325. if (postSolverUpdate != null)
  326. {
  327. postSolverUpdate();
  328. }
  329. }
  330. public void AttachPointTransCpy(Transform trans, string slot_name, string attach_name, bool scale_cpy = false)
  331. {
  332. int slotNo = this.TgtBody.GetSlotNo(slot_name);
  333. if (this.TgtBody.goSlot[slotNo].morph == null)
  334. {
  335. return;
  336. }
  337. Vector3 position;
  338. Quaternion rotation;
  339. Vector3 localScale;
  340. this.TgtBody.goSlot[slotNo].morph.GetAttachPoint(attach_name, out position, out rotation, out localScale, false);
  341. trans.position = position;
  342. trans.rotation = rotation;
  343. if (scale_cpy)
  344. {
  345. trans.localScale = localScale;
  346. }
  347. }
  348. public Transform GetIKBone(IKManager.BoneType boneType)
  349. {
  350. return (!this.m_IKBoneDic.ContainsKey(boneType)) ? null : this.m_IKBoneDic[boneType].Value.transform;
  351. }
  352. public Transform[] GetChainBonesToInit(IKManager.BoneType boneType)
  353. {
  354. Transform[] result = new Transform[0];
  355. switch (boneType)
  356. {
  357. case IKManager.BoneType.Forearm_R:
  358. result = new Transform[]
  359. {
  360. this.GetIKBone(IKManager.BoneType.Clavicle_R),
  361. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  362. this.GetIKBone(IKManager.BoneType.Forearm_R)
  363. };
  364. break;
  365. case IKManager.BoneType.Hand_R:
  366. result = new Transform[]
  367. {
  368. this.GetIKBone(IKManager.BoneType.UpperArm_R),
  369. this.GetIKBone(IKManager.BoneType.Forearm_R),
  370. this.GetIKBone(IKManager.BoneType.Hand_R)
  371. };
  372. break;
  373. default:
  374. switch (boneType)
  375. {
  376. case IKManager.BoneType.Head:
  377. if (!this.TgtMaid.boMAN)
  378. {
  379. result = new Transform[]
  380. {
  381. this.GetIKBone(IKManager.BoneType.Spine0),
  382. this.GetIKBone(IKManager.BoneType.Spine1),
  383. this.GetIKBone(IKManager.BoneType.Spine2),
  384. this.GetIKBone(IKManager.BoneType.Spine3),
  385. this.GetIKBone(IKManager.BoneType.Neck),
  386. this.GetIKBone(IKManager.BoneType.Head)
  387. };
  388. }
  389. else
  390. {
  391. result = new Transform[]
  392. {
  393. this.GetIKBone(IKManager.BoneType.Spine0),
  394. this.GetIKBone(IKManager.BoneType.Spine1),
  395. this.GetIKBone(IKManager.BoneType.Spine2),
  396. this.GetIKBone(IKManager.BoneType.Neck),
  397. this.GetIKBone(IKManager.BoneType.Head)
  398. };
  399. }
  400. break;
  401. case IKManager.BoneType.Neck:
  402. if (!this.TgtMaid.boMAN)
  403. {
  404. result = new Transform[]
  405. {
  406. this.GetIKBone(IKManager.BoneType.Spine0),
  407. this.GetIKBone(IKManager.BoneType.Spine1),
  408. this.GetIKBone(IKManager.BoneType.Spine2),
  409. this.GetIKBone(IKManager.BoneType.Spine3),
  410. this.GetIKBone(IKManager.BoneType.Neck)
  411. };
  412. }
  413. else
  414. {
  415. result = new Transform[]
  416. {
  417. this.GetIKBone(IKManager.BoneType.Spine0),
  418. this.GetIKBone(IKManager.BoneType.Spine1),
  419. this.GetIKBone(IKManager.BoneType.Spine2),
  420. this.GetIKBone(IKManager.BoneType.Neck)
  421. };
  422. }
  423. break;
  424. default:
  425. switch (boneType)
  426. {
  427. case IKManager.BoneType.Mouth:
  428. if (!this.TgtMaid.boMAN)
  429. {
  430. result = new Transform[]
  431. {
  432. this.GetIKBone(IKManager.BoneType.Spine0),
  433. this.GetIKBone(IKManager.BoneType.Spine1),
  434. this.GetIKBone(IKManager.BoneType.Spine2),
  435. this.GetIKBone(IKManager.BoneType.Spine3),
  436. this.GetIKBone(IKManager.BoneType.Neck),
  437. this.GetIKBone(IKManager.BoneType.Head),
  438. this.GetIKBone(IKManager.BoneType.Mouth)
  439. };
  440. }
  441. else
  442. {
  443. result = new Transform[]
  444. {
  445. this.GetIKBone(IKManager.BoneType.Spine0),
  446. this.GetIKBone(IKManager.BoneType.Spine1),
  447. this.GetIKBone(IKManager.BoneType.Spine2),
  448. this.GetIKBone(IKManager.BoneType.Neck),
  449. this.GetIKBone(IKManager.BoneType.Head),
  450. this.GetIKBone(IKManager.BoneType.Mouth)
  451. };
  452. }
  453. break;
  454. case IKManager.BoneType.Nipple_L:
  455. if (!this.TgtMaid.boMAN)
  456. {
  457. result = new Transform[]
  458. {
  459. this.GetIKBone(IKManager.BoneType.Bust_L),
  460. this.GetIKBone(IKManager.BoneType.Bust_L_Sub),
  461. this.GetIKBone(IKManager.BoneType.Nipple_L)
  462. };
  463. }
  464. break;
  465. case IKManager.BoneType.Nipple_R:
  466. if (!this.TgtMaid.boMAN)
  467. {
  468. result = new Transform[]
  469. {
  470. this.GetIKBone(IKManager.BoneType.Bust_R),
  471. this.GetIKBone(IKManager.BoneType.Bust_R_Sub),
  472. this.GetIKBone(IKManager.BoneType.Nipple_R)
  473. };
  474. }
  475. break;
  476. }
  477. break;
  478. case IKManager.BoneType.Spine2:
  479. result = new Transform[]
  480. {
  481. this.GetIKBone(IKManager.BoneType.Spine0),
  482. this.GetIKBone(IKManager.BoneType.Spine1),
  483. this.GetIKBone(IKManager.BoneType.Spine2)
  484. };
  485. break;
  486. case IKManager.BoneType.Spine3:
  487. if (!this.TgtMaid.boMAN)
  488. {
  489. result = new Transform[]
  490. {
  491. this.GetIKBone(IKManager.BoneType.Spine0),
  492. this.GetIKBone(IKManager.BoneType.Spine1),
  493. this.GetIKBone(IKManager.BoneType.Spine2),
  494. this.GetIKBone(IKManager.BoneType.Spine3)
  495. };
  496. }
  497. break;
  498. }
  499. break;
  500. case IKManager.BoneType.Calf_R:
  501. result = new Transform[]
  502. {
  503. this.GetIKBone(IKManager.BoneType.Thigh_R),
  504. this.GetIKBone(IKManager.BoneType.Calf_R)
  505. };
  506. break;
  507. case IKManager.BoneType.Foot_R:
  508. result = new Transform[]
  509. {
  510. this.GetIKBone(IKManager.BoneType.Thigh_R),
  511. this.GetIKBone(IKManager.BoneType.Calf_R),
  512. this.GetIKBone(IKManager.BoneType.Foot_R)
  513. };
  514. break;
  515. case IKManager.BoneType.Forearm_L:
  516. result = new Transform[]
  517. {
  518. this.GetIKBone(IKManager.BoneType.Clavicle_L),
  519. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  520. this.GetIKBone(IKManager.BoneType.Forearm_L)
  521. };
  522. break;
  523. case IKManager.BoneType.Hand_L:
  524. result = new Transform[]
  525. {
  526. this.GetIKBone(IKManager.BoneType.UpperArm_L),
  527. this.GetIKBone(IKManager.BoneType.Forearm_L),
  528. this.GetIKBone(IKManager.BoneType.Hand_L)
  529. };
  530. break;
  531. case IKManager.BoneType.Calf_L:
  532. result = new Transform[]
  533. {
  534. this.GetIKBone(IKManager.BoneType.Thigh_L),
  535. this.GetIKBone(IKManager.BoneType.Calf_L)
  536. };
  537. break;
  538. case IKManager.BoneType.Foot_L:
  539. result = new Transform[]
  540. {
  541. this.GetIKBone(IKManager.BoneType.Thigh_L),
  542. this.GetIKBone(IKManager.BoneType.Calf_L),
  543. this.GetIKBone(IKManager.BoneType.Foot_L)
  544. };
  545. break;
  546. }
  547. return result;
  548. }
  549. public IKCtrlData GetIKData(string tag_name, bool flagcheck = false)
  550. {
  551. if (this.m_strIKDataPair.ContainsKey(tag_name))
  552. {
  553. return this.m_strIKDataPair[tag_name];
  554. }
  555. if (this.m_ForearmCalfIKList.ContainsKey(tag_name))
  556. {
  557. if (flagcheck)
  558. {
  559. this.m_ForearmCalfIKList[tag_name].IsBendIK = true;
  560. }
  561. return this.m_ForearmCalfIKList[tag_name];
  562. }
  563. if (this.m_SholderThighIKList.ContainsKey(tag_name))
  564. {
  565. if (flagcheck)
  566. {
  567. this.m_SholderThighIKList[tag_name].IsRootIK = true;
  568. }
  569. return this.m_SholderThighIKList[tag_name];
  570. }
  571. return null;
  572. }
  573. public T GetIKData<T>(string tag_name, bool flagcheck = false) where T : IKCtrlData
  574. {
  575. IKCtrlData ikdata = this.GetIKData(tag_name, flagcheck);
  576. if (ikdata != null && ikdata is T)
  577. {
  578. return ikdata as T;
  579. }
  580. return (T)((object)null);
  581. }
  582. public Transform GetSTFlagObj(string name)
  583. {
  584. if (this.m_NameFlagObjpair.ContainsKey(name))
  585. {
  586. return this.m_NameFlagObjpair[name];
  587. }
  588. Transform transform = this.m_STRoot.Find(name);
  589. if (!transform)
  590. {
  591. transform = this.TgtBody.GetBone(name);
  592. if (!transform)
  593. {
  594. Debug.LogErrorFormat("{0}は存在しません", new object[]
  595. {
  596. name
  597. });
  598. return null;
  599. }
  600. }
  601. this.m_NameFlagObjpair.Add(name, transform);
  602. return transform;
  603. }
  604. [SerializeField]
  605. private TBody m_TgtBody;
  606. [SerializeField]
  607. private Transform m_IKTgtRoot;
  608. [SerializeField]
  609. private Transform m_STRoot;
  610. [SerializeField]
  611. private FullBodyBipedIK m_FullbodyIK;
  612. private CCDIK m_MouthIK;
  613. private CCDIK m_MuneLIK;
  614. private CCDIK m_MuneRIK;
  615. private FABRIK m_ForearmLIK;
  616. private FABRIK m_ForearmRIK;
  617. private FABRIK m_CalfLIK;
  618. private FABRIK m_CalfRIK;
  619. private Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>> m_IKBoneDic = new Dictionary<IKManager.BoneType, KeyValuePair<IKManager.BoneSetType, GameObject>>();
  620. [SerializeField]
  621. private BodyCtrlData m_BodyCtrlData;
  622. [SerializeField]
  623. private List<BipedIKCtrlData> m_FullbodyDataList = new List<BipedIKCtrlData>();
  624. [SerializeField]
  625. private List<CCDIKCtrlData> m_CCDDataList = new List<CCDIKCtrlData>();
  626. [SerializeField]
  627. private List<FABRIKCtrlData> m_FABRDataList = new List<FABRIKCtrlData>();
  628. private Transform m_NippleL;
  629. private Transform m_NippleR;
  630. private Transform m_Mouth;
  631. private Dictionary<string, IKCtrlData> m_strIKDataPair = new Dictionary<string, IKCtrlData>();
  632. private Dictionary<string, BipedIKCtrlData> m_ForearmCalfIKList = new Dictionary<string, BipedIKCtrlData>();
  633. private Dictionary<string, BipedIKCtrlData> m_SholderThighIKList = new Dictionary<string, BipedIKCtrlData>();
  634. private Dictionary<string, Transform> m_NameFlagObjpair = new Dictionary<string, Transform>();
  635. public bool IKActive = true;
  636. public bool DoHeightCover;
  637. public bool IsUpdateLate;
  638. public Action PostSolverUpdate;
  639. public bool AllForceIK;
  640. public float BlendTime = 0.5f;
  641. private float m_SpineLength;
  642. }