FullBodyIKCtrl.cs 20 KB

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