TBodySkin.cs 37 KB

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