BoneMorph.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BoneMorph
  5. {
  6. public static void Init()
  7. {
  8. BoneMorph.dic = new Dictionary<string, Vector3>();
  9. BoneMorph.SetPosition("KubiScl", "Bip01 Neck", 0.95f, 1f, 1f, 1.05f, 1f, 1f);
  10. BoneMorph.SetPosition("KubiScl", "Bip01 Head", 0.8f, 1f, 1f, 1.2f, 1f, 1f);
  11. BoneMorph.SetScale("UdeScl", "Bip01 ? UpperArm", 0.85f, 1f, 1f, 1.15f, 1f, 1f);
  12. BoneMorph.SetScale("EyeSclX", "Eyepos_L", 1f, 1f, 0.92f, 1f, 1f, 1.08f);
  13. BoneMorph.SetScale("EyeSclX", "Eyepos_R", 1f, 1f, 0.92f, 1f, 1f, 1.08f);
  14. BoneMorph.SetScale("EyeSclY", "Eyepos_L", 1f, 0.92f, 1f, 1f, 1.08f, 1f);
  15. BoneMorph.SetScale("EyeSclY", "Eyepos_R", 1f, 0.92f, 1f, 1f, 1.08f, 1f);
  16. BoneMorph.SetPosition("EyePosX", "Eyepos_R", 1f, 1f, 0.9f, 1f, 1f, 1.1f);
  17. BoneMorph.SetPosition("EyePosX", "Eyepos_L", 1f, 1f, 0.9f, 1f, 1f, 1.1f);
  18. BoneMorph.SetPosition("EyePosY", "Eyepos_R", 1f, 0.93f, 1f, 1f, 1.07f, 1f);
  19. BoneMorph.SetPosition("EyePosY", "Eyepos_L", 1f, 0.93f, 1f, 1f, 1.07f, 1f);
  20. BoneMorph.SetScale("HeadX", "Bip01 Head", 1f, 0.9f, 0.8f, 1f, 1.1f, 1.2f);
  21. BoneMorph.SetScale("HeadY", "Bip01 Head", 0.8f, 0.9f, 1f, 1.2f, 1.1f, 1f);
  22. BoneMorph.SetPosition("DouPer", "Bip01 Spine", 1f, 1f, 0.94f, 1f, 1f, 1.06f);
  23. BoneMorph.SetPosition("DouPer", "Bip01 Spine0a", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  24. BoneMorph.SetPosition("DouPer", "Bip01 Spine1", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  25. BoneMorph.SetPosition("DouPer", "Bip01 Spine1a", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  26. BoneMorph.SetPosition("DouPer", "Bip01 Neck", 1.03f, 1f, 1f, 0.97f, 1f, 1f);
  27. BoneMorph.SetPosition("DouPer", "Bip01 ? Calf", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  28. BoneMorph.SetPosition("DouPer", "Bip01 ? Foot", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  29. BoneMorph.SetScale("DouPer", "Bip01 ? Thigh_SCL_", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  30. BoneMorph.SetScale("DouPer", "momotwist_?", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  31. BoneMorph.SetScale("DouPer", "Bip01 ? Calf_SCL_", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  32. BoneMorph.SetScale("DouPer", "Bip01 ? UpperArm", 0.98f, 1f, 1f, 1.02f, 1f, 1f);
  33. BoneMorph.SetPosition("sintyou", "Bip01 Spine", 1f, 1f, 0.85f, 1f, 1f, 1.15f);
  34. BoneMorph.SetPosition("sintyou", "Bip01 Spine0a", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  35. BoneMorph.SetPosition("sintyou", "Bip01 Spine1", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  36. BoneMorph.SetPosition("sintyou", "Bip01 Spine1a", 0.88f, 1f, 1f, 1.12f, 1f, 1f);
  37. BoneMorph.SetPosition("sintyou", "Bip01 Neck", 0.97f, 1f, 1f, 1.03f, 1f, 1f);
  38. BoneMorph.SetPosition("sintyou", "Bip01 Head", 0.9f, 1f, 1f, 1.1f, 1f, 1f);
  39. BoneMorph.SetPosition("sintyou", "Bip01 ? Calf", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  40. BoneMorph.SetPosition("sintyou", "Bip01 ? Foot", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  41. BoneMorph.SetScale("sintyou", "Bip01 ? UpperArm", 0.9f, 1f, 1f, 1.1f, 1f, 1f);
  42. BoneMorph.SetScale("sintyou", "Bip01 ? Thigh_SCL_", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  43. BoneMorph.SetScale("sintyou", "momotwist_?", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  44. BoneMorph.SetScale("sintyou", "Bip01 ? Calf_SCL_", 0.87f, 1f, 1f, 1.13f, 1f, 1f);
  45. BoneMorph.SetScale("koshi", "Bip01 Pelvis_SCL_", 1f, 0.8f, 0.92f, 1f, 1.2f, 1.08f);
  46. BoneMorph.SetScale("koshi", "Bip01 Spine_SCL_", 1f, 1f, 1f, 1f, 1f, 1f);
  47. BoneMorph.SetScale("koshi", "Hip_?", 1f, 0.96f, 0.9f, 1f, 1.04f, 1.1f);
  48. BoneMorph.SetScale("koshi", "Skirt", 1f, 0.85f, 0.88f, 1f, 1.2f, 1.12f);
  49. BoneMorph.SetPosition("kata", "Bip01 ? Clavicle", 0.98f, 1f, 0.5f, 1.02f, 1f, 1.5f);
  50. BoneMorph.SetScale("kata", "Bip01 Spine1a_SCL_", 1f, 1f, 0.95f, 1f, 1f, 1.05f);
  51. BoneMorph.SetScale("west", "Bip01 Spine_SCL_", 1f, 0.95f, 0.9f, 1f, 1.05f, 1.1f);
  52. BoneMorph.SetScale("west", "Bip01 Spine0a_SCL_", 1f, 0.85f, 0.7f, 1f, 1.15f, 1.3f);
  53. BoneMorph.SetScale("west", "Bip01 Spine1_SCL_", 1f, 0.9f, 0.85f, 1f, 1.1f, 1.15f);
  54. BoneMorph.SetScale("west", "Bip01 Spine1a_SCL_", 1f, 0.95f, 0.95f, 1f, 1.05f, 1.05f);
  55. BoneMorph.SetScale("west", "Skirt", 1f, 0.92f, 0.88f, 1f, 1.08f, 1.12f);
  56. }
  57. private static void SetScale(string tag, string bname, float x, float y, float z, float x2, float y2, float z2)
  58. {
  59. string text = bname;
  60. List<BoneMorph.BoneProp> list;
  61. BoneMorph.BoneProp boneProp;
  62. if (bname.Contains("?"))
  63. {
  64. text = text.Replace('?', 'L');
  65. bname = bname.Replace('?', 'R');
  66. if (!BoneMorph.dic2.TryGetValue(bname, out list))
  67. {
  68. List<BoneMorph.BoneProp> list2 = new List<BoneMorph.BoneProp>();
  69. BoneMorph.dic2[bname] = list2;
  70. list = list2;
  71. }
  72. boneProp = list.Find((BoneMorph.BoneProp a) => a.strProp == tag);
  73. if (boneProp == null)
  74. {
  75. boneProp = new BoneMorph.BoneProp();
  76. list.Add(boneProp);
  77. }
  78. boneProp.strProp = tag;
  79. boneProp.nIndex = Array.FindIndex<string>(BoneMorph.PropNames, (string a) => a == tag);
  80. boneProp.bExistM = true;
  81. BoneMorph.dic["min+" + tag + "*" + bname] = (boneProp.vMinM = new Vector3(x, y, z));
  82. BoneMorph.dic["max+" + tag + "*" + bname] = (boneProp.vMaxM = new Vector3(x2, y2, z2));
  83. }
  84. if (!BoneMorph.dic2.TryGetValue(text, out list))
  85. {
  86. List<BoneMorph.BoneProp> list2 = new List<BoneMorph.BoneProp>();
  87. BoneMorph.dic2[text] = list2;
  88. list = list2;
  89. }
  90. boneProp = list.Find((BoneMorph.BoneProp a) => a.strProp == tag);
  91. if (boneProp == null)
  92. {
  93. boneProp = new BoneMorph.BoneProp();
  94. list.Add(boneProp);
  95. }
  96. boneProp.strProp = tag;
  97. boneProp.nIndex = Array.FindIndex<string>(BoneMorph.PropNames, (string a) => a == tag);
  98. boneProp.bExistM = true;
  99. BoneMorph.dic["min+" + tag + "*" + text] = (boneProp.vMinM = new Vector3(x, y, z));
  100. BoneMorph.dic["max+" + tag + "*" + text] = (boneProp.vMaxM = new Vector3(x2, y2, z2));
  101. }
  102. private static void SetPosition(string tag, string bname, float x, float y, float z, float x2, float y2, float z2)
  103. {
  104. string text = bname;
  105. List<BoneMorph.BoneProp> list;
  106. BoneMorph.BoneProp boneProp;
  107. if (bname.Contains("?"))
  108. {
  109. text = text.Replace('?', 'L');
  110. bname = bname.Replace('?', 'R');
  111. if (!BoneMorph.dic2.TryGetValue(bname, out list))
  112. {
  113. List<BoneMorph.BoneProp> list2 = new List<BoneMorph.BoneProp>();
  114. BoneMorph.dic2[bname] = list2;
  115. list = list2;
  116. }
  117. boneProp = list.Find((BoneMorph.BoneProp a) => a.strProp == tag);
  118. if (boneProp == null)
  119. {
  120. boneProp = new BoneMorph.BoneProp();
  121. list.Add(boneProp);
  122. }
  123. boneProp.strProp = tag;
  124. boneProp.nIndex = Array.FindIndex<string>(BoneMorph.PropNames, (string a) => a == tag);
  125. boneProp.bExistP = true;
  126. BoneMorph.dic["min+" + tag + "+" + bname] = (boneProp.vMinP = new Vector3(x, y, z));
  127. BoneMorph.dic["max+" + tag + "+" + bname] = (boneProp.vMaxP = new Vector3(x2, y2, z2));
  128. }
  129. if (!BoneMorph.dic2.TryGetValue(text, out list))
  130. {
  131. List<BoneMorph.BoneProp> list2 = new List<BoneMorph.BoneProp>();
  132. BoneMorph.dic2[text] = list2;
  133. list = list2;
  134. }
  135. boneProp = list.Find((BoneMorph.BoneProp a) => a.strProp == tag);
  136. if (boneProp == null)
  137. {
  138. boneProp = new BoneMorph.BoneProp();
  139. list.Add(boneProp);
  140. }
  141. boneProp.strProp = tag;
  142. boneProp.nIndex = Array.FindIndex<string>(BoneMorph.PropNames, (string a) => a == tag);
  143. boneProp.bExistP = true;
  144. BoneMorph.dic["min+" + tag + "+" + text] = (boneProp.vMinP = new Vector3(x, y, z));
  145. BoneMorph.dic["max+" + tag + "+" + text] = (boneProp.vMaxP = new Vector3(x2, y2, z2));
  146. }
  147. public static Dictionary<string, Vector3> dic = null;
  148. public static Dictionary<string, List<BoneMorph.BoneProp>> dic2 = new Dictionary<string, List<BoneMorph.BoneProp>>();
  149. public static string[] PropNames = new string[]
  150. {
  151. "KubiScl",
  152. "UdeScl",
  153. "EyeSclX",
  154. "EyeSclY",
  155. "EyePosX",
  156. "EyePosY",
  157. "HeadX",
  158. "HeadY",
  159. "DouPer",
  160. "sintyou",
  161. "koshi",
  162. "kata",
  163. "west",
  164. "MuneUpDown",
  165. "MuneYori"
  166. };
  167. public class BoneProp
  168. {
  169. public string strProp;
  170. public int nIndex;
  171. public bool bExistP;
  172. public bool bExistM;
  173. public Vector3 vMinP;
  174. public Vector3 vMaxP;
  175. public Vector3 vMinM;
  176. public Vector3 vMaxM;
  177. }
  178. }