TBodySkin.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Reflection;
  6. using System.Text.RegularExpressions;
  7. using UnityEngine;
  8. public class TBodySkin
  9. {
  10. public TBodySkin(TBody body_, string cate_, TBody.SlotID slot_id_, bool man)
  11. {
  12. this.boVisible = true;
  13. this.body = body_;
  14. this.Category = cate_;
  15. this.SlotId = slot_id_;
  16. this.m_bMan = man;
  17. this.m_trMaid = this.body.maid.transform;
  18. this.m_trMaidOffs = this.body.maid.m_goOffset.transform;
  19. this.bonehair = new TBoneHair_(this);
  20. this.TextureCache = new InfinityColorTextureCache(body_.maid);
  21. this.bonehair2 = new BoneHair2(this);
  22. this.bonehair3 = new BoneHair3(this);
  23. this.m_HairLengthCtrl = new TBodySkin.HairLengthCtrl(this);
  24. }
  25. public void AddRtMaterial(Material f_mat)
  26. {
  27. this.m_listRtMaterial.Add(f_mat);
  28. }
  29. public int PartsVersion
  30. {
  31. get
  32. {
  33. return this.m_partsVersion;
  34. }
  35. }
  36. public KupaCtrl kupaCtrl { get; private set; }
  37. public void DeleteObj()
  38. {
  39. this.m_ParentMPN = MPN.null_mpn;
  40. this.m_mp = null;
  41. this.m_animItem = null;
  42. this.body.MulTexRemove(this.Category);
  43. this.TextureCache.RemoveTexture();
  44. this.m_listManAlphaMat.Clear();
  45. this.m_HairLengthCtrl.NotExistThenClearHairLength();
  46. this.listTrs = null;
  47. this.listTrsScr = null;
  48. this.trsBoneAttach = null;
  49. foreach (UnityEngine.Object @object in this.listDEL)
  50. {
  51. UnityEngine.Object.DestroyImmediate(@object);
  52. }
  53. this.listDEL = new List<UnityEngine.Object>();
  54. this.boMizugi = false;
  55. if (this.morph != null)
  56. {
  57. this.morph.DeleteObj();
  58. this.morph = null;
  59. }
  60. this.boVisible = false;
  61. this.listMaskSlot = new List<int>();
  62. this.m_dicBackupShader.Clear();
  63. if (this.bonehair != null)
  64. {
  65. this.bonehair.Init();
  66. }
  67. if (this.bonehair2 != null)
  68. {
  69. this.bonehair2.Uninit();
  70. }
  71. if (this.bonehair3 != null)
  72. {
  73. this.bonehair3.Uninit();
  74. }
  75. if (this.obj != null)
  76. {
  77. this.obj_tr.parent = null;
  78. UnityEngine.Object.DestroyImmediate(this.obj);
  79. this.obj = null;
  80. this.obj_tr = null;
  81. }
  82. this.m_dicDelNodeParts.Clear();
  83. this.m_dicParam.Clear();
  84. this.m_dicParam2.Clear();
  85. this.m_OriVert.Clear();
  86. this.m_ParentMPN = MPN.null_mpn;
  87. this.m_mp = null;
  88. this.m_bHitFloorY = true;
  89. this.m_partsVersion = 0;
  90. this.kupaCtrl = null;
  91. }
  92. public void NewParamSet(string A)
  93. {
  94. string[] stringList = UTY.GetStringList(A);
  95. string key = stringList[1];
  96. int num = (stringList.Length - 2) / 2;
  97. KeyValuePair<float, string>[] array = new KeyValuePair<float, string>[num];
  98. for (int i = 0; i < num; i++)
  99. {
  100. string value = stringList[3 + i * 2];
  101. float key2 = float.Parse(stringList[2 + i * 2]);
  102. array[i] = new KeyValuePair<float, string>(key2, value);
  103. }
  104. this.dicParamSet[key] = array;
  105. }
  106. public void SetParam(string f_strTag, string f_strValue)
  107. {
  108. if (this.m_dicParam.ContainsKey(f_strTag))
  109. {
  110. this.m_dicParam[f_strTag] = f_strValue;
  111. }
  112. else
  113. {
  114. this.m_dicParam.Add(f_strTag, f_strValue);
  115. }
  116. }
  117. public string GetParam(string f_strTag)
  118. {
  119. string empty;
  120. this.m_dicParam.TryGetValue(f_strTag, out empty);
  121. if (empty == null)
  122. {
  123. empty = string.Empty;
  124. }
  125. return empty;
  126. }
  127. public void SetParam2(string f_strTag, string f_strValue)
  128. {
  129. if (this.m_dicParam2.ContainsKey(f_strTag))
  130. {
  131. this.m_dicParam2[f_strTag] = f_strValue;
  132. }
  133. else
  134. {
  135. this.m_dicParam2.Add(f_strTag, f_strValue);
  136. }
  137. }
  138. public string GetParam2(string f_strTag)
  139. {
  140. string empty;
  141. this.m_dicParam2.TryGetValue(f_strTag, out empty);
  142. if (empty == null)
  143. {
  144. empty = string.Empty;
  145. }
  146. return empty;
  147. }
  148. public void SetMaterialProperty(MPN f_SrcMpn, int f_nMatNo, string f_strPropName, string f_strTypeName, string f_strValue, bool f_bEditSave)
  149. {
  150. if (this.obj == null)
  151. {
  152. return;
  153. }
  154. foreach (Transform transform in this.obj.transform.GetComponentsInChildren<Transform>(true))
  155. {
  156. Renderer component = transform.GetComponent<Renderer>();
  157. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  158. {
  159. Material material = component.materials[f_nMatNo];
  160. if (f_strTypeName == "DEFINE")
  161. {
  162. if (f_strValue == "0")
  163. {
  164. material.DisableKeyword(f_strPropName);
  165. }
  166. else if (f_strValue == "1")
  167. {
  168. material.EnableKeyword(f_strPropName);
  169. }
  170. }
  171. else
  172. {
  173. Type type = Assembly.Load("UnityEngine.dll").GetType(f_strTypeName);
  174. if (type == null)
  175. {
  176. type = Type.GetType(f_strTypeName, false, true);
  177. }
  178. if (type == null)
  179. {
  180. Debug.LogError("タイプ " + f_strTypeName + " は存在しません。");
  181. return;
  182. }
  183. if (material.HasProperty(f_strPropName))
  184. {
  185. material.SetFloat(f_strPropName, float.Parse(f_strValue));
  186. if (f_bEditSave)
  187. {
  188. this.body.maid.SetMaterialProperty(f_SrcMpn, this.SlotId, f_nMatNo, f_strPropName, f_strTypeName, f_strValue);
  189. }
  190. else
  191. {
  192. MatPropSave materialProperty = this.body.maid.GetMaterialProperty(f_SrcMpn, this.SlotId);
  193. if (materialProperty != null)
  194. {
  195. this.SetMaterialProperty(f_SrcMpn, materialProperty.nMatNo, materialProperty.strPropName, materialProperty.strTypeName, materialProperty.strValue, true);
  196. }
  197. }
  198. }
  199. else
  200. {
  201. Debug.LogWarning(f_strPropName + "はありませんでした。");
  202. }
  203. }
  204. }
  205. }
  206. }
  207. public string GetMaterialProperty(int f_nMatNo, string f_strPropName, string f_strType = "AUTO")
  208. {
  209. if (this.obj == null)
  210. {
  211. return string.Empty;
  212. }
  213. bool flag = f_strType == "DEFINE";
  214. Transform[] componentsInChildren = this.obj.transform.GetComponentsInChildren<Transform>(true);
  215. int i = 0;
  216. while (i < componentsInChildren.Length)
  217. {
  218. Transform transform = componentsInChildren[i];
  219. Renderer component = transform.GetComponent<Renderer>();
  220. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  221. {
  222. Material material = component.materials[f_nMatNo];
  223. if (flag)
  224. {
  225. return (!material.IsKeywordEnabled(f_strPropName)) ? "0" : "1";
  226. }
  227. return material.GetFloat(f_strPropName).ToString();
  228. }
  229. else
  230. {
  231. i++;
  232. }
  233. }
  234. return string.Empty;
  235. }
  236. public void ChangeShader(int f_nMatNo, string f_strShaderFileName)
  237. {
  238. this.ChangeShader(f_nMatNo, Resources.Load<Shader>("Shaders/" + f_strShaderFileName));
  239. }
  240. private void ChangeShader(int f_nMatNo, Shader f_shader)
  241. {
  242. GameObject gameObject = this.obj;
  243. if (gameObject == null)
  244. {
  245. return;
  246. }
  247. foreach (Transform transform in gameObject.transform.GetComponentsInChildren<Transform>(true))
  248. {
  249. Renderer component = transform.GetComponent<Renderer>();
  250. if (component != null && component.material != null && f_nMatNo < component.materials.Length)
  251. {
  252. if (!this.m_dicBackupShader.ContainsKey(f_nMatNo))
  253. {
  254. this.m_dicBackupShader[f_nMatNo] = component.materials[f_nMatNo].shader;
  255. }
  256. Material material = component.materials[f_nMatNo];
  257. int renderQueue = material.renderQueue;
  258. material.shader = f_shader;
  259. material.renderQueue = renderQueue;
  260. }
  261. }
  262. }
  263. public void RestoreShader()
  264. {
  265. foreach (KeyValuePair<int, Shader> keyValuePair in this.m_dicBackupShader)
  266. {
  267. this.ChangeShader(keyValuePair.Key, keyValuePair.Value);
  268. }
  269. this.m_dicBackupShader.Clear();
  270. }
  271. public bool EnablePartsPosEdit
  272. {
  273. get
  274. {
  275. return this.m_bEnablePartPosEdit;
  276. }
  277. set
  278. {
  279. if (this.m_bEnablePartPosEdit == value)
  280. {
  281. return;
  282. }
  283. if (value)
  284. {
  285. BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
  286. if (tbodySkinPos != null && this.obj_tr != null)
  287. {
  288. Vector3 vector = tbodySkinPos.pss.position;
  289. this.obj_tr.localPosition = vector;
  290. this.m_vPosLocal = vector;
  291. Quaternion rotation = tbodySkinPos.pss.rotation;
  292. this.obj_tr.localRotation = rotation;
  293. this.m_qRotLocal = rotation;
  294. vector = tbodySkinPos.pss.scale;
  295. this.obj_tr.localScale = vector;
  296. this.m_vScaleRate = vector;
  297. }
  298. }
  299. else if (this.obj_tr != null)
  300. {
  301. this.obj_tr.localPosition = this.m_vDefPosLocal;
  302. this.obj_tr.localRotation = this.m_qDefRotLocal;
  303. this.obj_tr.localScale = this.m_vDefScaleLocal;
  304. }
  305. if (this.center_tr != null)
  306. {
  307. this.center_tr.localPosition = this.m_vCenterPosLocal;
  308. this.center_tr.localRotation = Quaternion.identity;
  309. this.center_tr.localScale = Vector3.one;
  310. }
  311. this.m_bEnablePartPosEdit = value;
  312. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  313. }
  314. }
  315. public bool GetAttachObjPointLocal(out Vector3 f_vPosLocal, out Quaternion f_vRotLocal, out Vector3 f_vScaleLocal)
  316. {
  317. f_vPosLocal = Vector3.zero;
  318. f_vRotLocal = Quaternion.identity;
  319. f_vScaleLocal = Vector3.zero;
  320. return false;
  321. }
  322. public bool SetAttachObjPointLocal(Vector3 f_vPosLocal, Quaternion f_vRotLocal, Vector3 f_vScaleLocal)
  323. {
  324. return false;
  325. }
  326. public bool CopyAttachObjPoint()
  327. {
  328. if (this.center_tr == null || this.obj_tr == null)
  329. {
  330. return false;
  331. }
  332. this.m_vTempAttachPointPos = this.obj_tr.localPosition;
  333. this.m_qTempAttachPointRot = this.obj_tr.localRotation;
  334. this.m_vTempAttachPointScale = this.obj_tr.localScale;
  335. return true;
  336. }
  337. public bool PastAttachObjPoint()
  338. {
  339. if (this.center_tr == null || this.obj_tr == null || !this.m_bEnablePartPosEdit)
  340. {
  341. return false;
  342. }
  343. Vector3 vector = this.m_vTempAttachPointPos;
  344. this.obj_tr.localPosition = vector;
  345. this.m_vPosLocal = vector;
  346. Quaternion qTempAttachPointRot = this.m_qTempAttachPointRot;
  347. this.obj_tr.localRotation = qTempAttachPointRot;
  348. this.m_qRotLocal = qTempAttachPointRot;
  349. vector = this.m_vTempAttachPointScale;
  350. this.obj_tr.localScale = vector;
  351. this.m_vScaleRate = vector;
  352. this.center_tr.localPosition = this.m_vCenterPosLocal;
  353. this.center_tr.localRotation = Quaternion.identity;
  354. this.center_tr.localScale = Vector3.one;
  355. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  356. return true;
  357. }
  358. public bool GetAttachCenterPointWorld(out Vector3 f_vPosWorld, out Quaternion f_vRotWorld, out Vector3 f_vScaleLocal)
  359. {
  360. if (this.center_tr == null)
  361. {
  362. f_vPosWorld = Vector3.zero;
  363. f_vRotWorld = Quaternion.identity;
  364. f_vScaleLocal = Vector3.zero;
  365. return false;
  366. }
  367. f_vPosWorld = this.center_tr.position;
  368. f_vRotWorld = this.center_tr.rotation;
  369. f_vScaleLocal = this.m_vScaleRate;
  370. return true;
  371. }
  372. public bool SetAttachCenterPointWorld(Vector3 f_vPosWorld, Quaternion f_vRotWorld, Vector3 f_vScaleLocal)
  373. {
  374. if (this.center_tr == null || !this.m_bEnablePartPosEdit)
  375. {
  376. return false;
  377. }
  378. Transform parent = this.center_tr.parent;
  379. Transform parent2 = this.obj_tr.parent;
  380. this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
  381. this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
  382. this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
  383. this.center_tr.localPosition = this.m_vCenterPosLocal;
  384. this.center_tr.localRotation = Quaternion.identity;
  385. this.center_tr.localScale = Vector3.one;
  386. this.center_tr.SetParent(this.obj_tr.parent, true);
  387. this.obj_tr.SetParent(this.center_tr, true);
  388. this.center_tr.position = f_vPosWorld;
  389. this.center_tr.rotation = f_vRotWorld;
  390. this.center_tr.localScale = f_vScaleLocal;
  391. this.obj_tr.SetParent(parent2, true);
  392. this.center_tr.SetParent(parent, true);
  393. this.center_tr.localPosition = this.m_vCenterPosLocal;
  394. this.center_tr.localRotation = Quaternion.identity;
  395. this.center_tr.localScale = Vector3.one;
  396. this.m_vPosLocal = this.obj_tr.localPosition;
  397. this.m_qRotLocal = this.obj_tr.localRotation;
  398. this.m_vScaleRate = this.obj_tr.localScale;
  399. this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
  400. return true;
  401. }
  402. public bool ResetAttachCenterPoint()
  403. {
  404. if (this.center_tr == null)
  405. {
  406. return false;
  407. }
  408. this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
  409. this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
  410. this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
  411. this.center_tr.localPosition = this.m_vCenterPosLocal;
  412. this.center_tr.localRotation = Quaternion.identity;
  413. this.center_tr.localScale = Vector3.one;
  414. this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
  415. return true;
  416. }
  417. public void LoadHitcheckData(Transform body_bone, string fn, int rot, string tag)
  418. {
  419. this.bonehair.Init();
  420. this.bonehair.LoadHitCheck(body_bone, fn + ".hitcheck", rot, tag);
  421. this.bonehair2.Init();
  422. this.bonehair3.Init();
  423. }
  424. public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp)
  425. {
  426. this.Load(mpn, srcbody, body1, trans, bonename, filename, slotname, AttachSlot, layer, f_bTemp, 100);
  427. }
  428. public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp, int version)
  429. {
  430. this.DeleteObj();
  431. this.m_partsVersion = version;
  432. if (mpn == MPN.accashi || mpn == MPN.shoes)
  433. {
  434. this.m_bHitFloorY = false;
  435. }
  436. this.m_ParentMPN = mpn;
  437. if (this.m_ParentMPN != MPN.null_mpn)
  438. {
  439. this.m_mp = this.body.maid.GetProp(this.m_ParentMPN);
  440. }
  441. this.m_bTemp = f_bTemp;
  442. this.boVisible = true;
  443. Vector3 position = srcbody.position;
  444. Quaternion rotation = srcbody.rotation;
  445. Vector3 localScale = srcbody.localScale;
  446. Vector3 position2 = body1.position;
  447. Quaternion rotation2 = body1.rotation;
  448. Vector3 localScale2 = body1.localScale;
  449. srcbody.position = Vector3.zero;
  450. srcbody.rotation = Quaternion.identity;
  451. srcbody.localScale = new Vector3(1f / srcbody.lossyScale.x, 1f / srcbody.lossyScale.y, 1f / srcbody.lossyScale.z);
  452. body1.position = Vector3.zero;
  453. body1.rotation = Quaternion.identity;
  454. body1.localScale = new Vector3(1f / body1.lossyScale.x, 1f / body1.lossyScale.y, 1f / body1.lossyScale.z);
  455. this.morph = new TMorph(this);
  456. GameObject gameObject = ImportCM.LoadSkinMesh_R(filename, this.morph, slotname, this, layer);
  457. if (this.m_bMan)
  458. {
  459. foreach (Transform transform in gameObject.GetComponentsInChildren<Transform>(true))
  460. {
  461. Renderer component = transform.GetComponent<Renderer>();
  462. if (!(component == null) && component.materials != null)
  463. {
  464. foreach (Material material in component.materials)
  465. {
  466. if (material.shader.name == "CM3D2/Man")
  467. {
  468. this.m_listManAlphaMat.Add(material);
  469. }
  470. if (material.shader.name == "CM3D2/Mosaic")
  471. {
  472. material.SetFloat("_FloatValue1", 15f);
  473. }
  474. }
  475. }
  476. }
  477. }
  478. this.morph.InitGameObject(gameObject);
  479. if (Product.SIBD && !Product.VBA && mpn == MPN.body)
  480. {
  481. this.kupaCtrl = new KupaCtrl(this.body, this.morph);
  482. }
  483. gameObject.transform.parent = CMT.SearchObjName(srcbody, bonename, true);
  484. Vector3 localPosition = gameObject.transform.localPosition;
  485. Vector3 localScale3 = gameObject.transform.localScale;
  486. Quaternion localRotation = gameObject.transform.localRotation;
  487. gameObject.transform.parent = CMT.SearchObjName(body1, bonename, true);
  488. if (!string.IsNullOrEmpty(AttachSlot))
  489. {
  490. this.AttachVisible = true;
  491. }
  492. if (AttachSlot == "ボーンにアタッチ" && (bonename == "_IK_handR" || bonename == "_IK_handL"))
  493. {
  494. localPosition = Vector3.zero;
  495. localRotation = Quaternion.identity;
  496. localScale3 = Vector3.one;
  497. }
  498. gameObject.transform.localPosition = localPosition;
  499. gameObject.transform.localRotation = localRotation;
  500. gameObject.transform.localScale = localScale3;
  501. this.obj = gameObject;
  502. this.obj_tr = this.obj.transform;
  503. this.listTrs = new List<Transform>(200);
  504. this.listTrsScr = new List<Transform>(4);
  505. CMT.BindTrans(this.listTrs, this.listTrsScr, trans, gameObject.transform);
  506. srcbody.position = position;
  507. srcbody.rotation = rotation;
  508. srcbody.localScale = localScale;
  509. body1.position = position2;
  510. body1.rotation = rotation2;
  511. body1.localScale = localScale2;
  512. if (this.body.m_bNewPhyscs)
  513. {
  514. if (!this.bonehair2.InitGameObject(gameObject, mpn))
  515. {
  516. bool bNoSkirt = this.bonehair3.InitGameObject(gameObject, mpn);
  517. this.bonehair.SearchGameObj(gameObject, bNoSkirt);
  518. }
  519. }
  520. else
  521. {
  522. this.bonehair.SearchGameObj(gameObject, false);
  523. }
  524. this.ItemScaleReset();
  525. this.OnChangeScreenSizeOrAA();
  526. if (this.m_bMan)
  527. {
  528. this.ManColorUpdate();
  529. }
  530. foreach (KeyValuePair<string, float> keyValuePair in this.m_BonehairBodyhitScaleBackup)
  531. {
  532. this.bonehair.bodyhit.ScaleMune(keyValuePair.Key, keyValuePair.Value);
  533. }
  534. IEnumerator enumerator2 = this.morph.hash.Keys.GetEnumerator();
  535. try
  536. {
  537. while (enumerator2.MoveNext())
  538. {
  539. object obj = enumerator2.Current;
  540. string key = (string)obj;
  541. int f_nIdx = (int)this.morph.hash[key];
  542. float f_fValue;
  543. if (this.body.m_MorphBlendValues.TryGetValue(key, out f_fValue))
  544. {
  545. this.morph.SetBlendValues(f_nIdx, f_fValue);
  546. }
  547. }
  548. }
  549. finally
  550. {
  551. IDisposable disposable;
  552. if ((disposable = (enumerator2 as IDisposable)) != null)
  553. {
  554. disposable.Dispose();
  555. }
  556. }
  557. this.morph.FixBlendValues();
  558. this.m_vDefPosLocal = (this.m_vPosLocal = this.obj_tr.localPosition);
  559. this.m_qDefRotLocal = (this.m_qRotLocal = this.obj_tr.localRotation);
  560. this.m_vDefScaleLocal = (this.m_vScaleRate = this.obj_tr.localScale);
  561. if (!f_bTemp && (this.SlotId == TBody.SlotID.accHat || this.SlotId == TBody.SlotID.headset || this.SlotId == TBody.SlotID.hairT || this.SlotId == TBody.SlotID.accSenaka || this.SlotId == TBody.SlotID.accKubi || this.SlotId == TBody.SlotID.accKubiwa || this.SlotId == TBody.SlotID.accShippo || this.SlotId == TBody.SlotID.accKubiwa))
  562. {
  563. SkinnedMeshRenderer componentInChildren = this.obj_tr.GetComponentInChildren<SkinnedMeshRenderer>(true);
  564. if (componentInChildren != null)
  565. {
  566. Bounds bounds = componentInChildren.bounds;
  567. GameObject gameObject2 = new GameObject("center");
  568. gameObject2.transform.SetParent(this.obj_tr, false);
  569. gameObject2.transform.position = bounds.center;
  570. GameObject gameObject3 = new GameObject("center2");
  571. gameObject3.transform.SetParent(gameObject2.transform, false);
  572. gameObject3.transform.position = bounds.center;
  573. this.m_vCenterPosLocal = gameObject2.transform.localPosition;
  574. this.center_tr = gameObject2.transform;
  575. this.center_tr2 = gameObject3.transform;
  576. BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
  577. if (tbodySkinPos != null)
  578. {
  579. this.m_vPosLocal = tbodySkinPos.pss.position;
  580. this.m_qRotLocal = tbodySkinPos.pss.rotation;
  581. this.m_vScaleRate = tbodySkinPos.pss.scale;
  582. this.m_bEnablePartPosEdit = tbodySkinPos.bEnable;
  583. if (this.m_bEnablePartPosEdit)
  584. {
  585. this.obj_tr.localPosition = tbodySkinPos.pss.position;
  586. this.obj_tr.localRotation = tbodySkinPos.pss.rotation;
  587. this.obj_tr.localScale = tbodySkinPos.pss.scale;
  588. }
  589. }
  590. else
  591. {
  592. this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
  593. }
  594. }
  595. }
  596. this.m_HairLengthCtrl.NotExistThenClearHairLength();
  597. if (OvrIK.IsModeVRIK && OvrIK.Instance != null && OvrIK.Instance.NowMaid == this.body.maid && (this.SlotId == TBody.SlotID.head || this.SlotId == TBody.SlotID.megane || this.SlotId == TBody.SlotID.accHead))
  598. {
  599. this.LayerCheck(this.obj);
  600. }
  601. }
  602. public void ItemScaleReset()
  603. {
  604. if (this.m_mp != null && this.m_mp.bNoScale)
  605. {
  606. Transform parent = this.obj_tr.parent;
  607. this.obj_tr.SetParent(null, true);
  608. this.obj_tr.localScale = Vector3.one;
  609. this.obj_tr.SetParent(parent, true);
  610. }
  611. }
  612. private void LayerCheck(GameObject goParent)
  613. {
  614. for (int i = 0; i < goParent.transform.childCount; i++)
  615. {
  616. this.LayerCheck(goParent.transform.GetChild(i).gameObject);
  617. }
  618. goParent.layer = LayerMask.NameToLayer("Face");
  619. }
  620. public void SetVisibleFlag(bool boSetFlag, string name, Transform t = null, bool boTgt = false)
  621. {
  622. if (t.name.IndexOf(name) >= 0)
  623. {
  624. boTgt = true;
  625. }
  626. if (name == "_ALL_")
  627. {
  628. boTgt = true;
  629. }
  630. if (boTgt)
  631. {
  632. this.m_dicDelNodeBody[t.name] = boSetFlag;
  633. }
  634. IEnumerator enumerator = t.GetEnumerator();
  635. try
  636. {
  637. while (enumerator.MoveNext())
  638. {
  639. object obj = enumerator.Current;
  640. Transform t2 = (Transform)obj;
  641. this.SetVisibleFlag(boSetFlag, name, t2, boTgt);
  642. }
  643. }
  644. finally
  645. {
  646. IDisposable disposable;
  647. if ((disposable = (enumerator as IDisposable)) != null)
  648. {
  649. disposable.Dispose();
  650. }
  651. }
  652. }
  653. public void SetVisibleFlagParts(bool f_bSetFlag, string f_strTargetSlot, string f_strBoneName, Transform t = null, bool boTgt = false)
  654. {
  655. if (t.name.IndexOf(f_strBoneName) >= 0)
  656. {
  657. boTgt = true;
  658. }
  659. if (f_strBoneName == "_ALL_")
  660. {
  661. boTgt = true;
  662. }
  663. if (boTgt)
  664. {
  665. Dictionary<string, bool> dictionary;
  666. if (!this.m_dicDelNodeParts.TryGetValue(f_strTargetSlot, out dictionary))
  667. {
  668. dictionary = new Dictionary<string, bool>();
  669. this.m_dicDelNodeParts.Add(f_strTargetSlot, dictionary);
  670. }
  671. dictionary[t.name] = f_bSetFlag;
  672. }
  673. IEnumerator enumerator = t.GetEnumerator();
  674. try
  675. {
  676. while (enumerator.MoveNext())
  677. {
  678. object obj = enumerator.Current;
  679. Transform t2 = (Transform)obj;
  680. this.SetVisibleFlagParts(f_bSetFlag, f_strTargetSlot, f_strBoneName, t2, boTgt);
  681. }
  682. }
  683. finally
  684. {
  685. IDisposable disposable;
  686. if ((disposable = (enumerator as IDisposable)) != null)
  687. {
  688. disposable.Dispose();
  689. }
  690. }
  691. }
  692. public void CopyTrans()
  693. {
  694. for (int i = 0; i < this.listTrs.Count; i += 2)
  695. {
  696. this.listTrs[i].localRotation = this.listTrs[i + 1].localRotation;
  697. this.listTrs[i].localPosition = this.listTrs[i + 1].localPosition;
  698. }
  699. for (int j = 0; j < this.listTrsScr.Count; j += 2)
  700. {
  701. this.listTrsScr[j].localScale = this.listTrsScr[j + 1].localScale;
  702. }
  703. this.TightSkirt();
  704. }
  705. public void TightSkirt()
  706. {
  707. }
  708. private void LookAtAxis(Transform f_trSrc, Vector3 f_vTargetPosWorld, TBodySkin.Axis f_axis, Vector3 f_vForwardWorld)
  709. {
  710. Vector3 position = f_trSrc.InverseTransformPoint(f_vTargetPosWorld);
  711. if (f_axis == TBodySkin.Axis.X)
  712. {
  713. position.x = 0f;
  714. }
  715. else if (f_axis == TBodySkin.Axis.Y)
  716. {
  717. position.y = 0f;
  718. }
  719. else
  720. {
  721. position.z = 0f;
  722. }
  723. Vector3 vector = f_trSrc.TransformPoint(position);
  724. Debug.DrawLine(vector, f_trSrc.position, Color.cyan);
  725. Quaternion lhs = Quaternion.FromToRotation(f_vForwardWorld, (vector - f_trSrc.position).normalized);
  726. f_trSrc.rotation = lhs * f_trSrc.rotation;
  727. }
  728. public void OnChangeScreenSizeOrAA()
  729. {
  730. bool flag = QualitySettings.antiAliasing != 0;
  731. if (this.obj == null)
  732. {
  733. return;
  734. }
  735. bool flag2 = !flag && !GameMain.Instance.MainCamera.IsBloomEnabled;
  736. if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
  737. {
  738. flag2 = false;
  739. }
  740. this.obj.GetComponentsInChildren<Renderer>(true, this.m_listRnederTemp);
  741. for (int i = 0; i < this.m_listRnederTemp.Count; i++)
  742. {
  743. Renderer renderer = this.m_listRnederTemp[i];
  744. if (!(renderer.material == null))
  745. {
  746. foreach (Material material in renderer.materials)
  747. {
  748. if (flag2)
  749. {
  750. material.EnableKeyword("UV_POS_REVERSE");
  751. material.DisableKeyword("UV_POS_NORMAL");
  752. }
  753. else
  754. {
  755. material.DisableKeyword("UV_POS_NORMAL");
  756. material.DisableKeyword("UV_POS_REVERSE");
  757. }
  758. }
  759. }
  760. }
  761. }
  762. private IEnumerator CoReFixBlendValues()
  763. {
  764. yield return null;
  765. this.morph.ResetBlendValues();
  766. yield break;
  767. }
  768. public void ManColorUpdate()
  769. {
  770. for (int i = 0; i < this.m_listManAlphaMat.Count; i++)
  771. {
  772. Material material = this.m_listManAlphaMat[i];
  773. material.SetFloat("_FloatValue2", (float)GameMain.Instance.CMSystem.ManAlpha / 100f);
  774. material.SetColor("_Color", this.body.maid.ManColor);
  775. }
  776. }
  777. public bool AnimationLoad(string f_strAnimName)
  778. {
  779. if (this.m_animItem == null)
  780. {
  781. this.m_animItem = this.obj.AddComponent<Animation>();
  782. }
  783. if (this.m_animItem.GetClip(f_strAnimName) == null)
  784. {
  785. string text = f_strAnimName;
  786. if (string.IsNullOrEmpty(Path.GetExtension(text)))
  787. {
  788. text += ".anm";
  789. }
  790. AnimationClip animationClip = ImportCM.LoadAniClipNative(GameUty.FileSystem, text, true, true, true);
  791. if (animationClip == null)
  792. {
  793. NDebug.Assert("アニメーション " + text + " が見つかりません。", false);
  794. return false;
  795. }
  796. this.m_animItem.Stop();
  797. this.m_animItem.AddClip(animationClip, f_strAnimName);
  798. this.m_animItem.clip = animationClip;
  799. this.m_animItem.playAutomatically = true;
  800. }
  801. this.m_animItem.Stop();
  802. return true;
  803. }
  804. public bool AnimationPlay(string f_strAnimName, bool f_bLoop)
  805. {
  806. if (this.m_animItem == null)
  807. {
  808. Debug.LogError("まだアイテムアニメが読まれていません。");
  809. return false;
  810. }
  811. this.m_animItem.Stop();
  812. this.m_animItem.wrapMode = ((!f_bLoop) ? WrapMode.Once : WrapMode.Loop);
  813. if (this.m_animItem.GetClip(f_strAnimName) == null)
  814. {
  815. NDebug.Assert("アニメーション " + f_strAnimName + " は設定されていません。", false);
  816. return false;
  817. }
  818. this.m_animItem[f_strAnimName].time = 0f;
  819. this.m_animItem.Play(f_strAnimName);
  820. return true;
  821. }
  822. public bool AnimationStop()
  823. {
  824. if (this.m_animItem == null)
  825. {
  826. return false;
  827. }
  828. this.m_animItem.Stop();
  829. return true;
  830. }
  831. public bool MaterialAnimatorAdd(int f_nMateNo)
  832. {
  833. Renderer componentInChildren = this.obj.GetComponentInChildren<Renderer>();
  834. if (componentInChildren != null)
  835. {
  836. MaterialAnimator materialAnimator = componentInChildren.gameObject.AddComponent<MaterialAnimator>();
  837. materialAnimator.m_nMateNo = f_nMateNo;
  838. materialAnimator.Init();
  839. }
  840. return true;
  841. }
  842. public void Update()
  843. {
  844. if (this.obj == null)
  845. {
  846. return;
  847. }
  848. if (this.obj.activeSelf != this.boVisible)
  849. {
  850. CMT.SetActiveFlag(this.obj_tr, this.boVisible);
  851. if (this.boVisible)
  852. {
  853. this.body.StartCoroutine(this.CoReFixBlendValues());
  854. }
  855. }
  856. if (!this.boVisible)
  857. {
  858. return;
  859. }
  860. if (this.trsBoneAttach != null)
  861. {
  862. this.obj_tr.position = this.trsBoneAttach.position;
  863. this.obj_tr.rotation = this.trsBoneAttach.rotation;
  864. }
  865. if (this.AttachName != null && this.body.goSlot[this.AttachSlotIdx].morph != null)
  866. {
  867. Vector3 position;
  868. Quaternion rotation;
  869. Vector3 vector;
  870. if (this.body.goSlot[this.AttachSlotIdx].morph.GetAttachPoint(this.AttachName, out position, out rotation, out vector, this.m_bTemp))
  871. {
  872. if (!this.AttachVisible)
  873. {
  874. this.obj_tr.localScale = Vector3.one;
  875. this.AttachVisible = true;
  876. }
  877. this.obj_tr.position = position;
  878. this.obj_tr.rotation = rotation;
  879. this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z);
  880. }
  881. else if (this.AttachVisible)
  882. {
  883. this.obj_tr.localScale = Vector3.zero;
  884. this.AttachVisible = false;
  885. }
  886. }
  887. if (this.kupaCtrl != null)
  888. {
  889. this.kupaCtrl.SelfUpdate();
  890. }
  891. Vector3 localScale = this.m_trMaid.localScale;
  892. Vector3 localScale2 = this.m_trMaidOffs.localScale;
  893. if (localScale.x < 0.998f || 1.002f < localScale.x || localScale2.x < 0.998f || 1.002f < localScale2.x)
  894. {
  895. this.m_trMaid.localScale = Vector3.one;
  896. this.m_trMaidOffs.localScale = Vector3.one;
  897. this.bonehair.Update();
  898. this.bonehair3.UpdateSelf();
  899. this.m_trMaid.localScale = localScale;
  900. this.m_trMaidOffs.localScale = localScale2;
  901. }
  902. else
  903. {
  904. this.bonehair.Update();
  905. this.bonehair3.UpdateSelf();
  906. }
  907. }
  908. public TBody body;
  909. public string Category;
  910. public TBody.SlotID SlotId;
  911. public bool boVisible = true;
  912. public List<int> listMaskSlot = new List<int>();
  913. public GameObject obj;
  914. public Transform obj_tr;
  915. public Transform center_tr;
  916. public Transform center_tr2;
  917. private List<Transform> listTrs;
  918. private List<Transform> listTrsScr;
  919. public List<UnityEngine.Object> listDEL = new List<UnityEngine.Object>();
  920. public Dictionary<string, UnityEngine.Object> dicDel = new Dictionary<string, UnityEngine.Object>();
  921. private List<Material> m_listRtMaterial = new List<Material>();
  922. public TMorph morph;
  923. public Dictionary<string, bool> m_dicDelNodeBody = new Dictionary<string, bool>();
  924. public Dictionary<string, Dictionary<string, bool>> m_dicDelNodeParts = new Dictionary<string, Dictionary<string, bool>>();
  925. public TBoneHair_ bonehair;
  926. public BoneHair2 bonehair2;
  927. public BoneHair3 bonehair3;
  928. public bool boMizugi;
  929. public Dictionary<string, KeyValuePair<float, string>[]> dicParamSet = new Dictionary<string, KeyValuePair<float, string>[]>();
  930. private Dictionary<string, string> m_dicParam = new Dictionary<string, string>();
  931. private Dictionary<string, string> m_dicParam2 = new Dictionary<string, string>();
  932. public Transform trsBoneAttach;
  933. public string AttachName;
  934. public bool AttachVisible;
  935. public int AttachSlotIdx;
  936. private Quaternion AttachRotation;
  937. public Vector3 m_vDefScaleLocal;
  938. public Vector3 m_vScaleRate;
  939. public Vector3 m_vTempAttachPointScale;
  940. public Vector3 m_vDefPosLocal;
  941. public Vector3 m_vPosLocal;
  942. public Vector3 m_vCenterPosLocal;
  943. public Vector3 m_vTempAttachPointPos;
  944. public Quaternion m_qDefRotLocal;
  945. public Quaternion m_qRotLocal;
  946. public Quaternion m_qTempAttachPointRot;
  947. public int RID;
  948. public int SyojiType;
  949. public string m_strModelFileName = string.Empty;
  950. public MPN m_ParentMPN;
  951. public MaidProp m_mp;
  952. private bool m_bMan;
  953. private List<Material> m_listManAlphaMat = new List<Material>();
  954. public InfinityColorTextureCache TextureCache;
  955. private bool m_bEnablePartPosEdit;
  956. public Dictionary<string, float> m_BonehairBodyhitScaleBackup = new Dictionary<string, float>();
  957. public Dictionary<string, TMorph.TempAttachPos> m_dicTempAttachPoint = new Dictionary<string, TMorph.TempAttachPos>();
  958. public bool m_bHitFloorY = true;
  959. private Transform m_trMaid;
  960. private Transform m_trMaidOffs;
  961. private Dictionary<int, Shader> m_dicBackupShader = new Dictionary<int, Shader>();
  962. private bool m_bTemp;
  963. private Transform m_trThigh_L;
  964. private Transform m_trThigh_R;
  965. private Transform m_trCalf_L;
  966. private Transform m_trCalf_R;
  967. private Transform m_trFoot_L;
  968. private Transform m_trFoot_R;
  969. public TBodySkin.OriVert m_OriVert = new TBodySkin.OriVert();
  970. public TBodySkin.HairLengthCtrl m_HairLengthCtrl;
  971. private Animation m_animItem;
  972. private int m_partsVersion;
  973. private List<Renderer> m_listRnederTemp = new List<Renderer>(4);
  974. public class HairLengthCtrl
  975. {
  976. public HairLengthCtrl(TBodySkin f_trTbodySkin)
  977. {
  978. this.m_tbskin = f_trTbodySkin;
  979. this.m_maid = this.m_tbskin.body.maid;
  980. }
  981. public bool IsHairLengthEditable
  982. {
  983. get
  984. {
  985. return this.m_dicHairLenght != null && this.m_dicHairLenght.Count != 0;
  986. }
  987. }
  988. public Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> HairLengthGroupList
  989. {
  990. get
  991. {
  992. return this.m_dicHairLenght;
  993. }
  994. }
  995. public void NotExistThenClearHairLength()
  996. {
  997. if (this.m_maid.NotExistThenClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId))
  998. {
  999. }
  1000. this.m_dicHairLenght.Clear();
  1001. }
  1002. public void SearchAndAddHairLengthTarget(string f_strGroupName, string f_strBoneSearchType, string f_strBoneName, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
  1003. {
  1004. if (this.m_tbskin == null || this.m_tbskin.obj_tr == null)
  1005. {
  1006. NDebug.Assert("髪ボーン拡縮検索 親が未だありません。", false);
  1007. }
  1008. string pattern = f_strBoneName.Replace("*", ".*");
  1009. TBodySkin.HairLengthCtrl.SerchMode mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
  1010. if (f_strBoneSearchType == "fbrother")
  1011. {
  1012. mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER;
  1013. }
  1014. else if (f_strBoneSearchType == "fchild")
  1015. {
  1016. mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD;
  1017. }
  1018. else if (f_strBoneSearchType == "all")
  1019. {
  1020. mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
  1021. }
  1022. else
  1023. {
  1024. NDebug.Assert("髪ボーン検索タイプが不正です。 " + f_strBoneSearchType, false);
  1025. }
  1026. this.SearchObjAndAdd(f_strGroupName, this.m_tbskin.obj_tr, new Regex(pattern), mode, f_vScaleMin, f_vScaleMax);
  1027. TBodySkin.HairLengthCtrl.HairLength hairLength;
  1028. if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
  1029. {
  1030. Debug.LogError("髪ボーングループがありません。");
  1031. return;
  1032. }
  1033. float lengthRate = 0.5f;
  1034. if (this.m_maid.GetHairLengthFromMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId, f_strGroupName, out lengthRate))
  1035. {
  1036. hairLength.SetLengthRate(lengthRate);
  1037. }
  1038. else
  1039. {
  1040. this.m_maid.ClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId);
  1041. }
  1042. this.HairLenghtBlend();
  1043. }
  1044. private Transform SearchObjAndAdd(string f_strGroupName, Transform t, Regex regex, TBodySkin.HairLengthCtrl.SerchMode mode, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
  1045. {
  1046. string name = t.name;
  1047. if (regex.IsMatch(name))
  1048. {
  1049. TBodySkin.HairLengthCtrl.HairLength hairLength;
  1050. if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
  1051. {
  1052. hairLength = new TBodySkin.HairLengthCtrl.HairLength(this.m_tbskin, f_strGroupName);
  1053. this.m_dicHairLenght[f_strGroupName] = hairLength;
  1054. }
  1055. hairLength.listTarget.Add(new TBodySkin.HairLengthCtrl.HairLengthTarget
  1056. {
  1057. trTarget = t,
  1058. vScaleDef = t.localScale,
  1059. vScaleMin = f_vScaleMin,
  1060. vScaleMax = f_vScaleMax
  1061. });
  1062. if (mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER || mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
  1063. {
  1064. return t;
  1065. }
  1066. }
  1067. for (int i = 0; i < t.childCount; i++)
  1068. {
  1069. Transform child = t.GetChild(i);
  1070. Transform transform = this.SearchObjAndAdd(f_strGroupName, child, regex, mode, f_vScaleMin, f_vScaleMax);
  1071. if (transform != null && mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
  1072. {
  1073. return transform;
  1074. }
  1075. }
  1076. return null;
  1077. }
  1078. public void HairLenghtBlend()
  1079. {
  1080. foreach (KeyValuePair<string, TBodySkin.HairLengthCtrl.HairLength> keyValuePair in this.m_dicHairLenght)
  1081. {
  1082. float lengthRate = keyValuePair.Value.GetLengthRate();
  1083. for (int i = 0; i < keyValuePair.Value.listTarget.Count; i++)
  1084. {
  1085. TBodySkin.HairLengthCtrl.HairLengthTarget hairLengthTarget = keyValuePair.Value.listTarget[i];
  1086. Vector3 localScale = hairLengthTarget.vScaleDef;
  1087. if (lengthRate < 0.5f)
  1088. {
  1089. localScale = Vector3.Lerp(hairLengthTarget.vScaleMin, hairLengthTarget.vScaleDef, lengthRate / 0.5f);
  1090. }
  1091. else if (0.5f < lengthRate)
  1092. {
  1093. localScale = Vector3.Lerp(hairLengthTarget.vScaleDef, hairLengthTarget.vScaleMax, (lengthRate - 0.5f) / 0.5f);
  1094. }
  1095. hairLengthTarget.trTarget.localScale = localScale;
  1096. }
  1097. }
  1098. }
  1099. private Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> m_dicHairLenght = new Dictionary<string, TBodySkin.HairLengthCtrl.HairLength>();
  1100. private TBodySkin m_tbskin;
  1101. private Maid m_maid;
  1102. public class HairLengthTarget
  1103. {
  1104. public Transform trTarget;
  1105. public Vector3 vScaleDef;
  1106. public Vector3 vScaleMin;
  1107. public Vector3 vScaleMax;
  1108. }
  1109. public class HairLength
  1110. {
  1111. public HairLength(TBodySkin f_tbskin, string f_strGroupName)
  1112. {
  1113. this.m_tbskin = f_tbskin;
  1114. this.strGroupName = f_strGroupName;
  1115. }
  1116. public float GetLengthRate()
  1117. {
  1118. return this.fLenghtRate;
  1119. }
  1120. public void SetLengthRate(float f_fRate)
  1121. {
  1122. Maid maid = this.m_tbskin.body.maid;
  1123. MPN parentMPN = this.m_tbskin.m_ParentMPN;
  1124. TBody.SlotID slotId = this.m_tbskin.SlotId;
  1125. string f_strName = this.strGroupName;
  1126. this.fLenghtRate = f_fRate;
  1127. maid.SetHairLengthSaveToMP(parentMPN, slotId, f_strName, f_fRate);
  1128. }
  1129. private TBodySkin m_tbskin;
  1130. private string strGroupName;
  1131. private float fLenghtRate = 0.5f;
  1132. public List<TBodySkin.HairLengthCtrl.HairLengthTarget> listTarget = new List<TBodySkin.HairLengthCtrl.HairLengthTarget>();
  1133. }
  1134. private enum SerchMode
  1135. {
  1136. FIRST_CHILD,
  1137. FIRST_BROTHER,
  1138. ALL
  1139. }
  1140. }
  1141. public class OriVert
  1142. {
  1143. public void Clear()
  1144. {
  1145. this.VCount = 0;
  1146. this.vOriVert = null;
  1147. this.vOriNorm = null;
  1148. this.nSubMeshCount = 0;
  1149. this.nSubMeshOriTri = null;
  1150. this.bwWeight = null;
  1151. }
  1152. public int VCount;
  1153. public Vector3[] vOriVert;
  1154. public Vector3[] vOriNorm;
  1155. public int nSubMeshCount;
  1156. public int[][] nSubMeshOriTri;
  1157. public BoneWeight[] bwWeight;
  1158. }
  1159. private enum Axis
  1160. {
  1161. X,
  1162. Y,
  1163. Z
  1164. }
  1165. }