TBodySkin.cs 35 KB

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