BoneMorph_.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. public class BoneMorph_
  6. {
  7. public void Init()
  8. {
  9. if (this.bones != null)
  10. {
  11. for (int i = this.bones.Count - 1; i >= 0; i--)
  12. {
  13. BoneMorphLocal boneMorphLocal = this.bones[i];
  14. if (boneMorphLocal.linkT != null)
  15. {
  16. boneMorphLocal.linkT.localPosition = boneMorphLocal.pos;
  17. }
  18. }
  19. }
  20. this.bones = new List<BoneMorphLocal>();
  21. }
  22. public void Uninit()
  23. {
  24. this.m_listBoneMorphPos.Clear();
  25. this.m_listBoneMorphScl.Clear();
  26. this.m_listBoneMorphRot.Clear();
  27. }
  28. public void InitBoneMorphEdit(Transform t, MPN f_mpn, TBody.SlotID f_slot)
  29. {
  30. Func<string, Transform, BoneMorph_.BoneMorphPos> func = delegate(string propertyName, Transform boneTrans)
  31. {
  32. this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => f.strPropName == propertyName);
  33. this.m_listBoneMorphPos.Add(new BoneMorph_.BoneMorphPos(propertyName, boneTrans));
  34. return this.m_listBoneMorphPos[this.m_listBoneMorphPos.Count - 1];
  35. };
  36. Func<string, Transform, BoneMorph_.BoneMorphRotatio> func2 = delegate(string propertyName, Transform boneTrans)
  37. {
  38. this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => f.strPropName == propertyName);
  39. this.m_listBoneMorphRot.Add(new BoneMorph_.BoneMorphRotatio(propertyName, boneTrans));
  40. return this.m_listBoneMorphRot[this.m_listBoneMorphRot.Count - 1];
  41. };
  42. Func<string, Transform, BoneMorph_.BoneMorphScl> func3 = delegate(string propertyName, Transform boneTrans)
  43. {
  44. this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => f.strPropName == propertyName);
  45. this.m_listBoneMorphScl.Add(new BoneMorph_.BoneMorphScl(propertyName, boneTrans));
  46. return this.m_listBoneMorphScl[this.m_listBoneMorphScl.Count - 1];
  47. };
  48. if (f_mpn == MPN.head && f_slot == TBody.SlotID.head)
  49. {
  50. Transform transform = CMT.SearchObjName(t, "Ear_L", false);
  51. bool flag = transform != null;
  52. if (flag)
  53. {
  54. this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => f.strPropName == "MayuY");
  55. }
  56. else
  57. {
  58. HashSet<string> gp001AddPropNames = new HashSet<string>(new string[]
  59. {
  60. "Earrot_L",
  61. "Earrot_R",
  62. "Earscl_L",
  63. "Earscl_R",
  64. "Nosepos",
  65. "Nosescl",
  66. "Mayupos_L",
  67. "Mayupos_R",
  68. "Mayurot_L",
  69. "Mayurot_R"
  70. });
  71. this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => gp001AddPropNames.Contains(f.strPropName));
  72. this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => gp001AddPropNames.Contains(f.strPropName));
  73. this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => gp001AddPropNames.Contains(f.strPropName));
  74. }
  75. if (transform != null)
  76. {
  77. func2("Earrot_L", transform);
  78. func3("Earscl_L", transform);
  79. }
  80. Transform transform2 = CMT.SearchObjName(t, "Ear_R", false);
  81. if (transform2 != null)
  82. {
  83. func2("Earrot_R", transform2);
  84. func3("Earscl_R", transform2);
  85. }
  86. Transform transform3 = CMT.SearchObjName(t, "Nose", false);
  87. if (transform3 != null)
  88. {
  89. func("Nosepos", transform3);
  90. func3("Nosescl", transform3);
  91. }
  92. Transform transform4 = CMT.SearchObjName(t, "Mayupos", false);
  93. if (transform4 != null)
  94. {
  95. func("MayuY", transform4);
  96. }
  97. Transform transform5 = CMT.SearchObjName(t, "Mayupos_L", false);
  98. if (transform5 != null)
  99. {
  100. func("Mayupos_L", transform5);
  101. func2("Mayurot_L", transform5);
  102. }
  103. Transform transform6 = CMT.SearchObjName(t, "Mayupos_R", false);
  104. if (transform6 != null)
  105. {
  106. func("Mayupos_R", transform6);
  107. func2("Mayurot_R", transform6);
  108. }
  109. Transform transform7 = CMT.SearchObjName(t, "Eye_L", false);
  110. if (transform7 != null)
  111. {
  112. func("EyeBallPosXL", transform7);
  113. BoneMorph_.BoneMorphPos boneMorphPos = func("EyeBallPosYL", transform7);
  114. boneMorphPos.m_vAddMin += new Vector3(0.00325f, -0.005f, 0f);
  115. boneMorphPos.m_vAddMax += new Vector3(0f, 0.004f, 0f);
  116. BoneMorph_.BoneMorphScl boneMorphScl = func3("EyeBallSclXL", transform7);
  117. boneMorphScl.m_vAddMin += new Vector3(0f, -0.3f, -0.3f);
  118. boneMorphScl.m_vAddMax += new Vector3(0f, 0.1f, 0.1f);
  119. boneMorphScl = func3("EyeBallSclYL", transform7);
  120. boneMorphScl.m_vAddMin += new Vector3(0f, -0.3f, -0.3f);
  121. boneMorphScl.m_vAddMax += new Vector3(0f, 0.1f, 0.1f);
  122. }
  123. Transform transform8 = CMT.SearchObjName(t, "Eye_R", false);
  124. if (transform8 != null)
  125. {
  126. func("EyeBallPosXR", transform8);
  127. BoneMorph_.BoneMorphPos boneMorphPos2 = func("EyeBallPosYR", transform8);
  128. boneMorphPos2.m_vAddMin += new Vector3(0.00325f, 0.005f, 0f);
  129. boneMorphPos2.m_vAddMax += new Vector3(0f, -0.004f, 0f);
  130. BoneMorph_.BoneMorphScl boneMorphScl2 = func3("EyeBallSclXR", transform8);
  131. boneMorphScl2.m_vAddMin += new Vector3(0f, -0.3f, -0.3f);
  132. boneMorphScl2.m_vAddMax += new Vector3(0f, 0.1f, 0.1f);
  133. boneMorphScl2 = func3("EyeBallSclYR", transform8);
  134. boneMorphScl2.m_vAddMin += new Vector3(0f, -0.3f, -0.3f);
  135. boneMorphScl2.m_vAddMax += new Vector3(0f, 0.1f, 0.1f);
  136. }
  137. }
  138. }
  139. public void DelBoneMorphEdit(MPN f_mpn, TBody.SlotID f_slot)
  140. {
  141. if (f_mpn == MPN.head && f_slot == TBody.SlotID.head)
  142. {
  143. HashSet<string> removeTargetPropNames = new HashSet<string>(new string[]
  144. {
  145. "Earrot_L",
  146. "Earrot_R",
  147. "Earscl_L",
  148. "Earscl_R",
  149. "Nosepos",
  150. "Nosescl",
  151. "MayuY",
  152. "Mayupos_L",
  153. "Mayupos_R",
  154. "Mayurot_L",
  155. "Mayurot_R",
  156. "EyeBallPosXL",
  157. "EyeBallPosYL",
  158. "EyeBallSclXL",
  159. "EyeBallSclXR",
  160. "EyeBallPosXR",
  161. "EyeBallPosYR",
  162. "EyeBallSclYL",
  163. "EyeBallSclYR"
  164. });
  165. this.m_listBoneMorphPos.RemoveAll((BoneMorph_.BoneMorphPos f) => removeTargetPropNames.Contains(f.strPropName));
  166. this.m_listBoneMorphRot.RemoveAll((BoneMorph_.BoneMorphRotatio f) => removeTargetPropNames.Contains(f.strPropName));
  167. this.m_listBoneMorphScl.RemoveAll((BoneMorph_.BoneMorphScl f) => removeTargetPropNames.Contains(f.strPropName));
  168. }
  169. }
  170. private void AddRoot_lp(Transform t, int level = 0, float Kahanshin = 0f)
  171. {
  172. string name = t.name;
  173. if (name.Contains("Thigh"))
  174. {
  175. Kahanshin = 1f;
  176. }
  177. BoneMorphLocal boneMorphLocal = null;
  178. List<BoneMorph.BoneProp> list = null;
  179. if (BoneMorph.dic2.TryGetValue(name, out list))
  180. {
  181. for (int i = 0; i < list.Count; i++)
  182. {
  183. BoneMorph.BoneProp boneProp = list[i];
  184. if (boneMorphLocal == null)
  185. {
  186. boneMorphLocal = new BoneMorphLocal();
  187. boneMorphLocal.atr = 0L;
  188. boneMorphLocal.linkT = t;
  189. boneMorphLocal.pos = t.localPosition;
  190. boneMorphLocal.Kahanshin = Kahanshin;
  191. }
  192. int nIndex = boneProp.nIndex;
  193. if (boneProp.bExistM)
  194. {
  195. boneMorphLocal.atr |= 1L << nIndex;
  196. boneMorphLocal.vecs_min[nIndex] = boneProp.vMinM;
  197. boneMorphLocal.vecs_max[nIndex] = boneProp.vMaxM;
  198. }
  199. if (boneProp.bExistP)
  200. {
  201. boneMorphLocal.atr |= 1L << nIndex + 32;
  202. boneMorphLocal.vecs_min[nIndex + 32] = boneProp.vMinP;
  203. boneMorphLocal.vecs_max[nIndex + 32] = boneProp.vMaxP;
  204. }
  205. boneMorphLocal.props.Add(boneProp.strProp);
  206. }
  207. }
  208. if (boneMorphLocal != null)
  209. {
  210. this.bones.Add(boneMorphLocal);
  211. }
  212. for (int j = 0; j < t.childCount; j++)
  213. {
  214. this.AddRoot_lp(t.GetChild(j), level + 1, Kahanshin);
  215. }
  216. }
  217. public void AddRoot(Transform root)
  218. {
  219. this.AddRoot_lp(root, 0, 0f);
  220. }
  221. public void ChangeMorphPosValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax)
  222. {
  223. BoneMorph_.BoneMorphPos boneMorphPos = this.m_listBoneMorphPos.Find((BoneMorph_.BoneMorphPos f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName);
  224. if (boneMorphPos != null)
  225. {
  226. boneMorphPos.m_vAddMin = boneMorphPos.trBone.localPosition + f_fAddMin;
  227. boneMorphPos.m_vAddMax = boneMorphPos.trBone.localPosition + f_fAddMax;
  228. }
  229. }
  230. public void ChangeMorphSclValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax)
  231. {
  232. BoneMorph_.BoneMorphScl boneMorphScl = this.m_listBoneMorphScl.Find((BoneMorph_.BoneMorphScl f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName);
  233. if (boneMorphScl != null)
  234. {
  235. boneMorphScl.m_vAddMin = boneMorphScl.trBone.localScale + f_fAddMin;
  236. boneMorphScl.m_vAddMax = boneMorphScl.trBone.localScale + f_fAddMax;
  237. }
  238. }
  239. public void ChangeMorphRotatioValue(string strPropName, string f_strBoneName, Vector3 f_fAddMin, Vector3 f_fAddMax)
  240. {
  241. BoneMorph_.BoneMorphRotatio boneMorphRotatio = this.m_listBoneMorphRot.Find((BoneMorph_.BoneMorphRotatio f) => f.strPropName == strPropName && f.trBone.name == f_strBoneName);
  242. if (boneMorphRotatio != null)
  243. {
  244. boneMorphRotatio.m_vAddMin = boneMorphRotatio.m_vDefRotate * Quaternion.Euler(f_fAddMin);
  245. boneMorphRotatio.m_vAddMax = boneMorphRotatio.m_vDefRotate * Quaternion.Euler(f_fAddMax);
  246. }
  247. }
  248. public void Blend()
  249. {
  250. for (int i = this.bones.Count - 1; i >= 0; i--)
  251. {
  252. BoneMorphLocal boneMorphLocal = this.bones[i];
  253. Vector3 vector = new Vector3(1f, 1f, 1f);
  254. Vector3 vector2 = boneMorphLocal.pos;
  255. for (int j = 0; j < BoneMorph.PropNames.Length; j++)
  256. {
  257. float num = 1f;
  258. if (j == 0)
  259. {
  260. num = this.SCALE_Kubi;
  261. }
  262. if (j == 1)
  263. {
  264. num = this.SCALE_Ude;
  265. }
  266. if (j == 2)
  267. {
  268. num = this.SCALE_EyeX;
  269. }
  270. if (j == 3)
  271. {
  272. num = this.SCALE_EyeY;
  273. }
  274. if (j == 4)
  275. {
  276. num = this.Postion_EyeX * (0.5f + this.Postion_EyeY * 0.5f);
  277. }
  278. if (j == 5)
  279. {
  280. num = this.Postion_EyeY;
  281. }
  282. if (j == 6)
  283. {
  284. num = this.SCALE_HeadX;
  285. }
  286. if (j == 7)
  287. {
  288. num = this.SCALE_HeadY;
  289. }
  290. if (j == 8)
  291. {
  292. num = this.SCALE_DouPer;
  293. if (boneMorphLocal.Kahanshin == 0f)
  294. {
  295. num = 1f - num;
  296. }
  297. }
  298. if (j == 9)
  299. {
  300. num = this.SCALE_Sintyou;
  301. }
  302. if (j == 10)
  303. {
  304. num = this.SCALE_Koshi;
  305. }
  306. if (j == 11)
  307. {
  308. num = this.SCALE_Kata;
  309. }
  310. if (j == 12)
  311. {
  312. num = this.SCALE_West;
  313. }
  314. if ((boneMorphLocal.atr & 1L << j) != 0L)
  315. {
  316. vector = Vector3.Scale(vector, Vector3.Lerp(boneMorphLocal.vecs_min[j], boneMorphLocal.vecs_max[j], num));
  317. }
  318. if ((boneMorphLocal.atr & 1L << 32 + j) != 0L)
  319. {
  320. vector2 = Vector3.Scale(vector2, Vector3.Lerp(boneMorphLocal.vecs_min[j + 32], boneMorphLocal.vecs_max[j + 32], num));
  321. }
  322. }
  323. if (boneMorphLocal.linkT.name.Contains("Thigh_SCL_"))
  324. {
  325. this.SnityouOutScale = Mathf.Pow(vector.x, 0.9f);
  326. }
  327. boneMorphLocal.linkT.localPosition = vector2;
  328. boneMorphLocal.linkT.localScale = vector;
  329. }
  330. for (int k = 0; k < this.m_listBoneMorphPos.Count; k++)
  331. {
  332. BoneMorph_.BoneMorphPos boneMorphPos = this.m_listBoneMorphPos[k];
  333. if (boneMorphPos.strPropName == "Nosepos")
  334. {
  335. boneMorphPos.trBone.localPosition = boneMorphPos.Lerp(this.POS_Nose);
  336. }
  337. else if (boneMorphPos.strPropName == "MayuY")
  338. {
  339. boneMorphPos.trBone.localPosition = boneMorphPos.Lerp(this.POS_MayuY);
  340. }
  341. else if (boneMorphPos.strPropName == "Mayupos_L" || boneMorphPos.strPropName == "Mayupos_R")
  342. {
  343. Vector3 vector3 = boneMorphPos.Lerp(this.POS_MayuY);
  344. float x = boneMorphPos.m_vAddMin.x;
  345. boneMorphPos.m_vAddMin = new Vector3(boneMorphPos.m_vAddMax.x, boneMorphPos.m_vAddMin.y, boneMorphPos.m_vAddMin.z);
  346. boneMorphPos.m_vAddMax = new Vector3(x, boneMorphPos.m_vAddMax.y, boneMorphPos.m_vAddMax.z);
  347. Vector3 vector4 = boneMorphPos.Lerp(this.POS_MayuX);
  348. x = boneMorphPos.m_vAddMax.x;
  349. boneMorphPos.m_vAddMax = new Vector3(boneMorphPos.m_vAddMin.x, boneMorphPos.m_vAddMax.y, boneMorphPos.m_vAddMax.z);
  350. boneMorphPos.m_vAddMin = new Vector3(x, boneMorphPos.m_vAddMin.y, boneMorphPos.m_vAddMin.z);
  351. float x2 = vector4.x + vector3.x - boneMorphPos.m_vDefPos.x;
  352. boneMorphPos.trBone.localPosition = new Vector3(x2, vector3.y, vector4.z);
  353. }
  354. else if (boneMorphPos.strPropName == "EyeBallPosYL" || boneMorphPos.strPropName == "EyeBallPosYR")
  355. {
  356. boneMorphPos.trBone.localPosition = ((this.EyeBallPosY > 0.5f) ? Vector3.Lerp(boneMorphPos.m_vDefPos, boneMorphPos.m_vAddMax, (this.EyeBallPosY - 0.5f) / 0.5f) : Vector3.Lerp(boneMorphPos.m_vAddMin, boneMorphPos.m_vDefPos, this.EyeBallPosY / 0.5f));
  357. }
  358. }
  359. for (int l = 0; l < this.m_listBoneMorphScl.Count; l++)
  360. {
  361. BoneMorph_.BoneMorphScl boneMorphScl = this.m_listBoneMorphScl[l];
  362. if (boneMorphScl.strPropName == "Earscl_L" || boneMorphScl.strPropName == "Earscl_R")
  363. {
  364. boneMorphScl.trBone.localScale = boneMorphScl.Lerp(this.SCALE_Ear);
  365. }
  366. else if (boneMorphScl.strPropName == "Nosescl")
  367. {
  368. boneMorphScl.trBone.localScale = boneMorphScl.Lerp(this.SCALE_Nose);
  369. }
  370. else if (boneMorphScl.strPropName == "EyeBallSclXL" || boneMorphScl.strPropName == "EyeBallSclXR")
  371. {
  372. float z = (this.EyeBallSclX >= 0.5f) ? Mathf.Lerp(boneMorphScl.m_vDefScl.z, boneMorphScl.m_vAddMax.z, (this.EyeBallSclX - 0.5f) / 0.5f) : Mathf.Lerp(boneMorphScl.m_vAddMin.z, boneMorphScl.m_vDefScl.z, this.EyeBallSclX / 0.5f);
  373. Vector3 localScale = boneMorphScl.trBone.localScale;
  374. localScale.z = z;
  375. boneMorphScl.trBone.localScale = localScale;
  376. }
  377. else if (boneMorphScl.strPropName == "EyeBallSclYL" || boneMorphScl.strPropName == "EyeBallSclYR")
  378. {
  379. float y = (this.EyeBallSclY >= 0.5f) ? Mathf.Lerp(boneMorphScl.m_vDefScl.y, boneMorphScl.m_vAddMax.y, (this.EyeBallSclY - 0.5f) / 0.5f) : Mathf.Lerp(boneMorphScl.m_vAddMin.y, boneMorphScl.m_vDefScl.y, this.EyeBallSclY / 0.5f);
  380. Vector3 localScale2 = boneMorphScl.trBone.localScale;
  381. localScale2.y = y;
  382. boneMorphScl.trBone.localScale = localScale2;
  383. }
  384. }
  385. foreach (BoneMorph_.BoneMorphRotatio boneMorphRotatio in this.m_listBoneMorphRot)
  386. {
  387. if (boneMorphRotatio.strPropName == "Earrot_L" || boneMorphRotatio.strPropName == "Earrot_R")
  388. {
  389. boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Ear);
  390. }
  391. if (boneMorphRotatio.strPropName == "Mayurot_L" || boneMorphRotatio.strPropName == "Mayurot_R")
  392. {
  393. boneMorphRotatio.trBone.localRotation = boneMorphRotatio.Lerp(this.ROT_Mayu);
  394. }
  395. }
  396. }
  397. private TextAsset textUserDef1;
  398. public float SCALE_Sintyou = 1f;
  399. public float SCALE_Koshi = 1f;
  400. public float SCALE_DouPer;
  401. public float SCALE_Kata = 1f;
  402. public float SCALE_West = 1f;
  403. public float SCALE_EyeX = 1f;
  404. public float SCALE_EyeY = 1f;
  405. public float Postion_EyeX = 1f;
  406. public float Postion_EyeY = 1f;
  407. public float EyeBallPosX = 0.5f;
  408. public float EyeBallPosY = 0.5f;
  409. public float EyeBallSclX = 0.5f;
  410. public float EyeBallSclY = 0.5f;
  411. public float SCALE_Kubi = 1f;
  412. public float SCALE_Ude = 1f;
  413. public float SCALE_HeadX = 1f;
  414. public float SCALE_HeadY = 1f;
  415. public float POS_Nose = 0.5f;
  416. public float SCALE_Nose = 0.5f;
  417. public float ROT_Ear = 0.5f;
  418. public float SCALE_Ear = 0.5f;
  419. public float POS_MayuX = 0.5f;
  420. public float POS_MayuY = 0.5f;
  421. public float ROT_Mayu = 0.5f;
  422. public List<BoneMorphLocal> bones;
  423. public float SnityouOutScale = 1f;
  424. private bool m_bMayuOffs;
  425. private List<BoneMorph_.BoneMorphPos> m_listBoneMorphPos = new List<BoneMorph_.BoneMorphPos>();
  426. private List<BoneMorph_.BoneMorphScl> m_listBoneMorphScl = new List<BoneMorph_.BoneMorphScl>();
  427. private List<BoneMorph_.BoneMorphRotatio> m_listBoneMorphRot = new List<BoneMorph_.BoneMorphRotatio>();
  428. private static StringBuilder sbMinM = new StringBuilder(32);
  429. private static StringBuilder sbMinP = new StringBuilder(32);
  430. private static StringBuilder sbMaxM = new StringBuilder(32);
  431. private static StringBuilder sbMaxP = new StringBuilder(32);
  432. private class BoneMorphPos
  433. {
  434. public BoneMorphPos(string f_strPropName, Transform f_trBone)
  435. {
  436. this.strPropName = f_strPropName;
  437. this.trBone = f_trBone;
  438. this.m_vAddMin = (this.m_vAddMax = (this.m_vDefPos = f_trBone.localPosition));
  439. }
  440. public BoneMorphPos(string f_strPropName, Transform f_trBone, Vector3 f_vAddMin, Vector3 f_vAddMax)
  441. {
  442. this.strPropName = f_strPropName;
  443. this.trBone = f_trBone;
  444. this.m_vDefPos = f_trBone.localPosition;
  445. this.m_vAddMin = this.m_vDefPos + f_vAddMin;
  446. this.m_vAddMax = this.m_vDefPos + f_vAddMax;
  447. }
  448. public Vector3 Lerp(float t)
  449. {
  450. return BoneMorph_.BoneMorphPos.Lerp(this.m_vAddMin, this.m_vDefPos, this.m_vAddMax, t);
  451. }
  452. public static Vector3 Lerp(Vector3 min, Vector3 def, Vector3 max, float t)
  453. {
  454. float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f);
  455. return (t > 0.5f) ? Vector3.Lerp(def, max, t2) : Vector3.Lerp(min, def, t2);
  456. }
  457. public static float Lerp(float min, float def, float max, float t)
  458. {
  459. float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f);
  460. return (t > 0.5f) ? Mathf.Lerp(def, max, t2) : Mathf.Lerp(min, def, t2);
  461. }
  462. public string strPropName;
  463. public Transform trBone;
  464. public Vector3 m_vDefPos;
  465. public Vector3 m_vAddMin;
  466. public Vector3 m_vAddMax;
  467. }
  468. private class BoneMorphScl
  469. {
  470. public BoneMorphScl(string f_strPropName, Transform f_trBone)
  471. {
  472. this.strPropName = f_strPropName;
  473. this.trBone = f_trBone;
  474. this.m_vAddMin = (this.m_vAddMax = (this.m_vDefScl = f_trBone.localScale));
  475. }
  476. public BoneMorphScl(string f_strPropName, Transform f_trBone, Vector3 f_vAddMin, Vector3 f_vAddMax)
  477. {
  478. this.strPropName = f_strPropName;
  479. this.trBone = f_trBone;
  480. this.m_vDefScl = f_trBone.localScale;
  481. this.m_vAddMin = this.m_vDefScl + f_vAddMin;
  482. this.m_vAddMax = this.m_vDefScl + f_vAddMax;
  483. }
  484. public Vector3 Lerp(float t)
  485. {
  486. return BoneMorph_.BoneMorphPos.Lerp(this.m_vAddMin, this.m_vDefScl, this.m_vAddMax, t);
  487. }
  488. public string strPropName;
  489. public Transform trBone;
  490. public Vector3 m_vDefScl;
  491. public Vector3 m_vAddMin;
  492. public Vector3 m_vAddMax;
  493. }
  494. private class BoneMorphRotatio
  495. {
  496. public BoneMorphRotatio(string f_strPropName, Transform f_trBone)
  497. {
  498. this.strPropName = f_strPropName;
  499. this.trBone = f_trBone;
  500. this.m_vAddMin = (this.m_vAddMax = (this.m_vDefRotate = f_trBone.localRotation));
  501. }
  502. public BoneMorphRotatio(string f_strPropName, Transform f_trBone, Quaternion f_vAddMin, Quaternion f_vAddMax)
  503. {
  504. this.strPropName = f_strPropName;
  505. this.trBone = f_trBone;
  506. this.m_vDefRotate = f_trBone.localRotation;
  507. this.m_vAddMin = this.m_vDefRotate * f_vAddMin;
  508. this.m_vAddMax = this.m_vDefRotate * f_vAddMax;
  509. }
  510. public Quaternion Lerp(float t)
  511. {
  512. return BoneMorph_.BoneMorphRotatio.Lerp(this.m_vAddMin, this.m_vDefRotate, this.m_vAddMax, t);
  513. }
  514. public static Quaternion Lerp(Quaternion min, Quaternion def, Quaternion max, float t)
  515. {
  516. float t2 = (t > 0.5f) ? ((t - 0.5f) / 0.5f) : (t / 0.5f);
  517. return (t > 0.5f) ? Quaternion.Lerp(def, max, t2) : Quaternion.Lerp(min, def, t2);
  518. }
  519. public string strPropName;
  520. public Transform trBone;
  521. public Quaternion m_vDefRotate;
  522. public Quaternion m_vAddMin;
  523. public Quaternion m_vAddMax;
  524. }
  525. }