FullBodyIKCtrl.cs 20 KB

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