OvrIK.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using RootMotion.FinalIK;
  7. using UnityEngine;
  8. using wf;
  9. public class OvrIK : MonoBehaviour
  10. {
  11. public OvrIK()
  12. {
  13. Quaternion[,] array = new Quaternion[4, 15];
  14. array[0, 0] = new Quaternion(1.379457E-08f, -1.907173E-10f, -0.1001217f, 0.9949752f);
  15. array[0, 1] = new Quaternion(-3.348364E-08f, -2.288052E-09f, -0.05697599f, 0.9983756f);
  16. array[0, 2] = new Quaternion(0.4853954f, -0.1902075f, 0.1155978f, 0.8454878f);
  17. array[0, 3] = new Quaternion(-2.555888E-09f, 1.190041E-09f, -0.08838178f, 0.9960867f);
  18. array[0, 4] = new Quaternion(-3.708266E-09f, -4.232382E-11f, -0.1423017f, 0.9898233f);
  19. array[0, 5] = new Quaternion(0.005196964f, -0.009313619f, -0.07643344f, 0.9970177f);
  20. array[0, 6] = new Quaternion(1.469708E-09f, -2.337872E-09f, -0.08838177f, 0.9960867f);
  21. array[0, 7] = new Quaternion(-4.677417E-09f, -1.311283E-08f, -0.1086997f, 0.9940746f);
  22. array[0, 8] = new Quaternion(-0.001879324f, -0.005337666f, -0.0991221f, 0.9950592f);
  23. array[0, 9] = new Quaternion(-8.490085E-09f, -1.805363E-09f, -0.0796621f, 0.9968219f);
  24. array[0, 10] = new Quaternion(2.300491E-09f, 3.334659E-09f, -0.1239805f, 0.9922847f);
  25. array[0, 11] = new Quaternion(-0.006921342f, 0.001893361f, -0.09829046f, 0.9951319f);
  26. array[0, 12] = new Quaternion(-5.701029E-09f, -1.521331E-09f, -0.05449884f, 0.9985139f);
  27. array[0, 13] = new Quaternion(3.803335E-09f, -5.725684E-09f, -0.1423017f, 0.9898233f);
  28. array[0, 14] = new Quaternion(-0.01357147f, 0.02850812f, -0.08513741f, 0.9958689f);
  29. array[1, 0] = new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f);
  30. array[1, 1] = new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f);
  31. array[1, 2] = new Quaternion(0.7708589f, -0.2672266f, 0.03713043f, 0.577051f);
  32. array[1, 3] = new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f);
  33. array[1, 4] = new Quaternion(-5.034789E-09f, -5.799267E-09f, -0.8191521f, 0.5735765f);
  34. array[1, 5] = new Quaternion(0.0478053f, -0.01974053f, -0.5880075f, 0.8072003f);
  35. array[1, 6] = new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f);
  36. array[1, 7] = new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f);
  37. array[1, 8] = new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f);
  38. array[1, 9] = new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f);
  39. array[1, 10] = new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f);
  40. array[1, 11] = new Quaternion(-0.04368013f, 0.007996441f, -0.6048046f, 0.7951349f);
  41. array[1, 12] = new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008097f, 0.8655574f);
  42. array[1, 13] = new Quaternion(4.887594E-09f, -3.295959E-08f, -0.8191521f, 0.5735765f);
  43. array[1, 14] = new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987924f);
  44. array[2, 0] = new Quaternion(-1.299039E-08f, 7.939377E-10f, -0.08632442f, 0.9962671f);
  45. array[2, 1] = new Quaternion(-1.412307E-08f, -4.882294E-09f, -0.05340298f, 0.9985731f);
  46. array[2, 2] = new Quaternion(-0.4710969f, 0.1764064f, 0.1206711f, 0.8557962f);
  47. array[2, 3] = new Quaternion(-1.785701E-09f, -1.246846E-08f, -0.06366991f, 0.9979711f);
  48. array[2, 4] = new Quaternion(-5.778726E-11f, -1.242248E-08f, -0.1014653f, 0.9948391f);
  49. array[2, 5] = new Quaternion(-0.002611603f, 0.001185287f, -0.04763259f, 0.9988608f);
  50. array[2, 6] = new Quaternion(1.790176E-09f, -1.245129E-08f, -0.0636699f, 0.9979711f);
  51. array[2, 7] = new Quaternion(5.652268E-09f, 1.780454E-09f, -0.06771687f, 0.9977046f);
  52. array[2, 8] = new Quaternion(0.001466242f, 0.004677885f, -0.07036161f, 0.9975095f);
  53. array[2, 9] = new Quaternion(7.64029E-09f, 7.058498E-09f, -0.05493468f, 0.99849f);
  54. array[2, 10] = new Quaternion(-2.104634E-09f, -7.598384E-09f, -0.08305829f, 0.9965447f);
  55. array[2, 11] = new Quaternion(0.004817214f, 0.003811401f, -0.0695642f, 0.9975586f);
  56. array[2, 12] = new Quaternion(2.864904E-09f, -1.440215E-08f, -0.02973721f, 0.9995578f);
  57. array[2, 13] = new Quaternion(-7.071282E-10f, -5.241497E-09f, -0.1014653f, 0.9948391f);
  58. array[2, 14] = new Quaternion(0.00861063f, -0.01516612f, -0.05657673f, 0.998246f);
  59. array[3, 0] = new Quaternion(7.66758E-09f, -1.102812E-08f, -0.3665012f, 0.9304176f);
  60. array[3, 1] = new Quaternion(-8.709043E-09f, -7.065411E-09f, -0.1618618f, 0.9868135f);
  61. array[3, 2] = new Quaternion(-0.7708589f, 0.2672265f, 0.03713048f, 0.577051f);
  62. array[3, 3] = new Quaternion(-8.292553E-09f, 7.889813E-10f, -0.5299194f, 0.8480481f);
  63. array[3, 4] = new Quaternion(6.103158E-09f, 4.273478E-09f, -0.8191521f, 0.5735765f);
  64. array[3, 5] = new Quaternion(-0.0478053f, 0.01974053f, -0.5880075f, 0.8072003f);
  65. array[3, 6] = new Quaternion(-1.288366E-08f, 7.501511E-09f, -0.5299194f, 0.8480481f);
  66. array[3, 7] = new Quaternion(1.786481E-08f, 1.343313E-08f, -0.7992581f, 0.6009881f);
  67. array[3, 8] = new Quaternion(0.009090304f, 0.01649068f, -0.6061373f, 0.7951371f);
  68. array[3, 9] = new Quaternion(1.513849E-08f, -3.815058E-09f, -0.5224782f, 0.8526527f);
  69. array[3, 10] = new Quaternion(-1.643181E-08f, -2.748009E-09f, -0.8084095f, 0.5886205f);
  70. array[3, 11] = new Quaternion(0.04368011f, -0.007996418f, -0.6048046f, 0.7951349f);
  71. array[3, 12] = new Quaternion(1.196498E-08f, -9.074872E-09f, -0.5008097f, 0.8655574f);
  72. array[3, 13] = new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.8191521f, 0.5735765f);
  73. array[3, 14] = new Quaternion(0.09800829f, -0.0545494f, -0.5910579f, 0.7987924f);
  74. this.m_aryHandRot = array;
  75. this.m_listDefaultPose = new List<KeyValuePair<Transform, Transform>>();
  76. this.m_vPelvisPosOffs = Vector3.zero;
  77. this.m_vPelvisRotOffs = Vector3.zero;
  78. this.m_listTrackerMeshRnder = new List<MeshRenderer>();
  79. this.m_fEyeToCamThresholdAngle = -0.9f;
  80. this.m_bEyeTocam = true;
  81. this.offsy = -0.06f;
  82. this.m_nShincho = -1;
  83. this.m_nDouPer = -1;
  84. this.m_nKubiScl = -1;
  85. base..ctor();
  86. }
  87. public static OvrIK Instance
  88. {
  89. get
  90. {
  91. return OvrIK.m_this;
  92. }
  93. }
  94. public static bool IsVRIKMode
  95. {
  96. get
  97. {
  98. return OvrIK.m_this != null && (OvrIK.IsModeVRIK || OvrIK.m_coCalibrate != null);
  99. }
  100. }
  101. public static bool IsModeVRIK { get; set; }
  102. private void DefaultPose()
  103. {
  104. string[] array = new string[]
  105. {
  106. "Bip01",
  107. "Bip01 Pelvis",
  108. "Bip01 Spine",
  109. "Bip01 Spine0a",
  110. "Bip01 Spine1",
  111. "Bip01 Spine1a",
  112. "Bip01 Neck",
  113. "Bip01 Head",
  114. "Bip01 L Clavicle",
  115. "Bip01 L UpperArm",
  116. "Bip01 L Forearm",
  117. "Bip01 L Hand",
  118. "Bip01 L Finger0",
  119. "Bip01 L Finger01",
  120. "Bip01 L Finger02",
  121. "Bip01 L Finger1",
  122. "Bip01 L Finger11",
  123. "Bip01 L Finger12",
  124. "Bip01 L Finger2",
  125. "Bip01 L Finger21",
  126. "Bip01 L Finger22",
  127. "Bip01 L Finger3",
  128. "Bip01 L Finger31",
  129. "Bip01 L Finger32",
  130. "Bip01 L Finger4",
  131. "Bip01 L Finger41",
  132. "Bip01 L Finger42",
  133. "Bip01 R Clavicle",
  134. "Bip01 R UpperArm",
  135. "Bip01 R Forearm",
  136. "Bip01 R Hand",
  137. "Bip01 R Finger0",
  138. "Bip01 R Finger01",
  139. "Bip01 R Finger02",
  140. "Bip01 R Finger1",
  141. "Bip01 R Finger11",
  142. "Bip01 R Finger12",
  143. "Bip01 R Finger2",
  144. "Bip01 R Finger21",
  145. "Bip01 R Finger22",
  146. "Bip01 R Finger3",
  147. "Bip01 R Finger31",
  148. "Bip01 R Finger32",
  149. "Bip01 R Finger4",
  150. "Bip01 R Finger41",
  151. "Bip01 R Finger42",
  152. "Bip01 L Thigh",
  153. "Bip01 L Calf",
  154. "Bip01 L Foot",
  155. "Bip01 L Toe2",
  156. "Bip01 L Toe21",
  157. "Bip01 L Toe1",
  158. "Bip01 L Toe11",
  159. "Bip01 L Toe0",
  160. "Bip01 L Toe01",
  161. "Bip01 R Thigh",
  162. "Bip01 R Calf",
  163. "Bip01 R Foot",
  164. "Bip01 R Toe2",
  165. "Bip01 R Toe21",
  166. "Bip01 R Toe1",
  167. "Bip01 R Toe11",
  168. "Bip01 R Toe0",
  169. "Bip01 R Toe01"
  170. };
  171. this.m_maid.body0.m_Bones.transform.position = Vector3.zero;
  172. this.m_maid.body0.m_Bones.transform.rotation = Quaternion.identity;
  173. foreach (string text in array)
  174. {
  175. Transform transform = CMT.SearchObjName(this.m_maid.body0.m_Bones2.transform, text, true);
  176. Transform transform2 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, text, true);
  177. if (transform != null && transform2 != null)
  178. {
  179. transform2.localRotation = transform.localRotation;
  180. if (text == "Bip01")
  181. {
  182. transform2.localPosition = transform.localPosition;
  183. }
  184. }
  185. }
  186. Transform transform3 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Thigh", true);
  187. transform3.localRotation = Quaternion.Euler(4.194572f, 175.3248f, -30.72415f);
  188. Transform transform4 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Calf", true);
  189. transform4.localRotation = Quaternion.Euler(-4.30072f, -1.857178f, 27.6982f);
  190. Transform transform5 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Thigh", true);
  191. transform5.localRotation = Quaternion.Euler(2.152464f, -178.752f, -30.914f);
  192. Transform transform6 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Calf", true);
  193. transform6.localRotation = Quaternion.Euler(-4.30072f, 1.857178f, 27.6982f);
  194. }
  195. public Maid NowMaid
  196. {
  197. get
  198. {
  199. return this.m_maid;
  200. }
  201. }
  202. public Transform EyeTargetTrs
  203. {
  204. get
  205. {
  206. return this.m_trEyeTarget;
  207. }
  208. }
  209. public bool EyeToCam
  210. {
  211. get
  212. {
  213. return this.m_bEyeTocam;
  214. }
  215. set
  216. {
  217. this.m_bEyeTocam = value;
  218. }
  219. }
  220. public static ControllerShortcutWindow CreateUI()
  221. {
  222. if (OvrIK.m_goVRIKConfigUI == null)
  223. {
  224. UnityEngine.Object original = Resources.Load("OVR/CircleCommandUI/Parent Controller Shortcut Setter Window");
  225. OvrIK.m_goVRIKConfigUI = (UnityEngine.Object.Instantiate(original) as GameObject);
  226. GameObject gameObject = GameObject.Find("SystemUI Root");
  227. OvrIK.m_goVRIKConfigUI.transform.SetParent(gameObject.transform, false);
  228. }
  229. if (OvrIK.m_VRIKConfigCompo == null)
  230. {
  231. OvrIK.m_VRIKConfigCompo = OvrIK.m_goVRIKConfigUI.GetComponent<ControllerShortcutWindow>();
  232. }
  233. return OvrIK.m_VRIKConfigCompo;
  234. }
  235. public static void InitStart()
  236. {
  237. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  238. if (maid != null)
  239. {
  240. OvrIK.m_this = maid.gameObject.GetComponent<OvrIK>();
  241. if (OvrIK.m_this == null)
  242. {
  243. OvrIK.m_this = maid.gameObject.AddComponent<OvrIK>();
  244. }
  245. if (!OvrIK.IsVRIKMode)
  246. {
  247. OvrIK.m_this.CalibrationStart();
  248. }
  249. }
  250. }
  251. public static void UninitEnd()
  252. {
  253. if (OvrIK.m_this != null)
  254. {
  255. OvrIK.m_this.Finish();
  256. }
  257. }
  258. public void CalibrationStart()
  259. {
  260. if (OvrIK.m_coCalibrate == null)
  261. {
  262. if (!this.Init())
  263. {
  264. return;
  265. }
  266. OvrIK.m_coCalibrate = base.StartCoroutine(this.CoCalibrate());
  267. }
  268. }
  269. private IEnumerator CoCalibrate()
  270. {
  271. yield return new WaitForSeconds(5f);
  272. this.Calibration();
  273. OvrIK.m_coCalibrate = null;
  274. yield break;
  275. }
  276. public void Finish()
  277. {
  278. if (OvrIK.m_coCalibrate != null)
  279. {
  280. base.StopCoroutine(OvrIK.m_coCalibrate);
  281. OvrIK.m_coCalibrate = null;
  282. }
  283. this.Uninit(true);
  284. }
  285. public void SelfShotCam()
  286. {
  287. if (this.m_coSelfShotCam != null)
  288. {
  289. this.m_coSelfShotCam.StartCountSnap();
  290. }
  291. }
  292. private void Uninit(bool bDestroyVRIKConfigUI = true)
  293. {
  294. OvrIK.IsModeVRIK = false;
  295. if (this.m_maid != null)
  296. {
  297. this.m_ik = this.m_maid.gameObject.GetComponent<VRIK>();
  298. if (this.m_ik != null)
  299. {
  300. UnityEngine.Object.Destroy(this.m_ik);
  301. Vector3 vector = GameMain.Instance.OvrMgr.OvrCamera.GetPos();
  302. vector += this.m_maid.transform.forward;
  303. GameMain.Instance.OvrMgr.OvrCamera.SetPos(vector);
  304. }
  305. this.m_ik = null;
  306. GameMain.Instance.OvrMgr.OvrCamera.HandVRIKMode = false;
  307. GameObject obj = this.m_maid.body0.GetSlot(1).obj;
  308. this.LayerCheck(obj, LayerMask.NameToLayer("Charactor"));
  309. Animation componentInChildren = this.m_maid.GetComponentInChildren<Animation>();
  310. if (componentInChildren != null)
  311. {
  312. componentInChildren.enabled = true;
  313. }
  314. if (this.m_aryBackAMTween != null)
  315. {
  316. foreach (AMTween amtween in this.m_aryBackAMTween)
  317. {
  318. if (amtween != null)
  319. {
  320. amtween.enabled = true;
  321. }
  322. }
  323. this.m_aryBackAMTween = null;
  324. }
  325. this.m_maid.boOffsetY = true;
  326. this.m_maid.SetMicLipSync(false);
  327. this.m_maid.SetPos(this.m_vBackPos);
  328. this.m_maid.SetRot(this.m_vBackRot);
  329. this.m_maid.body0.m_Bones.transform.localPosition = this.m_vBackRootPos;
  330. this.m_maid.body0.m_Bones.transform.localRotation = this.m_qBackRootRot;
  331. this.m_maid.SetAutoTwist(Maid.AutoTwist.ShoulderL, this.m_bBackAutoTwistShoulderL);
  332. this.m_maid.SetAutoTwist(Maid.AutoTwist.ShoulderR, this.m_bBackAutoTwistShoulderR);
  333. this.m_maid.SetAutoTwist(Maid.AutoTwist.WristL, this.m_bBackAutoTwistWristL);
  334. this.m_maid.SetAutoTwist(Maid.AutoTwist.WristR, this.m_bBackAutoTwistWristR);
  335. this.m_maid.SetAutoTwist(Maid.AutoTwist.ThighL, this.m_bBackAutoTwistThighL);
  336. this.m_maid.SetAutoTwist(Maid.AutoTwist.ThighR, this.m_bBackAutoTwistThighR);
  337. MaidColliderCollect.SuspendColliderAll(this.m_maid, true);
  338. this.m_maid.EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  339. this.m_maid = null;
  340. }
  341. this.m_listTrackerMeshRnder.Clear();
  342. this.m_listDefaultPose.Clear();
  343. if (this.m_goDefaultPoseParent != null)
  344. {
  345. UnityEngine.Object.Destroy(this.m_goDefaultPoseParent);
  346. }
  347. if (this.m_goIKTargetParent != null)
  348. {
  349. UnityEngine.Object.Destroy(this.m_goIKTargetParent);
  350. }
  351. if (this.m_trTargetOffsHead != null)
  352. {
  353. UnityEngine.Object.Destroy(this.m_trTargetOffsHead.gameObject);
  354. }
  355. if (this.m_trTargetOffsPelvis != null)
  356. {
  357. UnityEngine.Object.Destroy(this.m_trTargetOffsPelvis.gameObject);
  358. }
  359. if (this.m_trTargetOffsHandL != null)
  360. {
  361. UnityEngine.Object.Destroy(this.m_trTargetOffsHandL.gameObject);
  362. }
  363. if (this.m_trTargetOffsHandR != null)
  364. {
  365. UnityEngine.Object.Destroy(this.m_trTargetOffsHandR.gameObject);
  366. }
  367. if (this.m_trTargetOffsFootL != null)
  368. {
  369. UnityEngine.Object.Destroy(this.m_trTargetOffsFootL.gameObject);
  370. }
  371. if (this.m_trTargetOffsFootR != null)
  372. {
  373. UnityEngine.Object.Destroy(this.m_trTargetOffsFootR.gameObject);
  374. }
  375. if (this.m_trTargetOffsHeadTracker != null)
  376. {
  377. UnityEngine.Object.Destroy(this.m_trTargetOffsHeadTracker.gameObject);
  378. }
  379. if (this.m_self_shot_cam != null)
  380. {
  381. UnityEngine.Object.Destroy(this.m_self_shot_cam);
  382. }
  383. if (this.m_goMoni != null)
  384. {
  385. UnityEngine.Object.Destroy(this.m_goMoni);
  386. }
  387. if (this.m_FaceCompoL != null)
  388. {
  389. UnityEngine.Object.Destroy(this.m_FaceCompoL);
  390. }
  391. if (this.m_FaceCompoR != null)
  392. {
  393. UnityEngine.Object.Destroy(this.m_FaceCompoR);
  394. }
  395. if (this.m_coHandSignL != null)
  396. {
  397. UnityEngine.Object.Destroy(this.m_coHandSignL);
  398. }
  399. if (this.m_coHandSignR != null)
  400. {
  401. UnityEngine.Object.Destroy(this.m_coHandSignR);
  402. }
  403. if (this.m_coOtherCmdL != null)
  404. {
  405. UnityEngine.Object.Destroy(this.m_coOtherCmdL);
  406. }
  407. if (this.m_coOtherCmdR != null)
  408. {
  409. UnityEngine.Object.Destroy(this.m_coOtherCmdR);
  410. }
  411. if (bDestroyVRIKConfigUI && OvrIK.m_goVRIKConfigUI != null)
  412. {
  413. UnityEngine.Object.Destroy(OvrIK.m_goVRIKConfigUI);
  414. }
  415. GameMain.Instance.OvrMgr.OvrCamera.HandModelVisible = true;
  416. GameMain.Instance.OvrMgr.OvrCamera.SetCameraMask(CameraMain.CameraMask.OvrTouchLookObj, false);
  417. }
  418. private bool Init()
  419. {
  420. this.Uninit(false);
  421. this.m_maid = base.GetComponent<Maid>();
  422. NDebug.Assert(this.m_maid != null, "メイドが居ません。");
  423. if (!this.m_maid.Visible || this.m_maid.IsBusy || !this.m_maid.body0.isLoadedBody)
  424. {
  425. Debug.Log("OVRIK 未だメイドの準備ができていません。");
  426. return false;
  427. }
  428. Animation componentInChildren = this.m_maid.GetComponentInChildren<Animation>();
  429. componentInChildren.enabled = false;
  430. this.m_aryBackAMTween = this.m_maid.GetComponentsInChildren<AMTween>(true);
  431. if (this.m_aryBackAMTween != null)
  432. {
  433. foreach (AMTween amtween in this.m_aryBackAMTween)
  434. {
  435. if (amtween != null)
  436. {
  437. amtween.enabled = false;
  438. }
  439. }
  440. }
  441. this.m_bBackAutoTwistShoulderL = this.m_maid.body0.boAutoTwistShoulderL;
  442. this.m_bBackAutoTwistShoulderR = this.m_maid.body0.boAutoTwistShoulderR;
  443. this.m_bBackAutoTwistWristL = this.m_maid.body0.boAutoTwistWristL;
  444. this.m_bBackAutoTwistWristR = this.m_maid.body0.boAutoTwistWristR;
  445. this.m_bBackAutoTwistThighL = this.m_maid.body0.boAutoTwistThighL;
  446. this.m_bBackAutoTwistThighR = this.m_maid.body0.boAutoTwistThighR;
  447. this.m_maid.SetAutoTwistAll(true);
  448. this.m_vBackPos = this.m_maid.GetPos();
  449. this.m_vBackRot = this.m_maid.GetRot();
  450. this.m_vBackRootPos = this.m_maid.body0.m_Bones.transform.localPosition;
  451. this.m_qBackRootRot = this.m_maid.body0.m_Bones.transform.localRotation;
  452. this.m_maid.EyeToCamera(Maid.EyeMoveType.無し, 0f);
  453. this.m_maid.boOffsetY = false;
  454. this.DefaultPose();
  455. this.m_maid.SetPos(Vector3.zero);
  456. this.m_maid.SetRot(Vector3.zero);
  457. this.m_maid.SetMicLipSync(true);
  458. Transform transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Thigh", true);
  459. Quaternion localRotation = transform.localRotation;
  460. transform.localRotation = Quaternion.Euler(5.025288f, -179.97f, -9.849731f);
  461. Transform transform2 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Calf", true);
  462. Quaternion localRotation2 = transform2.localRotation;
  463. transform2.localRotation = Quaternion.Euler(-4.30072f, -1.857178f, 2.579935f);
  464. Transform transform3 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Thigh", true);
  465. Quaternion localRotation3 = transform3.localRotation;
  466. transform3.localRotation = Quaternion.Euler(5.025289f, -179.97f, -9.849731f);
  467. Transform transform4 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Calf", true);
  468. Quaternion localRotation4 = transform4.localRotation;
  469. transform4.localRotation = Quaternion.Euler(-4.30072f, 1.857178f, 2.579935f);
  470. Transform transform5 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Foot", true);
  471. this.m_maid.transform.position = new Vector3(0f, this.m_maid.transform.position.y - transform5.position.y + 0.13f, 0f);
  472. transform.localRotation = localRotation;
  473. transform2.localRotation = localRotation2;
  474. transform3.localRotation = localRotation3;
  475. transform4.localRotation = localRotation4;
  476. Transform t = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Hand", true);
  477. Transform t2 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Hand", true);
  478. this.m_trHandL = new Transform[this.m_strHandBoneNameL.Length];
  479. this.m_trHandR = new Transform[this.m_strHandBoneNameR.Length];
  480. for (int j = 0; j < this.m_strHandBoneNameL.Length; j++)
  481. {
  482. this.m_trHandL[j] = CMT.SearchObjName(t, this.m_strHandBoneNameL[j], true);
  483. this.m_trHandR[j] = CMT.SearchObjName(t2, this.m_strHandBoneNameR[j], true);
  484. }
  485. return true;
  486. }
  487. private void FindAndAddParent(Transform trChild, string f_strStopBone, bool f_bParentConnect = false)
  488. {
  489. if (trChild.name == f_strStopBone)
  490. {
  491. return;
  492. }
  493. GameObject gameObject = new GameObject(trChild.name);
  494. gameObject.transform.position = trChild.position;
  495. gameObject.transform.rotation = trChild.rotation;
  496. if (this.m_listDefaultPose.Count != 0 && f_bParentConnect)
  497. {
  498. this.m_listDefaultPose[this.m_listDefaultPose.Count - 1].Value.SetParent(gameObject.transform);
  499. }
  500. this.m_listDefaultPose.Add(new KeyValuePair<Transform, Transform>(trChild, gameObject.transform));
  501. if (trChild.parent != null)
  502. {
  503. this.FindAndAddParent(trChild.parent, f_strStopBone, true);
  504. }
  505. }
  506. private void LayerCheck(GameObject goParent, int nLayer)
  507. {
  508. if (goParent == null)
  509. {
  510. return;
  511. }
  512. try
  513. {
  514. for (int i = 0; i < goParent.transform.childCount; i++)
  515. {
  516. this.LayerCheck(goParent.transform.GetChild(i).gameObject, nLayer);
  517. }
  518. goParent.layer = nLayer;
  519. }
  520. catch (Exception message)
  521. {
  522. Debug.LogError(message);
  523. }
  524. }
  525. private void Calibration()
  526. {
  527. OvrIK.IsModeVRIK = true;
  528. MaidColliderCollect.SuspendColliderAll(this.m_maid, false);
  529. this.m_ik = this.m_maid.gameObject.GetComponent<VRIK>();
  530. if (this.m_ik == null)
  531. {
  532. this.m_ik = this.m_maid.gameObject.AddComponent<VRIK>();
  533. }
  534. OvrIK.m_conf = OvrIK.m_conf.Read();
  535. OvrIK.m_conf.Update(this.m_ik);
  536. this.m_fEyeToCamThresholdAngle = OvrIK.m_conf.m_fEyeToCamThresholdAngle;
  537. VRIK.References references = this.m_ik.references;
  538. string text = "Bip01";
  539. if (this.m_maid.boMAN)
  540. {
  541. text = "ManBip";
  542. }
  543. references.root = this.m_maid.body0.m_Bones.transform;
  544. references.pelvis = references.root.Find(text);
  545. references.spine = this.m_maid.body0.Spine;
  546. references.chest = this.m_maid.body0.Spine1a;
  547. references.neck = this.m_maid.body0.trsNeck;
  548. references.head = this.m_maid.body0.trsHead;
  549. references.leftShoulder = this.m_maid.body0.ClavicleL;
  550. references.leftUpperArm = this.m_maid.body0.UpperArmL;
  551. references.leftForearm = references.leftUpperArm.Find(text + " L Forearm");
  552. references.leftHand = references.leftForearm.Find(text + " L Hand");
  553. references.rightShoulder = this.m_maid.body0.ClavicleR;
  554. references.rightUpperArm = this.m_maid.body0.UpperArmR;
  555. references.rightForearm = references.rightUpperArm.Find(text + " R Forearm");
  556. references.rightHand = references.rightForearm.Find(text + " R Hand");
  557. references.leftThigh = this.m_maid.body0.Thigh_L;
  558. references.leftCalf = this.m_maid.body0.Calf_L;
  559. references.leftFoot = references.leftCalf.Find(text + " L Foot");
  560. references.rightThigh = this.m_maid.body0.Thigh_R;
  561. references.rightCalf = this.m_maid.body0.Calf_R;
  562. references.rightFoot = references.rightCalf.Find(text + " R Foot");
  563. this.m_ik.solver.leftLeg.positionWeight = 1f;
  564. this.m_ik.solver.leftLeg.rotationWeight = 1f;
  565. this.m_ik.solver.leftLeg.bendGoalWeight = 1f;
  566. this.m_ik.solver.rightLeg.positionWeight = 1f;
  567. this.m_ik.solver.rightLeg.rotationWeight = 1f;
  568. this.m_ik.solver.rightLeg.bendGoalWeight = 1f;
  569. this.m_ik.solver.plantFeet = false;
  570. if (this.m_goIKTargetParent != null)
  571. {
  572. UnityEngine.Object.Destroy(this.m_goIKTargetParent);
  573. }
  574. this.m_goIKTargetParent = new GameObject("VRIK Dummy Targets");
  575. Transform transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 Head", true);
  576. this.m_trTargetOffsHead = new GameObject("VRIK Target Offs Head").transform;
  577. this.m_trTargetOffsHead.position = transform.position;
  578. this.m_trTargetOffsHead.rotation = transform.rotation;
  579. this.m_trTargetOffsHead.SetParent(this.m_goIKTargetParent.transform, true);
  580. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01", true);
  581. this.m_trTargetOffsPelvis = new GameObject("VRIK Target Offs Pelvis").transform;
  582. this.m_trTargetOffsPelvis.position = transform.position;
  583. this.m_trTargetOffsPelvis.rotation = transform.rotation;
  584. this.m_trTargetOffsPelvis.SetParent(this.m_goIKTargetParent.transform, true);
  585. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Hand", true);
  586. this.m_trTargetOffsHandL = new GameObject("VRIK Target Offs Hand L").transform;
  587. this.m_trTargetOffsHandL.position = transform.position;
  588. this.m_trTargetOffsHandL.rotation = transform.rotation;
  589. this.m_trTargetOffsHandL.SetParent(this.m_goIKTargetParent.transform, true);
  590. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Hand", true);
  591. this.m_trTargetOffsHandR = new GameObject("VRIK Target Offs Hand R").transform;
  592. this.m_trTargetOffsHandR.position = transform.position;
  593. this.m_trTargetOffsHandR.rotation = transform.rotation;
  594. this.m_trTargetOffsHandR.SetParent(this.m_goIKTargetParent.transform, true);
  595. this.m_ik.solver.spine.headTarget = this.m_trTargetOffsHead;
  596. this.m_ik.solver.spine.pelvisTarget = this.m_trTargetOffsPelvis;
  597. this.m_ik.solver.leftArm.target = this.m_trTargetOffsHandL;
  598. this.m_ik.solver.rightArm.target = this.m_trTargetOffsHandR;
  599. this.m_ik.solver.spine.pelvisPositionOffset = this.m_vPelvisPosOffs;
  600. this.m_ik.solver.spine.pelvisRotationOffset = Quaternion.Euler(this.m_vPelvisRotOffs);
  601. this.m_ik.solver.spine.pelvisPositionWeight = 0f;
  602. this.m_ik.solver.spine.headClampWeight = 0f;
  603. this.m_ik.solver.spine.chestRotationWeight = 0.3f;
  604. this.m_ik.solver.spine.chestClampWeight = 0.5f;
  605. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Foot", true);
  606. this.m_trTargetOffsFootL = new GameObject("VRIK Target Offs Foot L").transform;
  607. this.m_trTargetOffsFootL.position = transform.position;
  608. this.m_trTargetOffsFootL.rotation = transform.rotation;
  609. this.m_trTargetOffsFootL.SetParent(this.m_goIKTargetParent.transform, true);
  610. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Foot", true);
  611. this.m_trTargetOffsFootR = new GameObject("VRIK Target Offs Foot R").transform;
  612. this.m_trTargetOffsFootR.position = transform.position;
  613. this.m_trTargetOffsFootR.rotation = transform.rotation;
  614. this.m_trTargetOffsFootR.SetParent(this.m_goIKTargetParent.transform, true);
  615. this.m_ik.solver.leftLeg.target = this.m_trTargetOffsFootL;
  616. this.m_ik.solver.rightLeg.target = this.m_trTargetOffsFootR;
  617. this.m_ik.UpdateSolverExternal();
  618. Transform transform2 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Thigh", true);
  619. transform2.localRotation = Quaternion.Euler(5.025288f, -179.97f, -9.849731f);
  620. Transform transform3 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Calf", true);
  621. transform3.localRotation = Quaternion.Euler(-4.30072f, -1.857178f, 2.579935f);
  622. Transform transform4 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Thigh", true);
  623. transform4.localRotation = Quaternion.Euler(5.025289f, -179.97f, -9.849731f);
  624. Transform transform5 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Calf", true);
  625. transform5.localRotation = Quaternion.Euler(-4.30072f, 1.857178f, 2.579935f);
  626. this.m_listDefaultPose.Clear();
  627. if (this.m_goDefaultPoseParent != null)
  628. {
  629. UnityEngine.Object.Destroy(this.m_goDefaultPoseParent);
  630. }
  631. this.m_goDefaultPoseParent = new GameObject("VRIK Default Pose Parent");
  632. Transform transform6 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01", true).transform;
  633. this.FindAndAddParent(CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Foot", true).transform, "Bip01", false);
  634. GameObject gameObject = new GameObject(transform6.name);
  635. gameObject.transform.SetParent(this.m_goDefaultPoseParent.transform, false);
  636. gameObject.transform.position = transform6.position;
  637. gameObject.transform.rotation = transform6.rotation;
  638. this.m_listDefaultPose[this.m_listDefaultPose.Count - 1].Value.SetParent(gameObject.transform, true);
  639. this.m_listDefaultPose.Add(new KeyValuePair<Transform, Transform>(transform6, gameObject.transform));
  640. this.FindAndAddParent(CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Eyepos_R", false).transform, "Bip01", false);
  641. this.m_listDefaultPose[this.m_listDefaultPose.Count - 1].Value.SetParent(gameObject.transform, true);
  642. this.m_trMaidDefaultPoseEyeR = this.m_listDefaultPose.Find((KeyValuePair<Transform, Transform> a) => a.Key.name == "Eyepos_R").Value;
  643. this.m_trMaidDefaultPoseFootR = this.m_listDefaultPose.Find((KeyValuePair<Transform, Transform> a) => a.Key.name == "Bip01 R Foot").Value;
  644. GameMain.Instance.OvrMgr.OvrCamera.HandModelVisible = false;
  645. Transform hand_trans = GameMain.Instance.OvrMgr.ovr_obj.left_controller.hand_trans;
  646. Transform hand_trans2 = GameMain.Instance.OvrMgr.ovr_obj.right_controller.hand_trans;
  647. this.m_FaceCompoL = hand_trans.gameObject.GetComponent<PhotoFaceDataShortcutParent>();
  648. if (this.m_FaceCompoL == null)
  649. {
  650. this.m_FaceCompoL = hand_trans.gameObject.AddComponent<PhotoFaceDataShortcutParent>();
  651. }
  652. this.m_FaceCompoL.Init(true);
  653. this.m_FaceCompoL.isEnableHandUI = false;
  654. this.m_FaceCompoR = hand_trans2.gameObject.GetComponent<PhotoFaceDataShortcutParent>();
  655. if (this.m_FaceCompoR == null)
  656. {
  657. this.m_FaceCompoR = hand_trans2.gameObject.AddComponent<PhotoFaceDataShortcutParent>();
  658. }
  659. this.m_FaceCompoR.Init(false);
  660. this.m_FaceCompoR.isEnableHandUI = false;
  661. this.m_coHandSignL = hand_trans.gameObject.GetComponent<HandSignShortcut>();
  662. if (this.m_coHandSignL == null)
  663. {
  664. this.m_coHandSignL = hand_trans.gameObject.AddComponent<HandSignShortcut>();
  665. }
  666. this.m_coHandSignL.Init(true);
  667. this.m_coHandSignL.isEnableHandUI = false;
  668. this.m_coHandSignR = hand_trans2.gameObject.GetComponent<HandSignShortcut>();
  669. if (this.m_coHandSignR == null)
  670. {
  671. this.m_coHandSignR = hand_trans2.gameObject.AddComponent<HandSignShortcut>();
  672. }
  673. this.m_coHandSignR.Init(false);
  674. this.m_coHandSignR.isEnableHandUI = false;
  675. this.m_coOtherCmdL = hand_trans.gameObject.GetComponent<OtherCommandShortcut>();
  676. if (this.m_coOtherCmdL == null)
  677. {
  678. this.m_coOtherCmdL = hand_trans.gameObject.AddComponent<OtherCommandShortcut>();
  679. }
  680. this.m_coOtherCmdL.Init(true);
  681. this.m_coOtherCmdL.isEnableHandUI = false;
  682. this.m_coOtherCmdR = hand_trans2.gameObject.GetComponent<OtherCommandShortcut>();
  683. if (this.m_coOtherCmdR == null)
  684. {
  685. this.m_coOtherCmdR = hand_trans2.gameObject.AddComponent<OtherCommandShortcut>();
  686. }
  687. this.m_coOtherCmdR.Init(false);
  688. this.m_coOtherCmdR.isEnableHandUI = false;
  689. if (OvrIK.m_goVRIKConfigUI == null)
  690. {
  691. UnityEngine.Object original = Resources.Load("OVR/CircleCommandUI/Parent Controller Shortcut Setter Window");
  692. OvrIK.m_goVRIKConfigUI = (UnityEngine.Object.Instantiate(original) as GameObject);
  693. GameObject gameObject2 = GameObject.Find("SystemUI Root");
  694. OvrIK.m_goVRIKConfigUI.transform.SetParent(gameObject2.transform, false);
  695. }
  696. if (OvrIK.m_VRIKConfigCompo == null)
  697. {
  698. OvrIK.m_VRIKConfigCompo = OvrIK.m_goVRIKConfigUI.GetComponent<ControllerShortcutWindow>();
  699. }
  700. OvrIK.m_VRIKConfigCompo.Init(this.m_FaceCompoR, this.m_FaceCompoL);
  701. OvrIK.m_VRIKConfigCompo.Open();
  702. GameMain.Instance.OvrMgr.OvrCamera.HandVRIKMode = true;
  703. if (this.m_ik == null)
  704. {
  705. Debug.LogError("未だVRIKが付いていません。");
  706. return;
  707. }
  708. this.m_maid = base.GetComponent<Maid>();
  709. NDebug.Assert(this.m_maid != null, "メイドが居ません。");
  710. this.m_maid.boOffsetY = false;
  711. GameObject obj = this.m_maid.body0.GetSlot(1).obj;
  712. this.LayerCheck(obj, LayerMask.NameToLayer("Face"));
  713. GameObject obj2 = this.m_maid.body0.GetSlot(36).obj;
  714. this.LayerCheck(obj2, LayerMask.NameToLayer("Face"));
  715. GameObject obj3 = this.m_maid.body0.GetSlot(17).obj;
  716. this.LayerCheck(obj3, LayerMask.NameToLayer("Face"));
  717. GameMain.Instance.OvrMgr.OvrCamera.SetCameraMask((CameraMain.CameraMask)LayerMask.NameToLayer("Face"), false);
  718. Transform transform7 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Eyepos_L", false);
  719. Transform transform8 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Eyepos_R", false);
  720. Vector3 vector = transform8.position + (transform7.position - transform8.position) * 0.5f;
  721. this.m_trPlayerDefaultPoseEye = new GameObject("Pair Player Eye").transform;
  722. this.m_trPlayerDefaultPoseEye.SetParent(this.m_goDefaultPoseParent.transform, false);
  723. this.m_trPlayerDefaultPoseEye.position = vector;
  724. GameMain.Instance.OvrMgr.OvrCamera.SetRealHeadPos(vector, false);
  725. GameMain.Instance.OvrMgr.OvrCamera.SetRealHeadRot(new Vector3(0f, 0f, 0f), true);
  726. Transform realHeadTransform = GameMain.Instance.OvrMgr.OvrCamera.GetRealHeadTransform();
  727. Transform hand_trans3 = GameMain.Instance.OvrMgr.ovr_obj.left_controller.hand_trans;
  728. Transform hand_trans4 = GameMain.Instance.OvrMgr.ovr_obj.right_controller.hand_trans;
  729. this.m_trTargetOffsHead.SetParent(realHeadTransform, false);
  730. this.m_trTargetOffsHead.localPosition = new Vector3(0f, -0.03f, -0.05f);
  731. this.m_trTargetOffsHead.localRotation = Quaternion.Euler(0f, -90f, -90f);
  732. this.m_trTargetOffsHandL.SetParent(hand_trans3, false);
  733. this.m_trTargetOffsHandL.localPosition = new Vector3(-0.014f, -0.032f, -0.106f);
  734. this.m_trTargetOffsHandL.localRotation = Quaternion.Euler(74.50851f, -128.3506f, 135.9052f);
  735. this.m_trTargetOffsHandR.SetParent(hand_trans4, false);
  736. this.m_trTargetOffsHandR.localPosition = new Vector3(0.014f, -0.032f, -0.106f);
  737. this.m_trTargetOffsHandR.localRotation = Quaternion.Euler(-83.64291f, 34.33916f, 46.03844f);
  738. this.m_ik.solver.spine.headTarget = this.m_trTargetOffsHead;
  739. this.m_ik.solver.leftArm.target = this.m_trTargetOffsHandL;
  740. this.m_ik.solver.rightArm.target = this.m_trTargetOffsHandR;
  741. AVRTrackingObjectsMgr trackingObjectsMgr = GameMain.Instance.OvrMgr.TrackingObjectsMgr;
  742. if (trackingObjectsMgr != null)
  743. {
  744. trackingObjectsMgr.Refresh();
  745. List<Transform> trackingObjects = trackingObjectsMgr.TrackingObjects;
  746. bool use1TrackerForHead = ControllerShortcutSettingData.config.use1TrackerForHead;
  747. int index = 0;
  748. int index2 = 1;
  749. int index3 = 2;
  750. int num = 2;
  751. int num2 = 3;
  752. if (use1TrackerForHead && 1 <= trackingObjects.Count)
  753. {
  754. Debug.Log("OvrIK トラッカーが1つ見つかりました。ヘッドトラッキングに使えます。");
  755. trackingObjects.Sort((Transform a, Transform b) => (b.transform.position.y - a.transform.position.y >= 0f) ? 1 : -1);
  756. Transform transform9 = trackingObjects[0];
  757. this.m_listTrackerMeshRnder.Add(transform9.GetComponent<MeshRenderer>());
  758. Transform transform10 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 Head", true);
  759. this.m_trTargetOffsHeadTracker = new GameObject("VRIK Target Offs Head Tracker").transform;
  760. this.m_trTargetOffsHeadTracker.position = transform10.position;
  761. this.m_trTargetOffsHeadTracker.rotation = transform10.rotation;
  762. this.m_trTargetOffsHeadTracker.SetParent(transform9, true);
  763. this.m_ik.solver.spine.headTarget = this.m_trTargetOffsHeadTracker;
  764. trackingObjects.Remove(transform);
  765. }
  766. if (num <= trackingObjects.Count)
  767. {
  768. trackingObjects.Sort((Transform a, Transform b) => (a.transform.position.y - b.transform.position.y >= 0f) ? 1 : -1);
  769. if (hand_trans3.position.y < trackingObjects[index].position.y || hand_trans3.position.y < trackingObjects[index2].position.y)
  770. {
  771. Debug.LogError("足のトラッカーは手より下になければなりません。");
  772. }
  773. if ((trackingObjects[index].position - trackingObjects[index2].position).magnitude < 0.1f)
  774. {
  775. Debug.LogError("足は10cm以上広げて下さい。");
  776. }
  777. Transform transform11;
  778. Transform transform12;
  779. if ((hand_trans3.position - trackingObjects[index].position).sqrMagnitude < (hand_trans3.position - trackingObjects[index2].position).sqrMagnitude)
  780. {
  781. transform11 = trackingObjects[index];
  782. transform12 = trackingObjects[index2];
  783. }
  784. else
  785. {
  786. transform11 = trackingObjects[index2];
  787. transform12 = trackingObjects[index];
  788. }
  789. this.m_listTrackerMeshRnder.Add(transform11.GetComponent<MeshRenderer>());
  790. this.m_listTrackerMeshRnder.Add(transform12.GetComponent<MeshRenderer>());
  791. this.m_ik.solver.spine.pelvisPositionOffset = this.m_vPelvisPosOffs;
  792. this.m_ik.solver.spine.pelvisRotationOffset = Quaternion.Euler(this.m_vPelvisRotOffs);
  793. this.m_ik.solver.spine.pelvisPositionWeight = 0f;
  794. this.m_ik.solver.spine.headClampWeight = 0f;
  795. this.m_ik.solver.spine.chestRotationWeight = 0.3f;
  796. this.m_ik.solver.spine.chestClampWeight = 0.5f;
  797. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 L Foot", true);
  798. this.m_trTargetOffsFootL.position = transform.position;
  799. this.m_trTargetOffsFootL.rotation = transform.rotation;
  800. this.m_trTargetOffsFootL.SetParent(transform11, true);
  801. this.m_vFootDefOffsLocalL = this.m_trTargetOffsFootL.localPosition;
  802. this.m_trTargetOffsFootLVecY = new GameObject("Y Vec").transform;
  803. this.m_trTargetOffsFootLVecY.SetParent(this.m_trTargetOffsFootL, false);
  804. this.m_trTargetOffsFootLVecY.localPosition = Vector3.zero;
  805. this.m_trTargetOffsFootLVecY.position += new Vector3(0f, -1f, 0f);
  806. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 R Foot", true);
  807. this.m_trTargetOffsFootR.position = transform.position;
  808. this.m_trTargetOffsFootR.rotation = transform.rotation;
  809. this.m_trTargetOffsFootR.SetParent(transform12, true);
  810. this.m_vFootDefOffsLocalR = this.m_trTargetOffsFootR.localPosition;
  811. this.m_trTargetOffsFootRVecY = new GameObject("Y Vec").transform;
  812. this.m_trTargetOffsFootRVecY.SetParent(this.m_trTargetOffsFootR, false);
  813. this.m_trTargetOffsFootRVecY.localPosition = Vector3.zero;
  814. this.m_trTargetOffsFootRVecY.position += new Vector3(0f, -1f, 0f);
  815. this.m_ik.solver.leftLeg.target = this.m_trTargetOffsFootL;
  816. this.m_ik.solver.rightLeg.target = this.m_trTargetOffsFootR;
  817. this.m_trPlayerDefaultPoseFoot = new GameObject("Pair Player Foot").transform;
  818. this.m_trPlayerDefaultPoseFoot.SetParent(this.m_trPlayerDefaultPoseEye, false);
  819. this.m_trPlayerDefaultPoseFoot.position = this.m_trTargetOffsFootL.position + (this.m_trTargetOffsFootR.position - this.m_trTargetOffsFootL.position) * 0.5f;
  820. this.m_ik.solver.spine.pelvisTarget = null;
  821. if (num2 <= trackingObjects.Count)
  822. {
  823. Transform transform13 = trackingObjects[index3];
  824. this.m_listTrackerMeshRnder.Add(transform13.GetComponent<MeshRenderer>());
  825. if (transform13.position.y >= hand_trans3.position.y)
  826. {
  827. Debug.LogError("腰は頭より下でなければなりません。");
  828. }
  829. if (transform13.position.y <= transform11.position.y || transform13.position.y <= transform12.position.y)
  830. {
  831. Debug.LogError("腰は両足より上でなければなりません。");
  832. }
  833. transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01", true);
  834. this.m_trTargetOffsPelvis.position = transform.position;
  835. this.m_trTargetOffsPelvis.rotation = transform.rotation;
  836. this.m_trTargetOffsPelvis.SetParent(transform13, true);
  837. float num3 = realHeadTransform.transform.position.y - (transform13.position.y - 0.2f);
  838. Transform transform14 = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, "Bip01 Pelvis", true);
  839. float num4 = vector.y - transform14.transform.position.y;
  840. float num5 = num4 - num3;
  841. this.m_ik.solver.spine.pelvisTarget = this.m_trTargetOffsPelvis;
  842. this.m_ik.solver.spine.pelvisPositionWeight = 1f;
  843. }
  844. this.m_bLegTracking = true;
  845. }
  846. else
  847. {
  848. Debug.Log("OvrIK トラッカーは" + num + "つ未満です。足のトラッキングは行いません。");
  849. this.m_bLegTracking = false;
  850. }
  851. }
  852. if (!this.m_bLegTracking)
  853. {
  854. this.m_ik.solver.leftLeg.rotationWeight = (this.m_ik.solver.rightLeg.rotationWeight = OvrIK.m_conf.leg_no_tracker_rot_weight);
  855. this.m_ik.solver.leftLeg.positionWeight = (this.m_ik.solver.rightLeg.positionWeight = OvrIK.m_conf.leg_no_tracker_pos_weight);
  856. }
  857. this.m_self_shot_cam = GameObject.Find("OvrSelfShotCamera");
  858. if (this.m_self_shot_cam == null)
  859. {
  860. this.m_coSelfShotCam = OvrSelfShotCamera.Create();
  861. this.m_self_shot_cam = this.m_coSelfShotCam.gameObject;
  862. this.m_trEyeTarget = this.m_coSelfShotCam.EyeTarget;
  863. this.m_rtMoniPlaneTex = this.m_coSelfShotCam.CamTex;
  864. }
  865. this.m_goMoni = GameObject.Find("OvrIKPlaneCamera");
  866. if (!this.m_goMoni)
  867. {
  868. this.m_goMoni = Utility.CreatePrefab(null, "OVR/OvrIKPlaneCamera", false);
  869. this.m_goMoni.name = "OvrIKPlaneCamera";
  870. this.m_trMoniPlane = this.m_goMoni.transform.Find("Plane").transform;
  871. }
  872. this.m_maid.EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
  873. }
  874. private void ReCalcShincho()
  875. {
  876. if (this.m_trMaidDefaultPoseEyeR == null || this.m_trPlayerDefaultPoseEye == null || this.m_trMaidDefaultPoseFootR == null || this.m_trPlayerDefaultPoseFoot == null || this.m_trTargetOffsFootL == null || this.m_trTargetOffsFootR == null)
  877. {
  878. return;
  879. }
  880. float num = this.m_trMaidDefaultPoseEyeR.position.y - this.m_trMaidDefaultPoseFootR.position.y;
  881. float num2 = this.m_trPlayerDefaultPoseEye.position.y - this.m_trPlayerDefaultPoseFoot.position.y;
  882. float d = num - num2 + this.offsy;
  883. this.m_trTargetOffsFootL.localPosition = this.m_vFootDefOffsLocalL;
  884. this.m_trTargetOffsFootR.localPosition = this.m_vFootDefOffsLocalR;
  885. this.m_trTargetOffsFootL.position += (this.m_trTargetOffsFootLVecY.position - this.m_trTargetOffsFootL.position).normalized * d;
  886. this.m_trTargetOffsFootR.position += (this.m_trTargetOffsFootRVecY.position - this.m_trTargetOffsFootR.position).normalized * d;
  887. }
  888. private void OnDisable()
  889. {
  890. this.Finish();
  891. }
  892. private void OnDestroy()
  893. {
  894. this.Finish();
  895. }
  896. private void Update()
  897. {
  898. if (Input.GetKeyUp(KeyCode.F9))
  899. {
  900. GameObject gameObject = GameObject.Find("TestMonitor");
  901. GameObject gameObject2 = GameObject.Find("TestMonitorR");
  902. if (gameObject != null)
  903. {
  904. UnityEngine.Object.Destroy(gameObject);
  905. UnityEngine.Object @object = Resources.Load("OVR/TestMonitorR");
  906. GameObject gameObject3 = UnityEngine.Object.Instantiate<GameObject>(@object as GameObject);
  907. gameObject3.name = @object.name;
  908. }
  909. if (gameObject2 != null)
  910. {
  911. UnityEngine.Object.Destroy(gameObject2);
  912. UnityEngine.Object object2 = Resources.Load("OVR/TestMonitor");
  913. GameObject gameObject4 = UnityEngine.Object.Instantiate<GameObject>(object2 as GameObject);
  914. gameObject4.name = object2.name;
  915. }
  916. }
  917. if (OvrIK.IsModeVRIK && (this.m_maid == null || !this.m_maid.Visible || !this.m_maid.body0.isLoadedBody))
  918. {
  919. this.Finish();
  920. }
  921. if (this.m_ik != null)
  922. {
  923. if (this.m_maid != null && !this.m_maid.IsBusy)
  924. {
  925. for (int i = 0; i < this.m_listDefaultPose.Count; i++)
  926. {
  927. KeyValuePair<Transform, Transform> item = this.m_listDefaultPose[i];
  928. if (item.Key == null)
  929. {
  930. Transform transform = CMT.SearchObjName(this.m_maid.body0.m_Bones.transform, item.Value.name, false);
  931. if (transform != null)
  932. {
  933. this.m_listDefaultPose[i] = new KeyValuePair<Transform, Transform>(transform, item.Value);
  934. }
  935. else
  936. {
  937. this.m_listDefaultPose.Remove(item);
  938. }
  939. }
  940. if (this.m_trMaidDefaultPoseEyeR == null)
  941. {
  942. Debug.Log("m_trMaidDefaultPoseEyeR");
  943. this.m_trMaidDefaultPoseEyeR = this.m_listDefaultPose.Find((KeyValuePair<Transform, Transform> a) => a.Key.name == "Eyepos_R").Value;
  944. }
  945. if (item.Key != null)
  946. {
  947. item.Value.localPosition = item.Key.localPosition;
  948. }
  949. }
  950. int value = this.m_maid.GetProp(MPN.sintyou).value;
  951. int value2 = this.m_maid.GetProp(MPN.DouPer).value;
  952. int value3 = this.m_maid.GetProp(MPN.KubiScl).value;
  953. if (this.m_nShincho != value || this.m_nDouPer != value2 || this.m_nKubiScl != value3)
  954. {
  955. this.m_nShincho = value;
  956. this.m_nDouPer = value2;
  957. this.m_nKubiScl = value3;
  958. }
  959. if (!this.m_bLegTracking)
  960. {
  961. Vector3 position = this.m_trTargetOffsHead.position;
  962. Vector3 floorPos = GameMain.Instance.OvrMgr.OvrCamera.GetFloorPos(position);
  963. Transform trTargetOffsFootR = this.m_trTargetOffsFootR;
  964. Vector3 position2 = new Vector3(position.x, floorPos.y, position.z);
  965. this.m_trTargetOffsFootL.position = position2;
  966. trTargetOffsFootR.position = position2;
  967. }
  968. }
  969. this.m_ik.solver.spine.maintainPelvisPosition = ControllerShortcutSettingData.config.maintainPelvisPosition;
  970. this.m_ik.solver.spine.bodyPosStiffness = ControllerShortcutSettingData.config.bodyPosStiffness;
  971. this.m_ik.solver.spine.bodyRotStiffness = ControllerShortcutSettingData.config.bodyRotStiffness;
  972. this.m_ik.solver.spine.chestRotationWeight = ControllerShortcutSettingData.config.chestRotationWeight;
  973. this.m_ik.solver.spine.pelvisPositionOffset = this.m_vPelvisPosOffs;
  974. this.m_ik.solver.spine.pelvisRotationOffset = Quaternion.Euler(this.m_vPelvisRotOffs);
  975. if (this.m_ik.fixTransforms && this.m_ik.GetIKSolver().initiated)
  976. {
  977. this.m_ik.GetIKSolver().FixTransforms();
  978. }
  979. this.m_ik.UpdateSolverExternal();
  980. if (this.m_goMoni != null)
  981. {
  982. if (this.m_trMoniPlane != null && this.m_rtMoniPlaneTex != null)
  983. {
  984. this.m_trMoniPlane.localScale = new Vector3((float)this.m_rtMoniPlaneTex.width / (float)this.m_rtMoniPlaneTex.height, 1f, 1f);
  985. }
  986. if (Input.GetKeyDown(KeyCode.Space))
  987. {
  988. this.m_goMoni.SetActive(!this.m_goMoni.activeSelf);
  989. }
  990. }
  991. if (this.m_trEyeTarget != null && this.m_maid != null)
  992. {
  993. Transform realHeadTransform = GameMain.Instance.OvrMgr.OvrCamera.GetRealHeadTransform();
  994. float num = Vector3.Dot(this.m_trEyeTarget.forward, realHeadTransform.forward);
  995. if (this.m_ik.solver.spine.headTarget == this.m_trTargetOffsHeadTracker)
  996. {
  997. num = Vector3.Dot(this.m_trEyeTarget.forward, this.m_trTargetOffsHeadTracker.up);
  998. }
  999. if (num < this.m_fEyeToCamThresholdAngle && this.m_bEyeTocam)
  1000. {
  1001. this.m_maid.EyeToCamera(Maid.EyeMoveType.目だけ向ける, 0f);
  1002. }
  1003. else
  1004. {
  1005. this.m_maid.EyeToCamera(Maid.EyeMoveType.無し, 0f);
  1006. }
  1007. }
  1008. for (int j = 0; j < this.m_listTrackerMeshRnder.Count; j++)
  1009. {
  1010. if (this.m_listTrackerMeshRnder[j] != null)
  1011. {
  1012. this.m_listTrackerMeshRnder[j].enabled = false;
  1013. }
  1014. }
  1015. if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyUp(KeyCode.F8))
  1016. {
  1017. if (this.m_trTargetOffsHeadTracker != null)
  1018. {
  1019. if (this.m_ik.solver.spine.headTarget == this.m_trTargetOffsHeadTracker)
  1020. {
  1021. this.m_ik.solver.spine.headTarget = this.m_trTargetOffsHead;
  1022. }
  1023. else
  1024. {
  1025. this.m_ik.solver.spine.headTarget = this.m_trTargetOffsHeadTracker;
  1026. }
  1027. }
  1028. else
  1029. {
  1030. Debug.Log("VRIK トラッカーがありませんので頭ターゲットに。");
  1031. }
  1032. }
  1033. }
  1034. }
  1035. public static List<string> UpdateGeneralModelFileList()
  1036. {
  1037. OvrIK.m_listFileList.Clear();
  1038. string fullPath = Path.GetFullPath(".\\");
  1039. string path = fullPath + "Model";
  1040. if (!Directory.Exists(path))
  1041. {
  1042. return OvrIK.m_listFileList;
  1043. }
  1044. string[] exts = new string[]
  1045. {
  1046. ".obj",
  1047. ".fbx",
  1048. ".dae",
  1049. ".stl",
  1050. ".x",
  1051. ".3ds"
  1052. };
  1053. string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
  1054. IEnumerable<string> source = from file in files
  1055. where exts.Any((string ext) => file.ToLower().EndsWith(ext))
  1056. select file;
  1057. OvrIK.m_listFileList = source.ToList<string>();
  1058. return OvrIK.m_listFileList;
  1059. }
  1060. public static void LoadGeneralModelFile(string f_strRead)
  1061. {
  1062. OvrIK.m_listGeneralModel.RemoveAll((GameObject o) => o == null);
  1063. GameObject gameObject = ImportCM.LoadGeneralModelFile(f_strRead);
  1064. if (gameObject != null)
  1065. {
  1066. MeshRenderer componentInChildren = gameObject.GetComponentInChildren<MeshRenderer>(true);
  1067. if (componentInChildren != null)
  1068. {
  1069. OvrGrabObj ovrGrabObj = gameObject.AddComponent<OvrGrabObj>();
  1070. Rigidbody rigidbody = gameObject.AddComponent<Rigidbody>();
  1071. rigidbody.useGravity = false;
  1072. rigidbody.isKinematic = true;
  1073. ovrGrabObj.m_trTarget = gameObject.transform;
  1074. string text = Path.GetFileName(f_strRead).ToLower();
  1075. if (text.Contains("_useg"))
  1076. {
  1077. rigidbody.useGravity = true;
  1078. rigidbody.isKinematic = false;
  1079. rigidbody.mass = 0.1f;
  1080. gameObject.layer = LayerMask.NameToLayer("OvrTouchLookObj");
  1081. GameMain.Instance.OvrMgr.OvrCamera.SetCameraMask(CameraMain.CameraMask.OvrTouchLookObj, true);
  1082. ovrGrabObj.m_bGrabToKinematic = true;
  1083. ovrGrabObj.m_fEaseRate = 60f;
  1084. ovrGrabObj.m_fGrabThrowRate = 1f;
  1085. }
  1086. if (text.Contains("_sphere"))
  1087. {
  1088. OvrIK.ColliderAutoAdjust(gameObject.AddComponent<SphereCollider>(), OvrIK.GetChildenMeshCombinedBounds(gameObject));
  1089. }
  1090. else if (text.Contains("_capsule"))
  1091. {
  1092. OvrIK.ColliderAutoAdjust(gameObject.AddComponent<CapsuleCollider>(), OvrIK.GetChildenMeshCombinedBounds(gameObject));
  1093. }
  1094. else if (text.Contains("_box"))
  1095. {
  1096. OvrIK.ColliderAutoAdjust(gameObject.AddComponent<BoxCollider>(), OvrIK.GetChildenMeshCombinedBounds(gameObject));
  1097. }
  1098. else if (text.Contains("_mesh"))
  1099. {
  1100. MeshCollider meshCollider = componentInChildren.gameObject.AddComponent<MeshCollider>();
  1101. meshCollider.inflateMesh = true;
  1102. meshCollider.skinWidth = 0.03f;
  1103. meshCollider.convex = true;
  1104. }
  1105. else if (text.Contains("_useg"))
  1106. {
  1107. OvrIK.ColliderAutoAdjust(gameObject.AddComponent<BoxCollider>(), OvrIK.GetChildenMeshCombinedBounds(gameObject));
  1108. }
  1109. else
  1110. {
  1111. MeshCollider meshCollider2 = componentInChildren.gameObject.AddComponent<MeshCollider>();
  1112. meshCollider2.inflateMesh = true;
  1113. meshCollider2.skinWidth = 0.03f;
  1114. meshCollider2.convex = true;
  1115. }
  1116. if (text.Contains("_trans"))
  1117. {
  1118. componentInChildren.sharedMaterial.shader = Shader.Find("CM3D2/Lighted_Trans");
  1119. }
  1120. else
  1121. {
  1122. componentInChildren.sharedMaterial.shader = Shader.Find("CM3D2/Lighted");
  1123. }
  1124. OvrObjAutoDestory ovrObjAutoDestory = gameObject.AddComponent<OvrObjAutoDestory>();
  1125. ovrObjAutoDestory.m_goTarget = gameObject;
  1126. OvrIK.m_listGeneralModel.Add(gameObject);
  1127. }
  1128. Transform realHeadTransform = GameMain.Instance.OvrMgr.OvrCamera.GetRealHeadTransform();
  1129. Vector3 position = new Vector3(realHeadTransform.forward.x, 0f, realHeadTransform.forward.z) * 2f + realHeadTransform.position;
  1130. gameObject.transform.position = position;
  1131. }
  1132. }
  1133. private static Bounds GetChildenMeshCombinedBounds(GameObject obj)
  1134. {
  1135. NDebug.AssertNull(obj);
  1136. Bounds result = default(Bounds);
  1137. MeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<MeshRenderer>();
  1138. if (componentsInChildren == null || componentsInChildren.Length <= 0)
  1139. {
  1140. return result;
  1141. }
  1142. result = componentsInChildren[0].bounds;
  1143. for (int i = 1; i < componentsInChildren.Length; i++)
  1144. {
  1145. result.Encapsulate(componentsInChildren[i].bounds);
  1146. }
  1147. return result;
  1148. }
  1149. private static void ColliderAutoAdjust(SphereCollider col, Bounds bounds)
  1150. {
  1151. col.center = bounds.center;
  1152. col.radius = bounds.extents.x;
  1153. if (col.radius < bounds.extents.y)
  1154. {
  1155. col.radius = bounds.extents.y;
  1156. }
  1157. if (col.radius < bounds.extents.z)
  1158. {
  1159. col.radius = bounds.extents.z;
  1160. }
  1161. }
  1162. private static void ColliderAutoAdjust(BoxCollider col, Bounds bounds)
  1163. {
  1164. col.center = bounds.center;
  1165. col.size = bounds.size;
  1166. }
  1167. private static void ColliderAutoAdjust(CapsuleCollider col, Bounds bounds)
  1168. {
  1169. col.center = bounds.center;
  1170. int index = 0;
  1171. int num = 2;
  1172. if (bounds.extents[index] > bounds.extents[1])
  1173. {
  1174. index = 1;
  1175. }
  1176. if (bounds.extents[index] > bounds.extents[2])
  1177. {
  1178. index = 2;
  1179. }
  1180. if (bounds.extents[num] < bounds.extents[1])
  1181. {
  1182. num = 1;
  1183. }
  1184. if (bounds.extents[num] < bounds.extents[2])
  1185. {
  1186. num = 2;
  1187. }
  1188. col.radius = bounds.extents[index];
  1189. col.height = bounds.size[num];
  1190. col.direction = num;
  1191. }
  1192. public static void DestroyGeneralModelAll()
  1193. {
  1194. foreach (GameObject gameObject in OvrIK.m_listGeneralModel)
  1195. {
  1196. if (gameObject != null)
  1197. {
  1198. UnityEngine.Object.Destroy(gameObject);
  1199. }
  1200. }
  1201. OvrIK.m_listGeneralModel.Clear();
  1202. }
  1203. private static OvrIK m_this;
  1204. private VRIK m_ik;
  1205. private static OvrIK.OvrIkConfig m_conf = new OvrIK.OvrIkConfig();
  1206. private readonly string[] m_strHandBoneNameL = new string[]
  1207. {
  1208. "Bip01 L Finger02",
  1209. "Bip01 L Finger01",
  1210. "Bip01 L Finger0",
  1211. "Bip01 L Finger12",
  1212. "Bip01 L Finger11",
  1213. "Bip01 L Finger1",
  1214. "Bip01 L Finger22",
  1215. "Bip01 L Finger21",
  1216. "Bip01 L Finger2",
  1217. "Bip01 L Finger32",
  1218. "Bip01 L Finger31",
  1219. "Bip01 L Finger3",
  1220. "Bip01 L Finger42",
  1221. "Bip01 L Finger41",
  1222. "Bip01 L Finger4"
  1223. };
  1224. private readonly string[] m_strHandBoneNameR = new string[]
  1225. {
  1226. "Bip01 R Finger02",
  1227. "Bip01 R Finger01",
  1228. "Bip01 R Finger0",
  1229. "Bip01 R Finger12",
  1230. "Bip01 R Finger11",
  1231. "Bip01 R Finger1",
  1232. "Bip01 R Finger22",
  1233. "Bip01 R Finger21",
  1234. "Bip01 R Finger2",
  1235. "Bip01 R Finger32",
  1236. "Bip01 R Finger31",
  1237. "Bip01 R Finger3",
  1238. "Bip01 R Finger42",
  1239. "Bip01 R Finger41",
  1240. "Bip01 R Finger4"
  1241. };
  1242. private readonly Quaternion[,] m_aryHandRot;
  1243. private Maid m_maid;
  1244. private Transform m_trTargetOffsHead;
  1245. private Transform m_trTargetOffsPelvis;
  1246. private Transform m_trTargetOffsHandL;
  1247. private Transform m_trTargetOffsHandR;
  1248. private Transform m_trTargetOffsFootL;
  1249. private Transform m_trTargetOffsFootR;
  1250. private Transform m_trTargetOffsHeadTracker;
  1251. private Transform m_trTargetOffsFootLVecY;
  1252. private Transform m_trTargetOffsFootRVecY;
  1253. private GameObject m_goDefaultPoseParent;
  1254. private List<KeyValuePair<Transform, Transform>> m_listDefaultPose;
  1255. private Transform m_trMaidDefaultPoseEyeR;
  1256. private Transform m_trMaidDefaultPoseFootR;
  1257. private Transform m_trPlayerDefaultPoseEye;
  1258. private Transform m_trPlayerDefaultPoseFoot;
  1259. private Transform[] m_trHandL;
  1260. private Transform[] m_trHandR;
  1261. public Vector3 m_vPelvisPosOffs;
  1262. public Vector3 m_vPelvisRotOffs;
  1263. private GameObject m_goIKTargetParent;
  1264. private int m_nCensorNum;
  1265. public bool m_bLegTracking;
  1266. private static Coroutine m_coCalibrate = null;
  1267. private GameObject m_self_shot_cam;
  1268. private OvrSelfShotCamera m_coSelfShotCam;
  1269. private GameObject m_goMoni;
  1270. private Transform m_trMoniPlane;
  1271. private RenderTexture m_rtMoniPlaneTex;
  1272. private Transform m_trEyeTarget;
  1273. private PhotoFaceDataShortcutParent m_FaceCompoL;
  1274. private PhotoFaceDataShortcutParent m_FaceCompoR;
  1275. private HandSignShortcut m_coHandSignL;
  1276. private HandSignShortcut m_coHandSignR;
  1277. private OtherCommandShortcut m_coOtherCmdL;
  1278. private OtherCommandShortcut m_coOtherCmdR;
  1279. private static GameObject m_goVRIKConfigUI;
  1280. private static ControllerShortcutWindow m_VRIKConfigCompo;
  1281. private Vector3 m_vBackPos;
  1282. private Vector3 m_vBackRot;
  1283. private Vector3 m_vBackRootPos;
  1284. private Quaternion m_qBackRootRot;
  1285. private List<MeshRenderer> m_listTrackerMeshRnder;
  1286. public float m_fEyeToCamThresholdAngle;
  1287. private bool m_bEyeTocam;
  1288. private bool m_bBackAutoTwistShoulderL;
  1289. private bool m_bBackAutoTwistShoulderR;
  1290. private bool m_bBackAutoTwistWristL;
  1291. private bool m_bBackAutoTwistWristR;
  1292. private bool m_bBackAutoTwistThighL;
  1293. private bool m_bBackAutoTwistThighR;
  1294. private AMTween[] m_aryBackAMTween;
  1295. private Vector3 m_vFootDefOffsLocalL;
  1296. private Vector3 m_vFootDefOffsLocalR;
  1297. public float offsy;
  1298. private int m_nShincho;
  1299. private int m_nDouPer;
  1300. private int m_nKubiScl;
  1301. private static List<string> m_listFileList = new List<string>();
  1302. private static List<GameObject> m_listGeneralModel = new List<GameObject>();
  1303. [Serializable]
  1304. public class OvrIkConfig : ISerializationCallbackReceiver
  1305. {
  1306. public void OnBeforeSerialize()
  1307. {
  1308. this.m_nVersion = 1140;
  1309. }
  1310. public void OnAfterDeserialize()
  1311. {
  1312. }
  1313. public bool Write()
  1314. {
  1315. string contents = JsonUtility.ToJson(this, true);
  1316. string path = Path.GetFullPath(".\\") + "OvrIK.json";
  1317. try
  1318. {
  1319. File.WriteAllText(path, contents);
  1320. }
  1321. catch
  1322. {
  1323. Debug.LogError("OvrIK.json の書き込みに失敗。");
  1324. return false;
  1325. }
  1326. return true;
  1327. }
  1328. public OvrIK.OvrIkConfig Read()
  1329. {
  1330. string path = Path.GetFullPath(".\\") + "OvrIK.json";
  1331. if (!File.Exists(path))
  1332. {
  1333. this.Write();
  1334. }
  1335. string json;
  1336. try
  1337. {
  1338. json = File.ReadAllText(path);
  1339. }
  1340. catch
  1341. {
  1342. Debug.LogError("OvrIK.json の読込に失敗。");
  1343. return this;
  1344. }
  1345. return JsonUtility.FromJson<OvrIK.OvrIkConfig>(json);
  1346. }
  1347. public void Update(VRIK f_vrik)
  1348. {
  1349. f_vrik.solver.locomotion.weight = this.solver_locomotion_weight;
  1350. f_vrik.solver.locomotion.footDistance = this.solver_locomotion_footDistance;
  1351. f_vrik.solver.locomotion.stepThreshold = this.solver_locomotion_stepThreshold;
  1352. f_vrik.solver.locomotion.angleThreshold = this.solver_locomotion_angleThreshold;
  1353. f_vrik.solver.locomotion.comAngleMlp = this.solver_locomotion_comAngleMlp;
  1354. f_vrik.solver.locomotion.maxVelocity = this.solver_locomotion_maxVelocity;
  1355. f_vrik.solver.locomotion.velocityFactor = this.solver_locomotion_velocityFactor;
  1356. f_vrik.solver.locomotion.maxLegStretch = this.solver_locomotion_maxLegStretch;
  1357. f_vrik.solver.locomotion.rootSpeed = this.solver_locomotion_rootSpeed;
  1358. f_vrik.solver.locomotion.stepSpeed = this.solver_locomotion_stepSpeed;
  1359. }
  1360. private const string CONF_NAME = "OvrIK.json";
  1361. [SerializeField]
  1362. private int m_nVersion = 1140;
  1363. [SerializeField]
  1364. private float solver_locomotion_weight = 1f;
  1365. [SerializeField]
  1366. private float solver_locomotion_footDistance = 0.1f;
  1367. [SerializeField]
  1368. private float solver_locomotion_stepThreshold = 0.28f;
  1369. [SerializeField]
  1370. private float solver_locomotion_angleThreshold = 60f;
  1371. [SerializeField]
  1372. private float solver_locomotion_comAngleMlp = 1f;
  1373. [SerializeField]
  1374. private float solver_locomotion_maxVelocity = 0.4f;
  1375. [SerializeField]
  1376. private float solver_locomotion_velocityFactor = 0.4f;
  1377. [SerializeField]
  1378. private float solver_locomotion_maxLegStretch = 1f;
  1379. [SerializeField]
  1380. private float solver_locomotion_rootSpeed = 20f;
  1381. [SerializeField]
  1382. private float solver_locomotion_stepSpeed = 3f;
  1383. [SerializeField]
  1384. private bool m_bHeadIsTracker;
  1385. [SerializeField]
  1386. public float m_fEyeToCamThresholdAngle = -0.9f;
  1387. [SerializeField]
  1388. public float leg_no_tracker_pos_weight = 0.3f;
  1389. [SerializeField]
  1390. public float leg_no_tracker_rot_weight = 0.3f;
  1391. }
  1392. }