HandSignShortcut.cs 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using UnityEngine.Events;
  6. using UnityEngine.UI;
  7. public class HandSignShortcut : MonoBehaviour
  8. {
  9. public static HandSignShortcut.Serializer config
  10. {
  11. get
  12. {
  13. HandSignShortcut.LoadDefault();
  14. return HandSignShortcut.m_Config;
  15. }
  16. }
  17. private static void LoadDefault()
  18. {
  19. if (HandSignShortcut.m_IsLoadedDefault)
  20. {
  21. return;
  22. }
  23. HandSignShortcut.m_IsLoadedDefault = true;
  24. HandSignShortcut.m_Config = HandSignShortcut.m_Config.ReadAndSet();
  25. }
  26. public bool IsLeftHand
  27. {
  28. get
  29. {
  30. return this.m_IsLeftHand;
  31. }
  32. set
  33. {
  34. this.m_IsLeftHand = value;
  35. }
  36. }
  37. public AVRController controller
  38. {
  39. get
  40. {
  41. return this.m_Controller;
  42. }
  43. private set
  44. {
  45. this.m_Controller = value;
  46. }
  47. }
  48. private CircleListSelectUI circleList
  49. {
  50. get
  51. {
  52. return this.m_CircleList;
  53. }
  54. set
  55. {
  56. this.m_CircleList = value;
  57. }
  58. }
  59. public bool isEnableHandUI
  60. {
  61. get
  62. {
  63. return this.circleList != null && this.circleList.gameObject.activeSelf;
  64. }
  65. set
  66. {
  67. if (this.circleList != null && this.circleList.gameObject.activeSelf != value)
  68. {
  69. this.circleList.gameObject.SetActive(value);
  70. }
  71. }
  72. }
  73. public void Init(bool isLeftHand)
  74. {
  75. this.IsLeftHand = isLeftHand;
  76. Debug.Log("初期化:ハンドサインのショートカットを実行するコンポーネント");
  77. this.controller = ((!isLeftHand) ? GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller : GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller);
  78. this.InitHand();
  79. this.InitCircleUI();
  80. }
  81. private void InitHand()
  82. {
  83. Maid maid = this.GetMaid();
  84. Transform t;
  85. string[] array;
  86. if (this.IsLeftHand)
  87. {
  88. t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true);
  89. array = HandSignShortcut.strHandBoneNameL;
  90. }
  91. else
  92. {
  93. t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true);
  94. array = HandSignShortcut.strHandBoneNameR;
  95. }
  96. this.m_TransformFingerArray = new Transform[array.Length];
  97. for (int i = 0; i < array.Length; i++)
  98. {
  99. this.m_TransformFingerArray[i] = CMT.SearchObjName(t, array[i], true);
  100. }
  101. }
  102. private void InitCircleUI()
  103. {
  104. string text = "OVR/CircleCommandUI/HandSignDataShortcut(Cotroller)";
  105. GameObject gameObject = Resources.Load<GameObject>(text);
  106. if (gameObject == null)
  107. {
  108. NDebug.Assert("[HandSignShortcut] " + text + "\nプレハブが見つかりません", false);
  109. }
  110. GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject);
  111. this.circleList = gameObject2.GetComponent<CircleListSelectUI>();
  112. this.CreateItemList(8);
  113. CircleCommandUI circleCommandUI = this.circleList.circleCommandUI;
  114. circleCommandUI.onSelect.AddListener(new UnityAction<GameObject>(this.OnSelectItem));
  115. circleCommandUI.onDeselect.AddListener(new UnityAction<GameObject>(this.OnDeselectItem));
  116. circleCommandUI.onDecide.AddListener(new UnityAction<GameObject>(this.OnDecide));
  117. this.circleList.controller = this.controller;
  118. Transform transform = gameObject2.transform;
  119. transform.SetParent(base.transform);
  120. transform.localPosition = Vector3.zero;
  121. transform.localRotation = Quaternion.identity;
  122. transform.localScale = Vector3.one;
  123. Vector3 b = new Vector3(0.03f, 0.15f, -0.05f);
  124. Vector3 localEulerAngles = new Vector3(35f, 15f, 0f);
  125. if (this.IsLeftHand)
  126. {
  127. b.Scale(new Vector3(-1f, 1f, 1f));
  128. localEulerAngles.Scale(new Vector3(1f, -1f, -1f));
  129. }
  130. transform.localPosition += b;
  131. transform.localEulerAngles = localEulerAngles;
  132. GameObject childObject = UTY.GetChildObject(this.circleList.gameObject, "CircleCommandUI/text right hand", false);
  133. childObject.GetComponent<Text>().text = ((!this.IsLeftHand) ? "右" : "左");
  134. }
  135. private void CreateItemList(int count)
  136. {
  137. List<HandSignShortcut.MaidFingerData> dataList = HandSignShortcut.config.maidFingerDataList;
  138. CircleCommandUI circleCommandUI = this.circleList.circleCommandUI;
  139. circleCommandUI.Show<Transform>(count, delegate(int index, Transform trans)
  140. {
  141. Text componentInChildren = trans.GetComponentInChildren<Text>();
  142. trans.localScale = Vector3.one * 0.5f;
  143. HandSignShortcut.ItemData itemData = trans.gameObject.AddComponent<HandSignShortcut.ItemData>();
  144. itemData.text = componentInChildren;
  145. if (index == 0)
  146. {
  147. itemData.data = null;
  148. return;
  149. }
  150. if (dataList.Count > index - 1)
  151. {
  152. itemData.data = dataList[index - 1];
  153. }
  154. else
  155. {
  156. itemData.data = null;
  157. }
  158. });
  159. }
  160. private void OnSelectItem(GameObject item)
  161. {
  162. if (item == null)
  163. {
  164. return;
  165. }
  166. Graphic component = item.GetComponent<Graphic>();
  167. if (component != null)
  168. {
  169. component.color = Color.red;
  170. }
  171. item.transform.localScale = Vector3.one;
  172. item.transform.SetAsLastSibling();
  173. if (ControllerShortcutSettingData.config.isDirectMode)
  174. {
  175. HandSignShortcut.ItemData component2 = item.GetComponent<HandSignShortcut.ItemData>();
  176. if (component2 != null)
  177. {
  178. this.m_NowTargetFingerData = component2.data;
  179. }
  180. else
  181. {
  182. this.m_NowTargetFingerData = null;
  183. }
  184. }
  185. }
  186. private void OnDeselectItem(GameObject item)
  187. {
  188. if (item == null)
  189. {
  190. return;
  191. }
  192. Graphic component = item.GetComponent<Graphic>();
  193. if (component != null)
  194. {
  195. Color white = Color.white;
  196. white.a = 0.5f;
  197. component.color = white;
  198. }
  199. item.transform.localScale = Vector3.one * 0.5f;
  200. }
  201. private void OnDecide(GameObject selectItem)
  202. {
  203. if (selectItem == null)
  204. {
  205. Debug.LogWarning("選択項目にnullが入った");
  206. return;
  207. }
  208. this.OnDeselectItem(selectItem);
  209. if (!ControllerShortcutSettingData.config.isEveryShowMode)
  210. {
  211. this.m_CircleList.SetActiveUI(false);
  212. }
  213. if (ControllerShortcutSettingData.config.isDirectMode)
  214. {
  215. return;
  216. }
  217. HandSignShortcut.ItemData component = selectItem.GetComponent<HandSignShortcut.ItemData>();
  218. if (component != null)
  219. {
  220. this.m_NowTargetFingerData = component.data;
  221. }
  222. else
  223. {
  224. this.m_NowTargetFingerData = null;
  225. }
  226. }
  227. private void Update()
  228. {
  229. if (this.m_NowTargetFingerData != null)
  230. {
  231. this.UpdateFinger(this.m_NowTargetFingerData);
  232. }
  233. else
  234. {
  235. this.UpdateHandSign();
  236. }
  237. }
  238. private void UpdateHandSign()
  239. {
  240. if (this.controller == null || !this.controller.HandEnable)
  241. {
  242. return;
  243. }
  244. AVRControllerButtons vrcontrollerButtons = this.controller.VRControllerButtons;
  245. if (vrcontrollerButtons != null)
  246. {
  247. if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH)
  248. {
  249. if (vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.REST) || vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.XA) || vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.YB))
  250. {
  251. this.FingerRateTarget(HandSignShortcut.Finger.Thumb, 1f);
  252. }
  253. else
  254. {
  255. this.FingerRateTarget(HandSignShortcut.Finger.Thumb, 0f);
  256. }
  257. if (vrcontrollerButtons.GetPress(AVRControllerButtons.BTN.TRIGGER))
  258. {
  259. this.FingerRateTarget(HandSignShortcut.Finger.Index, 1f);
  260. }
  261. else if (vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.TRIGGER))
  262. {
  263. this.FingerRateTarget(HandSignShortcut.Finger.Index, 0.5f);
  264. }
  265. else
  266. {
  267. this.FingerRateTarget(HandSignShortcut.Finger.Index, 0f);
  268. }
  269. if (vrcontrollerButtons.GetPress(AVRControllerButtons.BTN.GRIP))
  270. {
  271. this.FingerRateTarget(HandSignShortcut.Finger.Middle, 1f);
  272. this.FingerRateTarget(HandSignShortcut.Finger.Ring, 1f);
  273. this.FingerRateTarget(HandSignShortcut.Finger.Little, 1f);
  274. }
  275. else
  276. {
  277. this.FingerRateTarget(HandSignShortcut.Finger.Middle, 0f);
  278. this.FingerRateTarget(HandSignShortcut.Finger.Ring, 0f);
  279. this.FingerRateTarget(HandSignShortcut.Finger.Little, 0f);
  280. }
  281. }
  282. else if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.VIVE)
  283. {
  284. this.FingerRateTarget(HandSignShortcut.Finger.Thumb, vrcontrollerButtons.GetTriggerRate());
  285. this.FingerRateTarget(HandSignShortcut.Finger.Index, vrcontrollerButtons.GetTriggerRate());
  286. this.FingerRateTarget(HandSignShortcut.Finger.Middle, vrcontrollerButtons.GetTriggerRate());
  287. this.FingerRateTarget(HandSignShortcut.Finger.Ring, vrcontrollerButtons.GetTriggerRate());
  288. this.FingerRateTarget(HandSignShortcut.Finger.Little, vrcontrollerButtons.GetTriggerRate());
  289. }
  290. }
  291. for (int i = 0; i < 5; i++)
  292. {
  293. this.FingerRateUpdate((HandSignShortcut.Finger)i, this.m_fTargetRate[i]);
  294. }
  295. }
  296. private void FingerRateTarget(HandSignShortcut.Finger f_eFinger, float f_fRate)
  297. {
  298. this.m_fTargetRate[(int)f_eFinger] = f_fRate;
  299. }
  300. private void FingerRateUpdate(HandSignShortcut.Finger f_eFinger, float f_fRate)
  301. {
  302. int num = (int)(f_eFinger * HandSignShortcut.Finger.Ring);
  303. for (int i = num; i < num + 3; i++)
  304. {
  305. if (this.IsLeftHand)
  306. {
  307. this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, Quaternion.Lerp(HandSignShortcut.m_aryHandRot[0, i], HandSignShortcut.m_aryHandRot[1, i], f_fRate), 0.25f);
  308. }
  309. else
  310. {
  311. this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, Quaternion.Lerp(HandSignShortcut.m_aryHandRot[2, i], HandSignShortcut.m_aryHandRot[3, i], f_fRate), 0.25f);
  312. }
  313. }
  314. }
  315. private void UpdateFinger(HandSignShortcut.MaidFingerData data)
  316. {
  317. Quaternion[] array = (!this.IsLeftHand) ? data.rightFingerData : data.leftFingerData;
  318. for (int i = 0; i < this.m_TransformFingerArray.Length; i++)
  319. {
  320. this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, array[i], 0.25f);
  321. }
  322. }
  323. private Maid GetMaid()
  324. {
  325. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  326. return characterMgr.GetMaid(0);
  327. }
  328. private void OnApplicationQuit()
  329. {
  330. this.m_IsQuitting = true;
  331. }
  332. private void OnDestroy()
  333. {
  334. if (this.m_IsQuitting)
  335. {
  336. return;
  337. }
  338. if (this.circleList != null && this.circleList.gameObject != null)
  339. {
  340. UnityEngine.Object.Destroy(this.circleList.gameObject);
  341. Debug.Log("[HandSignShortcut] コントローラについているUIを破棄しました");
  342. }
  343. }
  344. static HandSignShortcut()
  345. {
  346. // Note: this type is marked as 'beforefieldinit'.
  347. Quaternion[,] array = new Quaternion[4, 15];
  348. array[0, 0] = new Quaternion(1.379457E-08f, -1.907173E-10f, -0.1001217f, 0.9949752f);
  349. array[0, 1] = new Quaternion(-3.348364E-08f, -2.288052E-09f, -0.05697599f, 0.9983756f);
  350. array[0, 2] = new Quaternion(0.4853954f, -0.1902075f, 0.1155978f, 0.8454878f);
  351. array[0, 3] = new Quaternion(-2.555888E-09f, 1.190041E-09f, -0.08838178f, 0.9960867f);
  352. array[0, 4] = new Quaternion(-3.708266E-09f, -4.232382E-11f, -0.1423017f, 0.9898233f);
  353. array[0, 5] = new Quaternion(0.005196964f, -0.009313619f, -0.07643344f, 0.9970177f);
  354. array[0, 6] = new Quaternion(1.469708E-09f, -2.337872E-09f, -0.08838177f, 0.9960867f);
  355. array[0, 7] = new Quaternion(-4.677417E-09f, -1.311283E-08f, -0.1086997f, 0.9940746f);
  356. array[0, 8] = new Quaternion(-0.001879324f, -0.005337666f, -0.0991221f, 0.9950592f);
  357. array[0, 9] = new Quaternion(-8.490085E-09f, -1.805363E-09f, -0.0796621f, 0.9968219f);
  358. array[0, 10] = new Quaternion(2.300491E-09f, 3.334659E-09f, -0.1239805f, 0.9922847f);
  359. array[0, 11] = new Quaternion(-0.006921342f, 0.001893361f, -0.09829046f, 0.9951319f);
  360. array[0, 12] = new Quaternion(-5.701029E-09f, -1.521331E-09f, -0.05449884f, 0.9985139f);
  361. array[0, 13] = new Quaternion(3.803335E-09f, -5.725684E-09f, -0.1423017f, 0.9898233f);
  362. array[0, 14] = new Quaternion(-0.01357147f, 0.02850812f, -0.08513741f, 0.9958689f);
  363. array[1, 0] = new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f);
  364. array[1, 1] = new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f);
  365. array[1, 2] = new Quaternion(0.7708589f, -0.2672266f, 0.03713043f, 0.577051f);
  366. array[1, 3] = new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f);
  367. array[1, 4] = new Quaternion(-5.034789E-09f, -5.799267E-09f, -0.8191521f, 0.5735765f);
  368. array[1, 5] = new Quaternion(0.0478053f, -0.01974053f, -0.5880075f, 0.8072003f);
  369. array[1, 6] = new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f);
  370. array[1, 7] = new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f);
  371. array[1, 8] = new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f);
  372. array[1, 9] = new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f);
  373. array[1, 10] = new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f);
  374. array[1, 11] = new Quaternion(-0.04368013f, 0.007996441f, -0.6048046f, 0.7951349f);
  375. array[1, 12] = new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008097f, 0.8655574f);
  376. array[1, 13] = new Quaternion(4.887594E-09f, -3.295959E-08f, -0.8191521f, 0.5735765f);
  377. array[1, 14] = new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987924f);
  378. array[2, 0] = new Quaternion(-1.299039E-08f, 7.939377E-10f, -0.08632442f, 0.9962671f);
  379. array[2, 1] = new Quaternion(-1.412307E-08f, -4.882294E-09f, -0.05340298f, 0.9985731f);
  380. array[2, 2] = new Quaternion(-0.4710969f, 0.1764064f, 0.1206711f, 0.8557962f);
  381. array[2, 3] = new Quaternion(-1.785701E-09f, -1.246846E-08f, -0.06366991f, 0.9979711f);
  382. array[2, 4] = new Quaternion(-5.778726E-11f, -1.242248E-08f, -0.1014653f, 0.9948391f);
  383. array[2, 5] = new Quaternion(-0.002611603f, 0.001185287f, -0.04763259f, 0.9988608f);
  384. array[2, 6] = new Quaternion(1.790176E-09f, -1.245129E-08f, -0.0636699f, 0.9979711f);
  385. array[2, 7] = new Quaternion(5.652268E-09f, 1.780454E-09f, -0.06771687f, 0.9977046f);
  386. array[2, 8] = new Quaternion(0.001466242f, 0.004677885f, -0.07036161f, 0.9975095f);
  387. array[2, 9] = new Quaternion(7.64029E-09f, 7.058498E-09f, -0.05493468f, 0.99849f);
  388. array[2, 10] = new Quaternion(-2.104634E-09f, -7.598384E-09f, -0.08305829f, 0.9965447f);
  389. array[2, 11] = new Quaternion(0.004817214f, 0.003811401f, -0.0695642f, 0.9975586f);
  390. array[2, 12] = new Quaternion(2.864904E-09f, -1.440215E-08f, -0.02973721f, 0.9995578f);
  391. array[2, 13] = new Quaternion(-7.071282E-10f, -5.241497E-09f, -0.1014653f, 0.9948391f);
  392. array[2, 14] = new Quaternion(0.00861063f, -0.01516612f, -0.05657673f, 0.998246f);
  393. array[3, 0] = new Quaternion(7.66758E-09f, -1.102812E-08f, -0.3665012f, 0.9304176f);
  394. array[3, 1] = new Quaternion(-8.709043E-09f, -7.065411E-09f, -0.1618618f, 0.9868135f);
  395. array[3, 2] = new Quaternion(-0.7708589f, 0.2672265f, 0.03713048f, 0.577051f);
  396. array[3, 3] = new Quaternion(-8.292553E-09f, 7.889813E-10f, -0.5299194f, 0.8480481f);
  397. array[3, 4] = new Quaternion(6.103158E-09f, 4.273478E-09f, -0.8191521f, 0.5735765f);
  398. array[3, 5] = new Quaternion(-0.0478053f, 0.01974053f, -0.5880075f, 0.8072003f);
  399. array[3, 6] = new Quaternion(-1.288366E-08f, 7.501511E-09f, -0.5299194f, 0.8480481f);
  400. array[3, 7] = new Quaternion(1.786481E-08f, 1.343313E-08f, -0.7992581f, 0.6009881f);
  401. array[3, 8] = new Quaternion(0.009090304f, 0.01649068f, -0.6061373f, 0.7951371f);
  402. array[3, 9] = new Quaternion(1.513849E-08f, -3.815058E-09f, -0.5224782f, 0.8526527f);
  403. array[3, 10] = new Quaternion(-1.643181E-08f, -2.748009E-09f, -0.8084095f, 0.5886205f);
  404. array[3, 11] = new Quaternion(0.04368011f, -0.007996418f, -0.6048046f, 0.7951349f);
  405. array[3, 12] = new Quaternion(1.196498E-08f, -9.074872E-09f, -0.5008097f, 0.8655574f);
  406. array[3, 13] = new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.8191521f, 0.5735765f);
  407. array[3, 14] = new Quaternion(0.09800829f, -0.0545494f, -0.5910579f, 0.7987924f);
  408. HandSignShortcut.m_aryHandRot = array;
  409. }
  410. [SerializeField]
  411. private CircleListSelectUI m_CircleList;
  412. private static HandSignShortcut.Serializer m_Config = new HandSignShortcut.Serializer();
  413. private static bool m_IsLoadedDefault = false;
  414. private Transform[] m_TransformFingerArray;
  415. private static readonly string[] strHandBoneNameL = new string[]
  416. {
  417. "Bip01 L Finger02",
  418. "Bip01 L Finger01",
  419. "Bip01 L Finger0",
  420. "Bip01 L Finger12",
  421. "Bip01 L Finger11",
  422. "Bip01 L Finger1",
  423. "Bip01 L Finger22",
  424. "Bip01 L Finger21",
  425. "Bip01 L Finger2",
  426. "Bip01 L Finger32",
  427. "Bip01 L Finger31",
  428. "Bip01 L Finger3",
  429. "Bip01 L Finger42",
  430. "Bip01 L Finger41",
  431. "Bip01 L Finger4"
  432. };
  433. private static readonly string[] strHandBoneNameR = new string[]
  434. {
  435. "Bip01 R Finger02",
  436. "Bip01 R Finger01",
  437. "Bip01 R Finger0",
  438. "Bip01 R Finger12",
  439. "Bip01 R Finger11",
  440. "Bip01 R Finger1",
  441. "Bip01 R Finger22",
  442. "Bip01 R Finger21",
  443. "Bip01 R Finger2",
  444. "Bip01 R Finger32",
  445. "Bip01 R Finger31",
  446. "Bip01 R Finger3",
  447. "Bip01 R Finger42",
  448. "Bip01 R Finger41",
  449. "Bip01 R Finger4"
  450. };
  451. private static readonly Quaternion[,] m_aryHandRot;
  452. private bool m_IsLeftHand;
  453. private AVRController m_Controller;
  454. private float[] m_fTargetRate = new float[5];
  455. private HandSignShortcut.MaidFingerData m_NowTargetFingerData;
  456. private bool m_IsQuitting;
  457. [Serializable]
  458. public class Serializer : ISerializationCallbackReceiver
  459. {
  460. public void OnBeforeSerialize()
  461. {
  462. this.m_nVersion = 1130;
  463. }
  464. public void OnAfterDeserialize()
  465. {
  466. }
  467. public bool Write()
  468. {
  469. string contents = JsonUtility.ToJson(this, true);
  470. string path = Path.GetFullPath(".\\") + "MaidFingerDataList.json";
  471. try
  472. {
  473. File.WriteAllText(path, contents);
  474. }
  475. catch
  476. {
  477. Debug.LogError("MaidFingerDataList.json の書き込みに失敗。");
  478. return false;
  479. }
  480. return true;
  481. }
  482. public HandSignShortcut.Serializer ReadAndSet()
  483. {
  484. string path = Path.GetFullPath(".\\") + "MaidFingerDataList.json";
  485. if (!File.Exists(path))
  486. {
  487. this.CreateDefaultData();
  488. this.Write();
  489. }
  490. string json;
  491. try
  492. {
  493. json = File.ReadAllText(path);
  494. }
  495. catch
  496. {
  497. Debug.LogError("MaidFingerDataList.json の読込に失敗。");
  498. return this;
  499. }
  500. return JsonUtility.FromJson<HandSignShortcut.Serializer>(json);
  501. }
  502. private void CreateDefaultData()
  503. {
  504. this.maidFingerDataList = new List<HandSignShortcut.MaidFingerData>();
  505. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("パー", new Quaternion[]
  506. {
  507. new Quaternion(1.467912E-08f, -6.667659E-09f, -0.04146498f, 0.99914f),
  508. new Quaternion(-1.327911E-08f, 7.618504E-09f, -0.006113322f, 0.9999813f),
  509. new Quaternion(0.3676831f, -0.3100421f, 0.1039245f, 0.8705646f),
  510. new Quaternion(-1.67299E-09f, 3.947202E-09f, -0.01237995f, 0.9999234f),
  511. new Quaternion(-1.825179E-09f, 3.798766E-09f, -0.01925841f, 0.9998146f),
  512. new Quaternion(0.0009547397f, -0.1243148f, 0.01200425f, 0.9921698f),
  513. new Quaternion(2.058673E-10f, -3.274742E-10f, -0.01237995f, 0.9999234f),
  514. new Quaternion(-3.4198E-09f, -1.477873E-08f, 0.01461135f, 0.9998932f),
  515. new Quaternion(-0.0006127622f, -0.003308513f, -0.01102171f, 0.9999336f),
  516. new Quaternion(-7.097293E-09f, -1.542719E-08f, -0.003629622f, 0.9999934f),
  517. new Quaternion(1.494679E-09f, -1.210031E-08f, -0.0007735032f, 0.9999997f),
  518. new Quaternion(-0.0008713655f, 0.08438367f, -0.010264f, 0.9963801f),
  519. new Quaternion(-1.4273E-09f, -7.799848E-09f, 0.02158942f, 0.9997669f),
  520. new Quaternion(2.313607E-09f, -7.748858E-10f, -0.01925842f, 0.9998146f),
  521. new Quaternion(-0.002091327f, 0.2073798f, 0.002760789f, 0.9782544f)
  522. }, new Quaternion[]
  523. {
  524. new Quaternion(-1.467912E-08f, 6.667659E-09f, -0.04146498f, 0.99914f),
  525. new Quaternion(1.327911E-08f, -7.618504E-09f, -0.006113322f, 0.9999813f),
  526. new Quaternion(-0.3676831f, 0.3100421f, 0.1039245f, 0.8705646f),
  527. new Quaternion(1.67299E-09f, -3.947202E-09f, -0.01237995f, 0.9999234f),
  528. new Quaternion(1.825179E-09f, -3.798766E-09f, -0.01925841f, 0.9998146f),
  529. new Quaternion(-0.0009547397f, 0.1243148f, 0.01200425f, 0.9921698f),
  530. new Quaternion(-2.058673E-10f, 3.274742E-10f, -0.01237995f, 0.9999234f),
  531. new Quaternion(3.4198E-09f, 1.477873E-08f, 0.01461135f, 0.9998932f),
  532. new Quaternion(0.0006127622f, 0.003308513f, -0.01102171f, 0.9999336f),
  533. new Quaternion(7.097293E-09f, 1.542719E-08f, -0.003629622f, 0.9999934f),
  534. new Quaternion(-1.494679E-09f, 1.210031E-08f, -0.0007735032f, 0.9999997f),
  535. new Quaternion(0.0008713655f, -0.08438367f, -0.010264f, 0.9963801f),
  536. new Quaternion(1.4273E-09f, 7.799848E-09f, 0.02158942f, 0.9997669f),
  537. new Quaternion(-2.313607E-09f, 7.748858E-10f, -0.01925842f, 0.9998146f),
  538. new Quaternion(0.002091327f, -0.2073798f, 0.002760789f, 0.9782544f)
  539. }));
  540. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("チョキ", new Quaternion[]
  541. {
  542. new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f),
  543. new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f),
  544. new Quaternion(0.7708589f, -0.2672266f, 0.03713044f, 0.577051f),
  545. new Quaternion(-1.692222E-09f, 3.961451E-09f, -0.008243912f, 0.999966f),
  546. new Quaternion(-1.793476E-09f, 3.862969E-09f, -0.01279752f, 0.9999181f),
  547. new Quaternion(0.0005797216f, -0.1249451f, 0.01676745f, 0.9920218f),
  548. new Quaternion(1.370887E-10f, -2.180677E-10f, -0.008243906f, 0.999966f),
  549. new Quaternion(-3.352409E-09f, -1.485988E-08f, 0.02107204f, 0.999778f),
  550. new Quaternion(-0.0005442168f, -0.003198181f, -0.006260789f, 0.9999751f),
  551. new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f),
  552. new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f),
  553. new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f),
  554. new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f),
  555. new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f),
  556. new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f)
  557. }, new Quaternion[]
  558. {
  559. new Quaternion(-6.932151E-09f, 2.730647E-09f, -0.3665012f, 0.9304176f),
  560. new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f),
  561. new Quaternion(-0.7708589f, 0.2672266f, 0.03713044f, 0.577051f),
  562. new Quaternion(1.692222E-09f, -3.961451E-09f, -0.008243912f, 0.999966f),
  563. new Quaternion(1.793476E-09f, -3.862969E-09f, -0.01279752f, 0.9999181f),
  564. new Quaternion(-0.0005797216f, 0.1249451f, 0.01676745f, 0.9920218f),
  565. new Quaternion(-1.370887E-10f, 2.180677E-10f, -0.008243906f, 0.999966f),
  566. new Quaternion(3.352409E-09f, 1.485988E-08f, 0.02107204f, 0.999778f),
  567. new Quaternion(0.0005442168f, 0.003198181f, -0.006260789f, 0.9999751f),
  568. new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f),
  569. new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f),
  570. new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f),
  571. new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f),
  572. new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f),
  573. new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f)
  574. }));
  575. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("グー", new Quaternion[]
  576. {
  577. new Quaternion(6.932151E-09f, -2.730646E-09f, -0.3665012f, 0.9304176f),
  578. new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f),
  579. new Quaternion(0.7708589f, -0.2672266f, 0.03713043f, 0.577051f),
  580. new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f),
  581. new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f),
  582. new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f),
  583. new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f),
  584. new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f),
  585. new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f),
  586. new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f),
  587. new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f),
  588. new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f),
  589. new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f),
  590. new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f),
  591. new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f)
  592. }, new Quaternion[]
  593. {
  594. new Quaternion(-6.932151E-09f, 2.730646E-09f, -0.3665012f, 0.9304176f),
  595. new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f),
  596. new Quaternion(-0.7708589f, 0.2672266f, 0.03713043f, 0.577051f),
  597. new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f),
  598. new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f),
  599. new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f),
  600. new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f),
  601. new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f),
  602. new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f),
  603. new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f),
  604. new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f),
  605. new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f),
  606. new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f),
  607. new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f),
  608. new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f)
  609. }));
  610. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("指差し", new Quaternion[]
  611. {
  612. new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f),
  613. new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f),
  614. new Quaternion(0.7708589f, -0.2672266f, 0.03713044f, 0.577051f),
  615. new Quaternion(-1.730466E-09f, 3.989648E-09f, 1.928734E-09f, 1f),
  616. new Quaternion(-1.730466E-09f, 3.989648E-09f, 1.928734E-09f, 1f),
  617. new Quaternion(-0.0001667258f, -0.1261909f, 0.02624661f, 0.9916587f),
  618. new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f),
  619. new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f),
  620. new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f),
  621. new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f),
  622. new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f),
  623. new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f),
  624. new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f),
  625. new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f),
  626. new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f)
  627. }, new Quaternion[]
  628. {
  629. new Quaternion(-6.932151E-09f, 2.730647E-09f, -0.3665012f, 0.9304176f),
  630. new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f),
  631. new Quaternion(-0.7708589f, 0.2672266f, 0.03713044f, 0.577051f),
  632. new Quaternion(1.730466E-09f, -3.989648E-09f, 1.928734E-09f, 1f),
  633. new Quaternion(1.730466E-09f, -3.989648E-09f, 1.928734E-09f, 1f),
  634. new Quaternion(0.0001667258f, 0.1261909f, 0.02624661f, 0.9916587f),
  635. new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f),
  636. new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f),
  637. new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f),
  638. new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f),
  639. new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f),
  640. new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f),
  641. new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f),
  642. new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f),
  643. new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f)
  644. }));
  645. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("サムズアップ", new Quaternion[]
  646. {
  647. new Quaternion(1.472499E-08f, -1.164853E-08f, -0.0242227f, 0.9997066f),
  648. new Quaternion(2.864741E-09f, 1.253174E-08f, 0.02121386f, 0.999775f),
  649. new Quaternion(0.3078066f, -0.4021123f, 0.08737727f, 0.8578613f),
  650. new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f),
  651. new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f),
  652. new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f),
  653. new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f),
  654. new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f),
  655. new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f),
  656. new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f),
  657. new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f),
  658. new Quaternion(-0.04368013f, 0.007996442f, -0.6048046f, 0.7951349f),
  659. new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f),
  660. new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f),
  661. new Quaternion(-0.09800828f, 0.05454941f, -0.591058f, 0.7987923f)
  662. }, new Quaternion[]
  663. {
  664. new Quaternion(-1.472499E-08f, 1.164853E-08f, -0.0242227f, 0.9997066f),
  665. new Quaternion(-2.864741E-09f, -1.253174E-08f, 0.02121386f, 0.999775f),
  666. new Quaternion(-0.3078066f, 0.4021123f, 0.08737727f, 0.8578613f),
  667. new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f),
  668. new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f),
  669. new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f),
  670. new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f),
  671. new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f),
  672. new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f),
  673. new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f),
  674. new Quaternion(-1.204624E-08f, -8.771129E-09f, -0.8084095f, 0.5886205f),
  675. new Quaternion(0.04368013f, -0.007996442f, -0.6048046f, 0.7951349f),
  676. new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f),
  677. new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f),
  678. new Quaternion(0.09800828f, -0.05454941f, -0.591058f, 0.7987923f)
  679. }));
  680. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("電話サイン", new Quaternion[]
  681. {
  682. new Quaternion(1.479486E-08f, -8.781127E-09f, -0.02975121f, 0.9995574f),
  683. new Quaternion(-6.50015E-09f, 1.013705E-08f, 0.007386392f, 0.9999728f),
  684. new Quaternion(0.3369619f, -0.3488706f, 0.09791746f, 0.8689983f),
  685. new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f),
  686. new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f),
  687. new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f),
  688. new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f),
  689. new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f),
  690. new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f),
  691. new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f),
  692. new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f),
  693. new Quaternion(-0.04368013f, 0.007996442f, -0.6048046f, 0.7951349f),
  694. new Quaternion(-8.023863E-10f, -9.682119E-09f, 0.03396483f, 0.999423f),
  695. new Quaternion(1.91605E-09f, -7.848716E-18f, -3.011494E-09f, 1f),
  696. new Quaternion(-0.0007191578f, 0.2631239f, 0.01688699f, 0.964614f)
  697. }, new Quaternion[]
  698. {
  699. new Quaternion(-1.479486E-08f, 8.781127E-09f, -0.02975121f, 0.9995574f),
  700. new Quaternion(6.50015E-09f, -1.013705E-08f, 0.007386392f, 0.9999728f),
  701. new Quaternion(-0.3369619f, 0.3488706f, 0.09791746f, 0.8689983f),
  702. new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f),
  703. new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f),
  704. new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f),
  705. new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f),
  706. new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f),
  707. new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f),
  708. new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f),
  709. new Quaternion(-1.204624E-08f, -8.771129E-09f, -0.8084095f, 0.5886205f),
  710. new Quaternion(0.04368013f, -0.007996442f, -0.6048046f, 0.7951349f),
  711. new Quaternion(8.023863E-10f, 9.682119E-09f, 0.03396483f, 0.999423f),
  712. new Quaternion(-1.91605E-09f, 7.848716E-18f, -3.011494E-09f, 1f),
  713. new Quaternion(0.0007191578f, -0.2631239f, 0.01688699f, 0.964614f)
  714. }));
  715. this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("狐コンコン", new Quaternion[]
  716. {
  717. new Quaternion(0f, 0f, 0f, 1f),
  718. new Quaternion(-1.192093E-07f, 1.788139E-07f, -0.1335995f, 0.9910354f),
  719. new Quaternion(0.8534603f, -0.2756786f, -0.1541951f, 0.4145248f),
  720. new Quaternion(-1.490116E-09f, 4.470349E-09f, 2.048909E-09f, 1f),
  721. new Quaternion(-1.490116E-09f, 4.470349E-09f, 2.048909E-09f, 1f),
  722. new Quaternion(0.0003543059f, -0.1458506f, 0.02624475f, 0.9889584f),
  723. new Quaternion(1.291415E-08f, 1.295253E-07f, 0.01154917f, 0.9999333f),
  724. new Quaternion(1.487787E-07f, -4.237517E-08f, -0.5324296f, 0.8464743f),
  725. new Quaternion(-0.01350924f, -0.01311721f, -0.3475225f, 0.9374825f),
  726. new Quaternion(7.117304E-07f, -7.226793E-07f, -0.00915247f, 0.9999582f),
  727. new Quaternion(2.980232E-08f, 1.061708E-06f, -0.4032317f, 0.9150979f),
  728. new Quaternion(-0.1480011f, 0.04210641f, -0.4022999f, 0.9024841f),
  729. new Quaternion(-7.434641E-10f, -8.971124E-09f, 0.03396483f, 0.999423f),
  730. new Quaternion(2.048909E-09f, -8.673617E-18f, -3.166497E-09f, 1f),
  731. new Quaternion(-0.0003274615f, 0.2406898f, 0.01689912f, 0.9704549f)
  732. }, new Quaternion[]
  733. {
  734. new Quaternion(0f, 0f, 0f, 1f),
  735. new Quaternion(1.192093E-07f, -1.788139E-07f, -0.1335995f, 0.9910354f),
  736. new Quaternion(-0.8534603f, 0.2756786f, -0.1541951f, 0.4145248f),
  737. new Quaternion(1.490116E-09f, -4.470349E-09f, 2.048909E-09f, 1f),
  738. new Quaternion(1.490116E-09f, -4.470349E-09f, 2.048909E-09f, 1f),
  739. new Quaternion(-0.0003543059f, 0.1458506f, 0.02624475f, 0.9889584f),
  740. new Quaternion(-1.291415E-08f, -1.295253E-07f, 0.01154917f, 0.9999333f),
  741. new Quaternion(-1.487787E-07f, 4.237517E-08f, -0.5324296f, 0.8464743f),
  742. new Quaternion(0.01350924f, 0.01311721f, -0.3475225f, 0.9374825f),
  743. new Quaternion(-7.117304E-07f, 7.226793E-07f, -0.00915247f, 0.9999582f),
  744. new Quaternion(-2.980232E-08f, -1.061708E-06f, -0.4032317f, 0.9150979f),
  745. new Quaternion(0.1480011f, -0.04210641f, -0.4022999f, 0.9024841f),
  746. new Quaternion(7.434641E-10f, 8.971124E-09f, 0.03396483f, 0.999423f),
  747. new Quaternion(-2.048909E-09f, 8.673617E-18f, -3.166497E-09f, 1f),
  748. new Quaternion(0.0003274615f, -0.2406898f, 0.01689912f, 0.9704549f)
  749. }));
  750. }
  751. public List<HandSignShortcut.MaidFingerData> maidFingerDataList
  752. {
  753. get
  754. {
  755. return this.MaidFingerDataList;
  756. }
  757. set
  758. {
  759. this.MaidFingerDataList = value;
  760. }
  761. }
  762. private const string CONF_NAME = "MaidFingerDataList.json";
  763. [SerializeField]
  764. private int m_nVersion = 1130;
  765. [SerializeField]
  766. private List<HandSignShortcut.MaidFingerData> MaidFingerDataList = new List<HandSignShortcut.MaidFingerData>();
  767. }
  768. [Serializable]
  769. public class MaidFingerData
  770. {
  771. public MaidFingerData(string name, Quaternion[] leftFingerData, Quaternion[] rightFingerData)
  772. {
  773. if (leftFingerData.Length != 15)
  774. {
  775. string message = "[HandSignShortcut.MaidFingerData] 項目「" + name + "」の左手指データ数が不正です";
  776. Debug.LogError(message);
  777. NDebug.Assert(message, false);
  778. }
  779. if (rightFingerData.Length != 15)
  780. {
  781. string message2 = "[HandSignShortcut.MaidFingerData] 項目「" + name + "」の右手指データ数が不正です";
  782. Debug.LogError(message2);
  783. NDebug.Assert(message2, false);
  784. }
  785. this.name = name;
  786. this.leftFingerData = leftFingerData;
  787. this.rightFingerData = rightFingerData;
  788. }
  789. public MaidFingerData()
  790. {
  791. }
  792. public string name
  793. {
  794. get
  795. {
  796. return this.m_Name;
  797. }
  798. set
  799. {
  800. this.m_Name = value;
  801. }
  802. }
  803. public Quaternion[] leftFingerData
  804. {
  805. get
  806. {
  807. return this.m_LeftFingerRotArray;
  808. }
  809. set
  810. {
  811. this.m_LeftFingerRotArray = value;
  812. }
  813. }
  814. public Quaternion[] rightFingerData
  815. {
  816. get
  817. {
  818. return this.m_RightFingerRotArray;
  819. }
  820. set
  821. {
  822. this.m_RightFingerRotArray = value;
  823. }
  824. }
  825. public void GetMaidFingerData(Maid maid)
  826. {
  827. this.leftFingerData = new Quaternion[HandSignShortcut.strHandBoneNameL.Length];
  828. this.rightFingerData = new Quaternion[HandSignShortcut.strHandBoneNameR.Length];
  829. Transform t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true);
  830. string[] array = HandSignShortcut.strHandBoneNameL;
  831. for (int i = 0; i < array.Length; i++)
  832. {
  833. this.leftFingerData[i] = CMT.SearchObjName(t, array[i], true).localRotation;
  834. }
  835. t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true);
  836. array = HandSignShortcut.strHandBoneNameR;
  837. for (int j = 0; j < array.Length; j++)
  838. {
  839. this.rightFingerData[j] = CMT.SearchObjName(t, array[j], true).localRotation;
  840. }
  841. }
  842. public void ApplyMaidFingerData(Maid maid)
  843. {
  844. Transform transform = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true);
  845. string[] array = HandSignShortcut.strHandBoneNameL;
  846. for (int i = 0; i < array.Length; i++)
  847. {
  848. CMT.SearchObjName(maid.body0.m_Bones.transform, array[i], true).localRotation = this.leftFingerData[i];
  849. }
  850. transform = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true);
  851. array = HandSignShortcut.strHandBoneNameR;
  852. for (int j = 0; j < array.Length; j++)
  853. {
  854. CMT.SearchObjName(maid.body0.m_Bones.transform, array[j], true).localRotation = this.rightFingerData[j];
  855. }
  856. }
  857. public static HandSignShortcut.MaidFingerData Get(string name)
  858. {
  859. HandSignShortcut.MaidFingerData.CreateDataDic();
  860. HandSignShortcut.MaidFingerData result;
  861. HandSignShortcut.MaidFingerData.m_DataDic.TryGetValue(name, out result);
  862. return result;
  863. }
  864. public static void Add(HandSignShortcut.MaidFingerData data)
  865. {
  866. HandSignShortcut.MaidFingerData.CreateDataDic();
  867. if (data == null)
  868. {
  869. Debug.Log("[HandSignShortcut.MaidFingerData] 登録するデータが null でした");
  870. return;
  871. }
  872. if (HandSignShortcut.MaidFingerData.m_DataDic.ContainsKey(data.name))
  873. {
  874. Debug.Log("[HandSignShortcut.MaidFingerData] 既に「" + data.name + "」が登録されています");
  875. return;
  876. }
  877. HandSignShortcut.MaidFingerData.m_DataDic.Add(data.name, data);
  878. HandSignShortcut.config.maidFingerDataList.Add(data);
  879. }
  880. private static void CreateDataDic()
  881. {
  882. if (HandSignShortcut.MaidFingerData.m_DataDic != null)
  883. {
  884. return;
  885. }
  886. HandSignShortcut.MaidFingerData.m_DataDic = new Dictionary<string, HandSignShortcut.MaidFingerData>();
  887. foreach (HandSignShortcut.MaidFingerData maidFingerData in HandSignShortcut.config.maidFingerDataList)
  888. {
  889. HandSignShortcut.MaidFingerData.m_DataDic.Add(maidFingerData.name, maidFingerData);
  890. }
  891. }
  892. [SerializeField]
  893. private string m_Name;
  894. [SerializeField]
  895. private Quaternion[] m_LeftFingerRotArray;
  896. [SerializeField]
  897. private Quaternion[] m_RightFingerRotArray;
  898. private static Dictionary<string, HandSignShortcut.MaidFingerData> m_DataDic;
  899. }
  900. private class ItemData : MonoBehaviour
  901. {
  902. public HandSignShortcut.MaidFingerData data
  903. {
  904. get
  905. {
  906. return this.m_Data;
  907. }
  908. set
  909. {
  910. this.m_Data = value;
  911. this.UpdateText();
  912. }
  913. }
  914. public Text text { get; set; }
  915. private void UpdateText()
  916. {
  917. if (this.text == null)
  918. {
  919. return;
  920. }
  921. if (this.m_Data == null)
  922. {
  923. this.text.text = "自由モード";
  924. }
  925. else
  926. {
  927. this.text.text = this.m_Data.name;
  928. }
  929. }
  930. private HandSignShortcut.MaidFingerData m_Data;
  931. }
  932. private enum Finger
  933. {
  934. Thumb,
  935. Index,
  936. Middle,
  937. Ring,
  938. Little,
  939. Max
  940. }
  941. }