TBodySkin.cs 36 KB

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