CacheBoneDataArray.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class CacheBoneDataArray : MonoBehaviour
  6. {
  7. public void CreateCache(Transform root)
  8. {
  9. if (CacheBoneDataArray.save_bone_path_set_ == null)
  10. {
  11. CacheBoneDataArray.save_bone_path_set_ = new HashSet<string>();
  12. string[] saveBonePathArray = CacheBoneDataArray.GetSaveBonePathArray();
  13. for (int i = 0; i < saveBonePathArray.Length; i++)
  14. {
  15. CacheBoneDataArray.save_bone_path_set_.Add(saveBonePathArray[i]);
  16. }
  17. }
  18. this.path_dic_ = new Dictionary<string, CacheBoneDataArray.BoneData>();
  19. this.bone_data = new CacheBoneDataArray.BoneData(root, null);
  20. this.bip_root_trans_ = this.bone_data.transform;
  21. this.bust_trans_ = new Transform[2];
  22. Action<CacheBoneDataArray.BoneData> bust_search = null;
  23. bust_search = delegate(CacheBoneDataArray.BoneData target_bone_data)
  24. {
  25. if (this.bust_trans_[0] != null && this.bust_trans_[1] != null)
  26. {
  27. return;
  28. }
  29. string name = target_bone_data.transform.gameObject.name;
  30. if (name == "Mune_L")
  31. {
  32. this.bust_trans_[0] = target_bone_data.transform;
  33. }
  34. else if (name == "Mune_R")
  35. {
  36. this.bust_trans_[1] = target_bone_data.transform;
  37. }
  38. for (int j = 0; j < target_bone_data.child_bone_array.Length; j++)
  39. {
  40. bust_search(target_bone_data.child_bone_array[j]);
  41. }
  42. };
  43. bust_search(this.bone_data);
  44. NDebug.Assert(this.bust_trans_[0] != null && this.bust_trans_[1] != null, "胸ボーンのサーチに失敗しました");
  45. Action<CacheBoneDataArray.BoneData> create_path_dic = null;
  46. create_path_dic = delegate(CacheBoneDataArray.BoneData target_bone_data)
  47. {
  48. if (!this.path_dic_.ContainsKey(target_bone_data.path))
  49. {
  50. this.path_dic_.Add(target_bone_data.path, target_bone_data);
  51. }
  52. for (int j = 0; j < target_bone_data.child_bone_array.Length; j++)
  53. {
  54. create_path_dic(target_bone_data.child_bone_array[j]);
  55. }
  56. };
  57. create_path_dic(this.bone_data);
  58. }
  59. public byte[] GetAnmBinary(bool use_bust_keyL, bool use_bust_keyR)
  60. {
  61. if (this.bone_data == null)
  62. {
  63. NDebug.Assert("ボーンデータがありません", false);
  64. return null;
  65. }
  66. Action<BinaryWriter, CacheBoneDataArray.BoneData> write_bone_data = null;
  67. write_bone_data = delegate(BinaryWriter w, CacheBoneDataArray.BoneData target_bone_data)
  68. {
  69. if (CacheBoneDataArray.save_bone_path_set_.Contains(target_bone_data.path))
  70. {
  71. int num = 2;
  72. w.Write(1);
  73. w.Write(target_bone_data.path);
  74. Vector3 localPosition = target_bone_data.transform.localPosition;
  75. Quaternion localRotation = target_bone_data.transform.localRotation;
  76. float[] array = new float[]
  77. {
  78. localRotation.x,
  79. localRotation.y,
  80. localRotation.z,
  81. localRotation.w
  82. };
  83. if (target_bone_data.transform == this.bip_root_trans_)
  84. {
  85. array = new float[]
  86. {
  87. localRotation.x,
  88. localRotation.y,
  89. localRotation.z,
  90. localRotation.w,
  91. localPosition.x,
  92. localPosition.y,
  93. localPosition.z
  94. };
  95. }
  96. for (int i = 0; i < array.Length; i++)
  97. {
  98. w.Write((byte)(100 + i));
  99. w.Write(num);
  100. for (int j = 0; j < num; j++)
  101. {
  102. w.Write((float)j);
  103. w.Write(array[i]);
  104. w.Write(0);
  105. w.Write(0);
  106. }
  107. }
  108. }
  109. for (int k = 0; k < target_bone_data.child_bone_array.Length; k++)
  110. {
  111. write_bone_data(w, target_bone_data.child_bone_array[k]);
  112. }
  113. };
  114. MemoryStream memoryStream = new MemoryStream();
  115. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  116. binaryWriter.Write("CM3D2_ANIM");
  117. binaryWriter.Write(1001);
  118. write_bone_data(binaryWriter, this.bone_data);
  119. binaryWriter.Write(0);
  120. binaryWriter.Write((!use_bust_keyL) ? 0 : 1);
  121. binaryWriter.Write((!use_bust_keyR) ? 0 : 1);
  122. binaryWriter.Close();
  123. memoryStream.Close();
  124. byte[] result = memoryStream.ToArray();
  125. memoryStream.Dispose();
  126. return result;
  127. }
  128. public List<KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>> GetTest()
  129. {
  130. List<KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>> result = new List<KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>>();
  131. Action<List<KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>>, CacheBoneDataArray.BoneData> write_bone_data = null;
  132. write_bone_data = delegate(List<KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>> dest, CacheBoneDataArray.BoneData target_bone_data)
  133. {
  134. if (CacheBoneDataArray.save_bone_path_set_.Contains(target_bone_data.path))
  135. {
  136. string path = target_bone_data.path;
  137. KeyValuePair<Quaternion, Vector3> value = new KeyValuePair<Quaternion, Vector3>(target_bone_data.transform.localRotation, target_bone_data.transform.localPosition);
  138. KeyValuePair<string, KeyValuePair<Quaternion, Vector3>> item = new KeyValuePair<string, KeyValuePair<Quaternion, Vector3>>(path, value);
  139. dest.Add(item);
  140. }
  141. for (int i = 0; i < target_bone_data.child_bone_array.Length; i++)
  142. {
  143. write_bone_data(result, target_bone_data.child_bone_array[i]);
  144. }
  145. };
  146. write_bone_data(result, this.bone_data);
  147. return result;
  148. }
  149. public byte[] GetFrameBinary(bool use_bust_keyL, bool use_bust_keyR)
  150. {
  151. if (this.bone_data == null)
  152. {
  153. NDebug.Assert("ボーンデータがありません", false);
  154. return null;
  155. }
  156. Action<BinaryWriter, CacheBoneDataArray.BoneData> write_bone_data = null;
  157. write_bone_data = delegate(BinaryWriter w, CacheBoneDataArray.BoneData target_bone_data)
  158. {
  159. if (CacheBoneDataArray.save_bone_path_set_.Contains(target_bone_data.path))
  160. {
  161. w.Write(1);
  162. w.Write(target_bone_data.path);
  163. Vector3 localPosition = target_bone_data.transform.localPosition;
  164. Quaternion localRotation = target_bone_data.transform.localRotation;
  165. float[] array = new float[]
  166. {
  167. localRotation.x,
  168. localRotation.y,
  169. localRotation.z,
  170. localRotation.w
  171. };
  172. if (target_bone_data.transform == this.bip_root_trans_)
  173. {
  174. array = new float[]
  175. {
  176. localRotation.x,
  177. localRotation.y,
  178. localRotation.z,
  179. localRotation.w,
  180. localPosition.x,
  181. localPosition.y,
  182. localPosition.z
  183. };
  184. }
  185. for (int i = 0; i < array.Length; i++)
  186. {
  187. w.Write(array[i]);
  188. }
  189. }
  190. for (int j = 0; j < target_bone_data.child_bone_array.Length; j++)
  191. {
  192. write_bone_data(w, target_bone_data.child_bone_array[j]);
  193. }
  194. };
  195. MemoryStream memoryStream = new MemoryStream();
  196. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  197. binaryWriter.Write("CM3D2_FRAME_ANIM");
  198. binaryWriter.Write(1001);
  199. write_bone_data(binaryWriter, this.bone_data);
  200. binaryWriter.Write(0);
  201. binaryWriter.Write((!use_bust_keyL) ? 0 : 1);
  202. binaryWriter.Write((!use_bust_keyR) ? 0 : 1);
  203. binaryWriter.Close();
  204. memoryStream.Close();
  205. byte[] result = memoryStream.ToArray();
  206. memoryStream.Dispose();
  207. return result;
  208. }
  209. public KeyValuePair<bool, bool> SetFrameBinary(byte[] binary)
  210. {
  211. if (this.bone_data == null)
  212. {
  213. NDebug.Assert("ボーンデータがありません", false);
  214. return new KeyValuePair<bool, bool>(false, false);
  215. }
  216. MemoryStream memoryStream = new MemoryStream(binary);
  217. BinaryReader binaryReader = new BinaryReader(memoryStream);
  218. string a = binaryReader.ReadString();
  219. if (a != "CM3D2_FRAME_ANIM")
  220. {
  221. binaryReader.Close();
  222. memoryStream.Close();
  223. memoryStream.Dispose();
  224. return new KeyValuePair<bool, bool>(false, false);
  225. }
  226. int num = binaryReader.ReadInt32();
  227. bool flag = false;
  228. if (1001 <= num)
  229. {
  230. flag = true;
  231. }
  232. Dictionary<int, KeyValuePair<Transform, float[]>> dictionary = new Dictionary<int, KeyValuePair<Transform, float[]>>();
  233. while (binaryReader.ReadByte() != 0)
  234. {
  235. string key = binaryReader.ReadString();
  236. CacheBoneDataArray.BoneData boneData = this.path_dic_[key];
  237. float[] array = new float[4];
  238. if (boneData.transform == this.bip_root_trans_)
  239. {
  240. array = new float[7];
  241. }
  242. for (int i = 0; i < array.Length; i++)
  243. {
  244. array[i] = binaryReader.ReadSingle();
  245. }
  246. if (flag && (boneData.transform == this.bust_trans_[0] || boneData.transform == this.bust_trans_[1]))
  247. {
  248. int key2 = 0;
  249. if (boneData.transform == this.bust_trans_[1])
  250. {
  251. key2 = 1;
  252. }
  253. KeyValuePair<Transform, float[]> value = new KeyValuePair<Transform, float[]>(boneData.transform, array);
  254. dictionary.Add(key2, value);
  255. }
  256. else
  257. {
  258. boneData.transform.localRotation = new Quaternion(array[0], array[1], array[2], array[3]);
  259. if (4 < array.Length)
  260. {
  261. boneData.transform.localPosition = new Vector3(array[4], array[5], array[6]);
  262. }
  263. }
  264. }
  265. bool flag2 = false;
  266. bool flag3 = false;
  267. if (flag)
  268. {
  269. flag2 = (binaryReader.ReadByte() != 0);
  270. flag3 = (binaryReader.ReadByte() != 0);
  271. List<KeyValuePair<Transform, float[]>> list = new List<KeyValuePair<Transform, float[]>>();
  272. if (flag2)
  273. {
  274. list.Add(dictionary[0]);
  275. }
  276. if (flag3)
  277. {
  278. list.Add(dictionary[1]);
  279. }
  280. foreach (KeyValuePair<Transform, float[]> keyValuePair in list)
  281. {
  282. float[] value2 = keyValuePair.Value;
  283. keyValuePair.Key.localRotation = new Quaternion(value2[0], value2[1], value2[2], value2[3]);
  284. if (4 < value2.Length)
  285. {
  286. keyValuePair.Key.transform.localPosition = new Vector3(value2[4], value2[5], value2[6]);
  287. }
  288. }
  289. }
  290. binaryReader.Close();
  291. memoryStream.Close();
  292. memoryStream.Dispose();
  293. return new KeyValuePair<bool, bool>(flag2, flag3);
  294. }
  295. public CacheBoneDataArray.BoneData bone_data { get; private set; }
  296. private static string[] GetSaveBonePathArray()
  297. {
  298. return new string[]
  299. {
  300. "Bip01",
  301. "Bip01/Bip01 Footsteps",
  302. "Bip01/Bip01 Pelvis",
  303. "Bip01/Bip01 Pelvis/Bip01 L Thigh",
  304. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf",
  305. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot",
  306. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe0",
  307. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe0/Bip01 L Toe01",
  308. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe1",
  309. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe1/Bip01 L Toe11",
  310. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe2",
  311. "Bip01/Bip01 Pelvis/Bip01 L Thigh/Bip01 L Calf/Bip01 L Foot/Bip01 L Toe2/Bip01 L Toe21",
  312. "Bip01/Bip01 Pelvis/Bip01 R Thigh",
  313. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf",
  314. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot",
  315. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe0",
  316. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe0/Bip01 R Toe01",
  317. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe1",
  318. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe1/Bip01 R Toe11",
  319. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe2",
  320. "Bip01/Bip01 Pelvis/Bip01 R Thigh/Bip01 R Calf/Bip01 R Foot/Bip01 R Toe2/Bip01 R Toe21",
  321. "Bip01/Bip01 Spine",
  322. "Bip01/Bip01 Spine/Bip01 Spine0a",
  323. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1",
  324. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a",
  325. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 Neck",
  326. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 Neck/Bip01 Head",
  327. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle",
  328. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm",
  329. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm",
  330. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand",
  331. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger0",
  332. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger0/Bip01 L Finger01",
  333. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger0/Bip01 L Finger01/Bip01 L Finger02",
  334. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger1",
  335. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger1/Bip01 L Finger11",
  336. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger1/Bip01 L Finger11/Bip01 L Finger12",
  337. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger2",
  338. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger2/Bip01 L Finger21",
  339. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger2/Bip01 L Finger21/Bip01 L Finger22",
  340. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger3",
  341. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger3/Bip01 L Finger31",
  342. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger3/Bip01 L Finger31/Bip01 L Finger32",
  343. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger4",
  344. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger4/Bip01 L Finger41",
  345. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand/Bip01 L Finger4/Bip01 L Finger41/Bip01 L Finger42",
  346. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle",
  347. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm",
  348. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm",
  349. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand",
  350. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger0",
  351. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger0/Bip01 R Finger01",
  352. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger0/Bip01 R Finger01/Bip01 R Finger02",
  353. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger1",
  354. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger1/Bip01 R Finger11",
  355. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger1/Bip01 R Finger11/Bip01 R Finger12",
  356. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger2",
  357. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger2/Bip01 R Finger21",
  358. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger2/Bip01 R Finger21/Bip01 R Finger22",
  359. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger3",
  360. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger3/Bip01 R Finger31",
  361. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger3/Bip01 R Finger31/Bip01 R Finger32",
  362. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger4",
  363. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger4/Bip01 R Finger41",
  364. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand/Bip01 R Finger4/Bip01 R Finger41/Bip01 R Finger42",
  365. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Mune_L",
  366. "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1/Bip01 Spine1a/Mune_R"
  367. };
  368. }
  369. private Transform bip_root_trans_;
  370. private Transform[] bust_trans_;
  371. private Dictionary<string, CacheBoneDataArray.BoneData> path_dic_;
  372. private static HashSet<string> save_bone_path_set_;
  373. public class BoneData
  374. {
  375. public BoneData(Transform trans, string hierarchy_path)
  376. {
  377. this.transform = trans;
  378. this.path = hierarchy_path;
  379. if (!string.IsNullOrEmpty(this.path))
  380. {
  381. this.path += "/";
  382. }
  383. this.path += trans.gameObject.name;
  384. List<CacheBoneDataArray.BoneData> list = new List<CacheBoneDataArray.BoneData>();
  385. for (int i = 0; i < this.transform.childCount; i++)
  386. {
  387. Transform child = this.transform.GetChild(i);
  388. string name = child.name;
  389. if (0 > name.IndexOf("_IK") && 0 > name.IndexOf("_SCL") && 0 > name.IndexOf("nub"))
  390. {
  391. list.Add(new CacheBoneDataArray.BoneData(child, this.path));
  392. }
  393. }
  394. this.child_bone_array = list.ToArray();
  395. }
  396. public Transform transform { get; private set; }
  397. public CacheBoneDataArray.BoneData[] child_bone_array { get; private set; }
  398. public string path { get; private set; }
  399. }
  400. }