TMorphSkin.cs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using UnityEngine;
  6. public class TMorphSkin : TMorph
  7. {
  8. public TMorphSkin(TBodySkin bs, bool man)
  9. {
  10. this.bodyskin = bs;
  11. this.m_isMan = man;
  12. this.Category = bs.Category;
  13. this.SlotId = bs.SlotId;
  14. this.hash = new Hashtable();
  15. this.MorphCount = 0;
  16. this.BlendDatas = new List<BlendData>(20);
  17. this.BoneNames = new List<string>(200);
  18. this.BoneVisible = new List<bool>(200);
  19. }
  20. ~TMorphSkin()
  21. {
  22. this.DeleteObj();
  23. }
  24. public override BlendData this[string tag]
  25. {
  26. get
  27. {
  28. int index = (int)this.hash[tag];
  29. return this.BlendDatas[index];
  30. }
  31. }
  32. public override bool Contains(string name)
  33. {
  34. return this.hash.ContainsKey(name);
  35. }
  36. public override float GetBlendValues(int f_nIdx)
  37. {
  38. return this.BlendValues[f_nIdx];
  39. }
  40. public override void SetBlendValues(int f_nIdx, float f_fValue)
  41. {
  42. float[] blendValuesBackup = this.BlendValuesBackup;
  43. this.BlendValues[f_nIdx] = f_fValue;
  44. blendValuesBackup[f_nIdx] = f_fValue;
  45. }
  46. public override void DeleteObj()
  47. {
  48. foreach (KeyValuePair<string, TAttachPoint> keyValuePair in this.dicAttachPoint)
  49. {
  50. if (keyValuePair.Value.newAttachChild != null)
  51. {
  52. keyValuePair.Value.newAttachChild.ResetAttachPoint();
  53. }
  54. }
  55. this.m_baseBlendValues = null;
  56. this.m_chikubiTotsuMorphsIdx = null;
  57. this.bodyskin = null;
  58. this.m_mesh = null;
  59. this.smr_src = null;
  60. this.m_bones = null;
  61. this.m_vOriVert = null;
  62. this.m_vOriNorm = null;
  63. this.m_vOriTan = null;
  64. this.m_nSubMeshOriTri = null;
  65. this.m_bws = null;
  66. }
  67. public unsafe override void InitGameObject(GameObject o)
  68. {
  69. this.m_OriVert = this.bodyskin.m_OriVert;
  70. SkinnedMeshRenderer skinnedMeshRenderer = null;
  71. List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(3);
  72. o.GetComponentsInChildren<SkinnedMeshRenderer>(true, list);
  73. for (int i = 0; i < list.Count; i++)
  74. {
  75. skinnedMeshRenderer = list[i];
  76. }
  77. Transform[] bones = skinnedMeshRenderer.bones;
  78. Transform transform = o.transform;
  79. this.tRoot = transform;
  80. if (skinnedMeshRenderer == null)
  81. {
  82. Debug.LogError("err init morph " + o.name);
  83. this.initlp(this.tRoot);
  84. return;
  85. }
  86. this.smr_src = skinnedMeshRenderer;
  87. this.m_bones = bones;
  88. this.m_mesh = this.smr_src.sharedMesh;
  89. this.VCount = this.m_OriVert.VCount;
  90. this.m_vOriVert = this.m_OriVert.vOriVert;
  91. this.m_vOriNorm = this.m_OriVert.vOriNorm;
  92. this.m_vTmpVert = new Vector3[this.VCount];
  93. this.m_vTmpNorm = new Vector3[this.VCount];
  94. if (this.m_vOriTan != null)
  95. {
  96. this.m_vTmpTan = new Vector4[this.VCount];
  97. }
  98. this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
  99. this.m_vOriNorm.CopyTo(this.m_vTmpNorm, 0);
  100. if (this.m_vOriTan != null)
  101. {
  102. this.m_vOriTan.CopyTo(this.m_vTmpTan, 0);
  103. }
  104. this.m_nSubMeshCount = this.m_OriVert.nSubMeshCount;
  105. this.m_nSubMeshOriTri = this.m_OriVert.nSubMeshOriTri;
  106. this.m_nSubMeshTmpTri = new int[this.m_nSubMeshCount][];
  107. for (int j = 0; j < this.m_nSubMeshCount; j++)
  108. {
  109. int[] array = this.m_nSubMeshOriTri[j];
  110. this.m_nSubMeshTmpTri[j] = new int[array.Length];
  111. }
  112. this.BoneCount = this.m_bones.Length;
  113. this.initlp(this.tRoot);
  114. this.m_EarNoneData.rate = false;
  115. this.m_EarNoneData.idx = ((!this.hash.ContainsKey("earnone")) ? -1 : ((int)this.hash["earnone"]));
  116. this.m_EarElfData.rate = 0f;
  117. this.m_EarElfData.idx = ((!this.hash.ContainsKey("earelf")) ? -1 : ((int)this.hash["earelf"]));
  118. this.m_FaceShapeData.rate = 0f;
  119. this.m_FaceShapeData.idx = ((!this.hash.ContainsKey("shape")) ? -1 : ((int)this.hash["shape"]));
  120. this.m_FaceShapeSlimData.rate = 0f;
  121. this.m_FaceShapeSlimData.idx = ((!this.hash.ContainsKey("shapeslim")) ? -1 : ((int)this.hash["shapeslim"]));
  122. this.m_MayuShapeIn.rate = (this.m_MayuShapeOut.rate = 0f);
  123. this.m_MayuShapeIn.idx = ((!this.hash.ContainsKey("mayueditin")) ? -1 : ((int)this.hash["mayueditin"]));
  124. this.m_MayuShapeOut.idx = ((!this.hash.ContainsKey("mayueditout")) ? -1 : ((int)this.hash["mayueditout"]));
  125. if (this.bodyskin.SlotId == TBody.SlotID.head && 120 <= this.bodyskin.PartsVersion)
  126. {
  127. Action<string, TMorph.IdxMinMaxRatePair> action = delegate(string no, TMorph.IdxMinMaxRatePair idx)
  128. {
  129. bool flag = false;
  130. flag |= ((idx.idxDwL = ((!this.hash.ContainsKey("eyeeditl" + no + "_dw")) ? -1 : ((int)this.hash["eyeeditl" + no + "_dw"]))) == -1);
  131. flag |= ((idx.idxUpL = ((!this.hash.ContainsKey("eyeeditl" + no + "_up")) ? -1 : ((int)this.hash["eyeeditl" + no + "_up"]))) == -1);
  132. flag |= ((idx.idxDwR = ((!this.hash.ContainsKey("eyeeditr" + no + "_dw")) ? -1 : ((int)this.hash["eyeeditr" + no + "_dw"]))) == -1);
  133. flag |= ((idx.idxUpR = ((!this.hash.ContainsKey("eyeeditr" + no + "_up")) ? -1 : ((int)this.hash["eyeeditr" + no + "_up"]))) == -1);
  134. if (flag)
  135. {
  136. return;
  137. }
  138. idx.exec = delegate(float rateL, float rateR)
  139. {
  140. float num6 = Mathf.Clamp01((idx.rate - 0.5f) / -0.5f);
  141. float num7 = Mathf.Clamp01((idx.rate - 0.5f) / 0.5f);
  142. this.BlendValues[idx.idxDwL] = num6 * rateL;
  143. this.BlendValues[idx.idxDwR] = num6 * rateR;
  144. this.BlendValues[idx.idxUpL] = num7 * rateL;
  145. this.BlendValues[idx.idxUpR] = num7 * rateR;
  146. };
  147. if (this.m_IdxMinMaxList == null)
  148. {
  149. this.m_IdxMinMaxList = new List<TMorph.IdxMinMaxRatePair>();
  150. }
  151. this.m_IdxMinMaxList.Add(idx);
  152. };
  153. action("1", this.m_MabutaUpIn);
  154. action("2", this.m_MabutaUpIn2);
  155. action("3", this.m_MabutaUpMiddle);
  156. action("4", this.m_MabutaUpOut);
  157. action("5", this.m_MabutaUpOut2);
  158. action("6", this.m_MabutaLowUpOut);
  159. action("7", this.m_MabutaLowUpMiddle);
  160. action("8", this.m_MabutaLowIn);
  161. this.SetIdx<float>("irisedit1", out this.m_HitomiShapeUp, 0f);
  162. this.SetIdx<float>("irisedit2", out this.m_HitomiShapeLow, 0f);
  163. this.SetIdx<float>("irisedit3", out this.m_HitomiShapeIn, 0f);
  164. this.SetIdx<float>("irisedit4", out this.m_HitomiShapeOutUp, 0f);
  165. this.SetIdx<float>("irisedit5", out this.m_HitomiShapeOutLow, 0f);
  166. this.SetIdx<float>("shapehoho", out this.m_HohoShape, 0f);
  167. this.SetIdx<float>("ha1", out this.m_Ha1, 0f);
  168. this.SetIdx<float>("ha2", out this.m_Ha2, 0f);
  169. this.SetIdx<float>("ha3", out this.m_Ha3, 0f);
  170. this.SetIdx<float>("ha4", out this.m_Ha4, 0f);
  171. this.SetIdx<float>("ha5", out this.m_Ha5, 0f);
  172. this.SetIdx<float>("ha6", out this.m_Ha6, 0f);
  173. }
  174. this.m_fEyeCloseRate = 0f;
  175. this.BlendDataIdx_EyeClose = new int[][]
  176. {
  177. new int[10],
  178. new int[10],
  179. new int[10]
  180. };
  181. if (this.bodyskin.PartsVersion < 120)
  182. {
  183. if (this.hash.ContainsKey("eyeclose"))
  184. {
  185. this.BlendDataIdx_EyeClose[0][0] = (int)this.hash["eyeclose"];
  186. }
  187. for (int k = 1; k < 10; k++)
  188. {
  189. if (this.hash.ContainsKey("eyeclose" + k.ToString()))
  190. {
  191. this.BlendDataIdx_EyeClose[0][k] = (int)this.hash["eyeclose" + k.ToString()];
  192. }
  193. }
  194. if (!this.bodyskin.body.boMAN && this.Category == "head" && this.BlendDataIdx_EyeClose[0][0] == 0)
  195. {
  196. Debug.LogError("Face[eyeclose]");
  197. }
  198. }
  199. else if (this.m_isMan)
  200. {
  201. if (this.hash.ContainsKey("eyeclose"))
  202. {
  203. this.BlendDataIdx_EyeClose[0][0] = (int)this.hash["eyeclose"];
  204. }
  205. for (int l = 1; l < 10; l++)
  206. {
  207. if (this.hash.ContainsKey("eyeclose" + l.ToString()))
  208. {
  209. this.BlendDataIdx_EyeClose[0][l] = (int)this.hash["eyeclose" + l.ToString()];
  210. }
  211. }
  212. }
  213. else
  214. {
  215. for (int m = 0; m < 3; m++)
  216. {
  217. for (int n = 0; n < 10; n++)
  218. {
  219. if (this.hash.ContainsKey("eyeclose" + (n + 1).ToString() + TMorph.crcFaceTypesStr[m]))
  220. {
  221. this.BlendDataIdx_EyeClose[m][n] = (int)this.hash["eyeclose" + (n + 1).ToString() + TMorph.crcFaceTypesStr[m]];
  222. }
  223. }
  224. }
  225. }
  226. if (this.hash.ContainsKey("toothoff"))
  227. {
  228. this.BlendDataIdx_LipSyncTh = (int)this.hash["toothoff"];
  229. }
  230. if (this.hash.ContainsKey("moutha"))
  231. {
  232. this.BlendDataIdx_LipSync_A = (int)this.hash["moutha"];
  233. }
  234. if (this.hash.ContainsKey("mouths"))
  235. {
  236. this.BlendDataIdx_LipSync_S = (int)this.hash["mouths"];
  237. }
  238. if (this.hash.ContainsKey("mouthc"))
  239. {
  240. this.BlendDataIdx_LipSync_C = (int)this.hash["mouthc"];
  241. }
  242. if (this.hash.ContainsKey("toothoff"))
  243. {
  244. this.BlendDataIdx_LipSync_ToothOFF = (int)this.hash["toothoff"];
  245. }
  246. if (this.hash.ContainsKey("mouthdw"))
  247. {
  248. this.BlendDataIdx_LipSync_W = (int)this.hash["mouthdw"];
  249. }
  250. if (this.hash.ContainsKey("tear1"))
  251. {
  252. this.BlendDataIdx_Tear1 = (int)this.hash["tear1"];
  253. }
  254. if (this.hash.ContainsKey("tear2"))
  255. {
  256. this.BlendDataIdx_Tear2 = (int)this.hash["tear2"];
  257. }
  258. if (this.hash.ContainsKey("tear3"))
  259. {
  260. this.BlendDataIdx_Tear3 = (int)this.hash["tear3"];
  261. }
  262. if (this.hash.ContainsKey("nosefook"))
  263. {
  264. this.BlendDataIdx_NoseFook = (int)this.hash["nosefook"];
  265. }
  266. if (this.hash.ContainsKey("eyeclose"))
  267. {
  268. int count = this.BlendDatas.Count;
  269. this.hash["uru-uru"] = count;
  270. this.BlendDatas.Add(null);
  271. this.MorphCount++;
  272. }
  273. if (this.hash.ContainsKey("regfat"))
  274. {
  275. this.BlendDataIdx_RegFat = (int)this.hash["regfat"];
  276. }
  277. if (this.hash.ContainsKey("regmeet"))
  278. {
  279. this.BlendDataIdx_RegMeet = (int)this.hash["regmeet"];
  280. }
  281. if (this.hash.ContainsKey("hipsize"))
  282. {
  283. this.BlendDataIdx_HipSize = (int)this.hash["hipsize"];
  284. }
  285. foreach (string key in this.m_kuikomiMorphs)
  286. {
  287. if (this.hash.ContainsKey(key))
  288. {
  289. if (this.m_baseBlendValues == null)
  290. {
  291. this.m_baseBlendValues = new Dictionary<int, List<TMorphSkin.BaseBlendValue>>();
  292. }
  293. this.m_baseBlendValues.Add((int)this.hash[key], new List<TMorphSkin.BaseBlendValue>());
  294. }
  295. }
  296. foreach (string key2 in this.m_chikubiTotsuMorphs)
  297. {
  298. if (this.hash.ContainsKey(key2))
  299. {
  300. if (this.m_chikubiTotsuMorphsIdx == null)
  301. {
  302. this.m_chikubiTotsuMorphsIdx = new HashSet<int>();
  303. }
  304. this.m_chikubiTotsuMorphsIdx.Add((int)this.hash[key2]);
  305. }
  306. }
  307. this.ScrnV = new Vector3[this.VCount];
  308. this.WorldV = new Vector3[this.VCount];
  309. this.BindVert = new Vector3[this.VCount];
  310. this.DefVert = new Vector3[this.VCount];
  311. this.BindBone = new int[this.VCount];
  312. this.m_bindposes = this.m_mesh.bindposes;
  313. this.m_bws = this.m_OriVert.bwWeight;
  314. fixed (BoneWeight* ptr = &this.m_bws[0])
  315. {
  316. BoneWeight* ptr2 = ptr;
  317. for (int num3 = 0; num3 < this.VCount; num3++)
  318. {
  319. int num4 = ptr2->boneIndex0;
  320. float num5 = ptr2->weight0;
  321. if (ptr2->weight1 > num5)
  322. {
  323. num5 = ptr2->weight1;
  324. num4 = ptr2->boneIndex1;
  325. }
  326. if (ptr2->weight2 > num5)
  327. {
  328. num5 = ptr2->weight2;
  329. num4 = ptr2->boneIndex2;
  330. }
  331. if (ptr2->weight3 > num5)
  332. {
  333. num5 = ptr2->weight3;
  334. num4 = ptr2->boneIndex3;
  335. }
  336. this.BindBone[num3] = num4;
  337. Vector3 vector = this.m_bindposes[num4].MultiplyPoint3x4(this.m_vOriVert[num3]);
  338. this.BindVert[num3] = vector;
  339. this.DefVert[num3] = this.m_bones[num4].TransformPoint(vector);
  340. ptr2++;
  341. }
  342. }
  343. }
  344. private void SetIdx<T>(string name, out TMorph.IdxRatePair<T> idx, T initVal) where T : struct
  345. {
  346. idx.rate = initVal;
  347. idx.idx = ((!this.hash.ContainsKey(name)) ? -1 : ((int)this.hash[name]));
  348. }
  349. private void initlp(Transform t)
  350. {
  351. for (int i = 0; i < this.BoneCount; i++)
  352. {
  353. if (this.m_bones[i] != null)
  354. {
  355. this.BoneNames.Add(this.m_bones[i].name);
  356. this.BoneVisible.Add(true);
  357. }
  358. else
  359. {
  360. this.BoneNames.Add(string.Empty);
  361. this.BoneVisible.Add(false);
  362. }
  363. }
  364. this.m_bDut = false;
  365. }
  366. public override void ClearAllVisibleFlag(bool boSetFlag)
  367. {
  368. for (int i = 0; i < this.BoneCount; i++)
  369. {
  370. if (this.BoneVisible[i] != boSetFlag)
  371. {
  372. this.BoneVisible[i] = boSetFlag;
  373. this.m_bDut = true;
  374. }
  375. }
  376. }
  377. public override void SetVisibleFlag1(int idx, bool flag)
  378. {
  379. if (this.BoneVisible[idx] != flag)
  380. {
  381. this.BoneVisible[idx] = flag;
  382. this.m_bDut = true;
  383. }
  384. }
  385. public void VisibleVtxByPlane(Vector3Int plane, float pos)
  386. {
  387. if (this.smr_src == null)
  388. {
  389. return;
  390. }
  391. if (this.m_mesh == null)
  392. {
  393. return;
  394. }
  395. for (int i = 0; i < this.m_nSubMeshCount; i++)
  396. {
  397. this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
  398. int[] array = this.m_nSubMeshTmpTri[i];
  399. for (int j = 0; j < array.Length / 3; j++)
  400. {
  401. int num = 3;
  402. for (int k = 0; k < 3; k++)
  403. {
  404. int num2 = array[j * 3 + k];
  405. if (plane.x != 0)
  406. {
  407. if (plane.x < 0)
  408. {
  409. if (pos <= this.m_vOriVert[num2].x)
  410. {
  411. num--;
  412. }
  413. }
  414. else if (this.m_vOriVert[num2].x < pos)
  415. {
  416. num--;
  417. }
  418. }
  419. else if (plane.y != 0)
  420. {
  421. if (plane.y < 0)
  422. {
  423. if (pos <= this.m_vOriVert[num2].y)
  424. {
  425. num--;
  426. }
  427. }
  428. else if (this.m_vOriVert[num2].y < pos)
  429. {
  430. num--;
  431. }
  432. }
  433. else if (plane.z != 0)
  434. {
  435. if (plane.z < 0)
  436. {
  437. if (pos <= this.m_vOriVert[num2].z)
  438. {
  439. num--;
  440. }
  441. }
  442. else if (this.m_vOriVert[num2].z < pos)
  443. {
  444. num--;
  445. }
  446. }
  447. }
  448. if (num != 3)
  449. {
  450. for (int l = 0; l < 3; l++)
  451. {
  452. array[j * 3 + l] = 0;
  453. }
  454. }
  455. }
  456. this.m_nSubMeshTmpTri[i].CopyTo(this.m_nSubMeshOriTri[i], 0);
  457. this.m_mesh.SetTriangles(array, i);
  458. }
  459. }
  460. public void VisibleVtxByBonwWeight(List<int> boneVisibleIdxs)
  461. {
  462. if (this.smr_src == null)
  463. {
  464. return;
  465. }
  466. if (this.m_mesh == null)
  467. {
  468. return;
  469. }
  470. int[] array = new int[4];
  471. for (int i = 0; i < this.m_nSubMeshCount; i++)
  472. {
  473. this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
  474. int[] array2 = this.m_nSubMeshTmpTri[i];
  475. for (int j = 0; j < array2.Length / 3; j++)
  476. {
  477. int num = 3;
  478. for (int k = 0; k < 3; k++)
  479. {
  480. int num2 = array2[j * 3 + k];
  481. BoneWeight boneWeight = this.m_bws[num2];
  482. array[0] = ((boneWeight.weight0 <= 0f) ? -1 : boneWeight.boneIndex0);
  483. array[1] = ((boneWeight.weight1 <= 0f) ? -1 : boneWeight.boneIndex1);
  484. array[2] = ((boneWeight.weight2 <= 0f) ? -1 : boneWeight.boneIndex2);
  485. array[3] = ((boneWeight.weight3 <= 0f) ? -1 : boneWeight.boneIndex3);
  486. if (Array.FindIndex<int>(array, (int bi) => boneVisibleIdxs.FindIndex((int fi) => fi == bi) != -1) == -1)
  487. {
  488. num--;
  489. }
  490. }
  491. if (num != 3)
  492. {
  493. for (int l = 0; l < 3; l++)
  494. {
  495. array2[j * 3 + l] = 0;
  496. }
  497. }
  498. }
  499. this.m_nSubMeshTmpTri[i].CopyTo(this.m_nSubMeshOriTri[i], 0);
  500. this.m_mesh.SetTriangles(array2, i);
  501. }
  502. }
  503. public override void FixVisibleFlag()
  504. {
  505. if (this.smr_src == null)
  506. {
  507. return;
  508. }
  509. if (this.m_mesh == null)
  510. {
  511. return;
  512. }
  513. MaterialMgr materialMgr = this.bodyskin.MaterialMgr;
  514. this.m_bDut |= materialMgr.FixSkinMask();
  515. if (!this.m_bDut)
  516. {
  517. return;
  518. }
  519. Vector2[] vOriUV = this.m_OriVert.vOriUV;
  520. bool flag = vOriUV != null && this.SlotId == TBody.SlotID.body;
  521. for (int i = 0; i < this.m_nSubMeshCount; i++)
  522. {
  523. this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
  524. int[] array = this.m_nSubMeshTmpTri[i];
  525. for (int j = 0; j < array.Length / 3; j++)
  526. {
  527. int num = 3;
  528. for (int k = 0; k < 3; k++)
  529. {
  530. int num2 = array[j * 3 + k];
  531. if (flag && materialMgr.CheckSkinMaskUV(vOriUV[num2]))
  532. {
  533. num--;
  534. }
  535. else
  536. {
  537. BoneWeight boneWeight = this.m_bws[num2];
  538. if (!this.BoneVisible[boneWeight.boneIndex0])
  539. {
  540. num--;
  541. break;
  542. }
  543. if (!this.BoneVisible[boneWeight.boneIndex1] && boneWeight.weight1 > 0f)
  544. {
  545. num--;
  546. break;
  547. }
  548. if (!this.BoneVisible[boneWeight.boneIndex2] && boneWeight.weight2 > 0f)
  549. {
  550. num--;
  551. break;
  552. }
  553. if (!this.BoneVisible[boneWeight.boneIndex3] && boneWeight.weight3 > 0f)
  554. {
  555. num--;
  556. break;
  557. }
  558. }
  559. }
  560. if (num != 3)
  561. {
  562. for (int l = 0; l < 3; l++)
  563. {
  564. array[j * 3 + l] = 0;
  565. }
  566. }
  567. }
  568. this.m_mesh.SetTriangles(array, i);
  569. }
  570. this.m_bDut = false;
  571. }
  572. public override void LoadMoprhData2(BinaryReader r, int ver)
  573. {
  574. string text = r.ReadString();
  575. int count = this.BlendDatas.Count;
  576. this.hash[text] = count;
  577. BlendData blendData = new BlendData();
  578. blendData.name = text;
  579. int num = r.ReadInt32();
  580. blendData.vert = new Vector3[num];
  581. blendData.norm = new Vector3[num];
  582. blendData.v_index = new int[num];
  583. bool flag = false;
  584. if (2102 <= ver)
  585. {
  586. flag = r.ReadBoolean();
  587. }
  588. if (flag)
  589. {
  590. blendData.tans = new Vector4[num];
  591. }
  592. for (int i = 0; i < num; i++)
  593. {
  594. blendData.v_index[i] = (int)r.ReadUInt16();
  595. blendData.vert[i].x = r.ReadSingle();
  596. blendData.vert[i].y = r.ReadSingle();
  597. blendData.vert[i].z = r.ReadSingle();
  598. blendData.norm[i].x = r.ReadSingle();
  599. blendData.norm[i].y = r.ReadSingle();
  600. blendData.norm[i].z = r.ReadSingle();
  601. if (flag)
  602. {
  603. blendData.tans[i].x = r.ReadSingle();
  604. blendData.tans[i].y = r.ReadSingle();
  605. blendData.tans[i].z = r.ReadSingle();
  606. blendData.tans[i].w = r.ReadSingle();
  607. }
  608. }
  609. this.MorphCount++;
  610. this.BlendDatas.Add(blendData);
  611. this.BlendValues = new float[this.MorphCount + 1];
  612. this.BlendValuesTemp = new float[this.MorphCount + 1];
  613. this.BlendValuesBackup = new float[this.MorphCount + 1];
  614. this.BlendValuesCHK = new float[this.MorphCount + 1];
  615. }
  616. public override void NewBlendSet(string BlendSetName)
  617. {
  618. float[] array = new float[this.hash.Count];
  619. for (int i = 0; i < array.Length; i++)
  620. {
  621. array[i] = 0f;
  622. }
  623. if (this.dicBlendSet.ContainsKey(BlendSetName))
  624. {
  625. Debug.LogError("\u0093ブレンドセット" + BlendSetName);
  626. }
  627. this.dicBlendSet[BlendSetName] = array;
  628. this.dicBlendAtr[BlendSetName] = 0;
  629. if (!this.dicBlendSet.ContainsKey("オリジナル"))
  630. {
  631. float[] array2 = new float[this.hash.Count];
  632. for (int j = 0; j < array2.Length; j++)
  633. {
  634. array2[j] = 0f;
  635. }
  636. this.dicBlendSet["オリジナル"] = array2;
  637. }
  638. }
  639. public override void SetValueBlendSet(string BlendSetName, string tag, float val)
  640. {
  641. if (tag == "hoho2")
  642. {
  643. Dictionary<string, int> dicBlendAtr = this.dicBlendAtr;
  644. int value = (this.dicBlendAtr[BlendSetName] & -4) | 2;
  645. this.dicBlendAtr[BlendSetName] = value;
  646. dicBlendAtr[BlendSetName] = value;
  647. }
  648. if (tag == "hoho" && (this.dicBlendAtr[BlendSetName] & 3) != 1)
  649. {
  650. this.dicBlendAtr[BlendSetName] = ((this.dicBlendAtr[BlendSetName] & -4) | 1);
  651. }
  652. if (!this.dicBlendSet.ContainsKey(BlendSetName))
  653. {
  654. Debug.LogError("表情がありません。" + BlendSetName);
  655. return;
  656. }
  657. if (tag.Contains("*"))
  658. {
  659. for (int i = 0; i < 3; i++)
  660. {
  661. string text = tag.Replace("*", TMorph.crcFaceTypesStr[i]);
  662. if (!this.hash.Contains(text))
  663. {
  664. Debug.LogError("表情がありません。tag=" + text);
  665. }
  666. else
  667. {
  668. int num = (int)this.hash[text];
  669. if (text == "hoho2")
  670. {
  671. this.IdxHOHO2 = num;
  672. }
  673. if (text == "hoho")
  674. {
  675. this.IdxHOHO = num;
  676. }
  677. this.dicBlendSet[BlendSetName][num] = val * 0.01f;
  678. }
  679. }
  680. }
  681. else
  682. {
  683. if (!this.hash.Contains(tag))
  684. {
  685. Debug.LogError("表情がありません。tag=" + tag);
  686. return;
  687. }
  688. int num2 = (int)this.hash[tag];
  689. if (tag == "hoho2")
  690. {
  691. this.IdxHOHO2 = num2;
  692. }
  693. if (tag == "hoho")
  694. {
  695. this.IdxHOHO = num2;
  696. }
  697. this.dicBlendSet[BlendSetName][num2] = val * 0.01f;
  698. }
  699. }
  700. public override void SetBlendSetValueOriginal(TMorph.AddBlendType add_blend_type_flag)
  701. {
  702. float[] array = this.dicBlendSet["オリジナル"];
  703. array[(int)this.hash["hohol"]] = (array[(int)this.hash["hoho"]] = (array[(int)this.hash["hohos"]] = 0f));
  704. if ((add_blend_type_flag & TMorph.AddBlendType.Cheek3) == TMorph.AddBlendType.Cheek3)
  705. {
  706. array[(int)this.hash["hohol"]] = 1f;
  707. }
  708. else if ((add_blend_type_flag & TMorph.AddBlendType.Cheek2) == TMorph.AddBlendType.Cheek2)
  709. {
  710. array[(int)this.hash["hoho"]] = 1f;
  711. }
  712. else if ((add_blend_type_flag & TMorph.AddBlendType.Cheek1) == TMorph.AddBlendType.Cheek1)
  713. {
  714. array[(int)this.hash["hohos"]] = 1f;
  715. }
  716. array[(int)this.hash["tear3"]] = (array[(int)this.hash["tear2"]] = (array[(int)this.hash["tear1"]] = 0f));
  717. if ((add_blend_type_flag & TMorph.AddBlendType.Tear3) == TMorph.AddBlendType.Tear3)
  718. {
  719. array[(int)this.hash["tear3"]] = 1f;
  720. }
  721. else if ((add_blend_type_flag & TMorph.AddBlendType.Tear2) == TMorph.AddBlendType.Tear2)
  722. {
  723. array[(int)this.hash["tear2"]] = 1f;
  724. }
  725. else if ((add_blend_type_flag & TMorph.AddBlendType.Tear1) == TMorph.AddBlendType.Tear1)
  726. {
  727. array[(int)this.hash["tear1"]] = 1f;
  728. }
  729. array[(int)this.hash["hoho2"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Blush) != TMorph.AddBlendType.Blush) ? 0 : 1);
  730. array[(int)this.hash["namida"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.TearBig) != TMorph.AddBlendType.TearBig) ? 0 : 1);
  731. array[(int)this.hash["yodare"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Yodare) != TMorph.AddBlendType.Yodare) ? 0 : 1);
  732. array[(int)this.hash["shock"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Shock) != TMorph.AddBlendType.Shock) ? 0 : 1);
  733. }
  734. public override void MulBlendSetValues(string BlendSetName, float mul = 1f)
  735. {
  736. if (this.dicBlendSet.ContainsKey(BlendSetName))
  737. {
  738. float[] array = this.dicBlendSet[BlendSetName];
  739. for (int i = 0; i < this.MorphCount; i++)
  740. {
  741. this.BlendValuesBackup[i] = (this.BlendValues[i] = this.BlendValues[i] * (1f - mul) + array[i] * mul);
  742. }
  743. return;
  744. }
  745. if (BlendSetName == "頬0涙0")
  746. {
  747. return;
  748. }
  749. Debug.LogError("表情がありません。" + BlendSetName);
  750. }
  751. public override void AddBlendSetValues(string BlendSetName, float add = 1f)
  752. {
  753. if (this.dicBlendSet.ContainsKey(BlendSetName))
  754. {
  755. float[] array = this.dicBlendSet[BlendSetName];
  756. for (int i = 0; i < this.MorphCount; i++)
  757. {
  758. this.BlendValues[i] += array[i] * add;
  759. if (this.BlendValues[i] > 1f)
  760. {
  761. this.BlendValues[i] = 1f;
  762. }
  763. this.BlendValuesBackup[i] = this.BlendValues[i];
  764. }
  765. return;
  766. }
  767. if (BlendSetName == "頬0涙0")
  768. {
  769. return;
  770. }
  771. Debug.LogError("表情がありません。" + BlendSetName);
  772. }
  773. public override void ClearBlendValues()
  774. {
  775. for (int i = 0; i < this.MorphCount; i++)
  776. {
  777. this.BlendValuesBackup[i] = (this.BlendValues[i] = 0f);
  778. }
  779. }
  780. public TMorphSkin.CRC_FACE_TYPE GetFaceTypeCRC()
  781. {
  782. float num = this.m_MabutaUpOut2.rate - 0.5f;
  783. float num2 = Mathf.Clamp01(num / -0.5f);
  784. float num3 = Mathf.Clamp01(num / 0.5f);
  785. if (num2 < 0.35f && num3 < 0.35f)
  786. {
  787. return TMorphSkin.CRC_FACE_TYPE.NORMAL;
  788. }
  789. if (0.35f <= num2)
  790. {
  791. return TMorphSkin.CRC_FACE_TYPE.TARE;
  792. }
  793. if (0.35f <= num3)
  794. {
  795. return TMorphSkin.CRC_FACE_TYPE.TSURI;
  796. }
  797. return TMorphSkin.CRC_FACE_TYPE.MAX;
  798. }
  799. public override void FixBlendValues_Face()
  800. {
  801. if (!this.m_isMan && 120 <= this.bodyskin.PartsVersion)
  802. {
  803. this.m_crcFaceTypeNow = this.GetFaceTypeCRC();
  804. for (int i = 0; i < 3; i++)
  805. {
  806. if (i != (int)this.m_crcFaceTypeNow)
  807. {
  808. int[] array = this.BlendDataIdx_EyeClose[i];
  809. for (int j = 0; j < array.Length; j++)
  810. {
  811. this.BlendValues[array[j]] = 0f;
  812. }
  813. }
  814. }
  815. }
  816. int[] array2 = this.BlendDataIdx_EyeClose[(int)this.m_crcFaceTypeNow];
  817. this.BlendValuesTemp[array2[0]] = this.m_fEyeCloseRate + this.BlendValuesBackup[array2[0]] * (1f - this.m_fEyeCloseRate);
  818. for (int k = 1; k < 10; k++)
  819. {
  820. if (array2[k] != 0)
  821. {
  822. this.BlendValuesTemp[array2[k]] = this.BlendValuesBackup[array2[k]] * (1f - this.m_fEyeCloseRate);
  823. }
  824. }
  825. if (0f < this.EyeMabataki)
  826. {
  827. float num = 0f;
  828. for (int l = 0; l < 10; l++)
  829. {
  830. if (array2[l] != 0)
  831. {
  832. num += this.BlendValuesTemp[array2[l]];
  833. }
  834. }
  835. if (num > 1f)
  836. {
  837. num = 1f;
  838. }
  839. float num2 = 1f - num;
  840. float num3 = this.BlendValuesTemp[array2[0]] + num2 * this.EyeMabataki;
  841. if (num3 > 0f)
  842. {
  843. this.BlendValuesTemp[array2[0]] = num3;
  844. }
  845. }
  846. for (int m = 0; m < 10; m++)
  847. {
  848. if (array2[m] != 0)
  849. {
  850. this.BlendValues[array2[m]] = this.BlendValuesTemp[array2[m]];
  851. }
  852. }
  853. if (this.m_EarNoneData.idx != -1)
  854. {
  855. this.BlendValues[this.m_EarNoneData.idx] = (float)((!this.m_EarNoneData.rate) ? 0 : 1);
  856. }
  857. if (this.m_EarElfData.idx != -1 && !this.m_EarNoneData.rate)
  858. {
  859. this.BlendValues[this.m_EarElfData.idx] = this.m_EarElfData.rate;
  860. }
  861. if (this.m_FaceShapeData.idx != -1)
  862. {
  863. this.BlendValues[this.m_FaceShapeData.idx] = this.m_FaceShapeData.rate;
  864. }
  865. if (this.m_FaceShapeSlimData.idx != -1)
  866. {
  867. this.BlendValues[this.m_FaceShapeSlimData.idx] = this.m_FaceShapeSlimData.rate;
  868. }
  869. if (this.m_MayuShapeIn.idx != -1)
  870. {
  871. this.BlendValues[this.m_MayuShapeIn.idx] = this.m_MayuShapeIn.rate;
  872. }
  873. if (this.m_MayuShapeOut.idx != -1)
  874. {
  875. this.BlendValues[this.m_MayuShapeOut.idx] = this.m_MayuShapeOut.rate;
  876. }
  877. if (120 <= this.bodyskin.PartsVersion && this.m_IdxMinMaxList != null)
  878. {
  879. float arg = 1f - Mathf.Clamp01(this.BlendValues[array2[0]] + this.BlendValues[array2[1]] + this.BlendValues[array2[4]] + this.BlendValues[array2[5]]);
  880. float arg2 = 1f - Mathf.Clamp01(this.BlendValues[array2[0]] + this.BlendValues[array2[1]] + this.BlendValues[array2[6]] + this.BlendValues[array2[7]]);
  881. foreach (TMorph.IdxMinMaxRatePair idxMinMaxRatePair in this.m_IdxMinMaxList)
  882. {
  883. if (idxMinMaxRatePair.exec != null)
  884. {
  885. idxMinMaxRatePair.exec(arg, arg2);
  886. }
  887. }
  888. }
  889. if (this.m_HitomiShapeUp.idx != -1)
  890. {
  891. this.BlendValues[this.m_HitomiShapeUp.idx] = this.m_HitomiShapeUp.rate;
  892. }
  893. if (this.m_HitomiShapeLow.idx != -1)
  894. {
  895. this.BlendValues[this.m_HitomiShapeLow.idx] = this.m_HitomiShapeLow.rate;
  896. }
  897. if (this.m_HitomiShapeIn.idx != -1)
  898. {
  899. this.BlendValues[this.m_HitomiShapeIn.idx] = this.m_HitomiShapeIn.rate;
  900. }
  901. if (this.m_HitomiShapeOutUp.idx != -1)
  902. {
  903. this.BlendValues[this.m_HitomiShapeOutUp.idx] = this.m_HitomiShapeOutUp.rate;
  904. }
  905. if (this.m_HitomiShapeOutLow.idx != -1)
  906. {
  907. this.BlendValues[this.m_HitomiShapeOutLow.idx] = this.m_HitomiShapeOutLow.rate;
  908. }
  909. if (this.m_HohoShape.idx != -1)
  910. {
  911. this.BlendValues[this.m_HohoShape.idx] = this.m_HohoShape.rate;
  912. }
  913. if (this.m_Ha1.idx != -1)
  914. {
  915. this.BlendValues[this.m_Ha1.idx] = this.m_Ha1.rate;
  916. }
  917. if (this.m_Ha2.idx != -1)
  918. {
  919. this.BlendValues[this.m_Ha2.idx] = this.m_Ha2.rate;
  920. }
  921. if (this.m_Ha3.idx != -1)
  922. {
  923. this.BlendValues[this.m_Ha3.idx] = this.m_Ha3.rate;
  924. }
  925. if (this.m_Ha4.idx != -1)
  926. {
  927. this.BlendValues[this.m_Ha4.idx] = this.m_Ha4.rate;
  928. }
  929. if (this.m_Ha5.idx != -1)
  930. {
  931. this.BlendValues[this.m_Ha5.idx] = this.m_Ha5.rate;
  932. }
  933. if (this.m_Ha6.idx != -1)
  934. {
  935. this.BlendValues[this.m_Ha6.idx] = this.m_Ha6.rate;
  936. }
  937. if (this.boLipSync)
  938. {
  939. this.BlendValues[this.BlendDataIdx_LipSync_A] = base.LipSync1 * 0.8f;
  940. this.BlendValues[this.BlendDataIdx_LipSync_C] = base.LipSync3 * 0.7f;
  941. this.BlendValues[this.BlendDataIdx_LipSync_ToothOFF] = base.LipSync3;
  942. this.BlendValues[this.BlendDataIdx_LipSync_S] = base.LipSync2 * (1f - base.LipSync1) * 0.5f;
  943. this.BlendValues[this.BlendDataIdx_LipSync_W] = base.LipSync2 * 0.3f;
  944. this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0.5f;
  945. }
  946. if (this.boLookTooth)
  947. {
  948. this.BlendValues[this.BlendDataIdx_LipSync_A] = 0f;
  949. this.BlendValues[this.BlendDataIdx_LipSync_S] = 0.7f;
  950. this.BlendValues[this.BlendDataIdx_LipSync_C] = 0f;
  951. this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0f;
  952. }
  953. if (this.boBallGAG)
  954. {
  955. this.BlendValues[this.BlendDataIdx_LipSync_A] = 1f;
  956. this.BlendValues[this.BlendDataIdx_LipSync_S] = 0f;
  957. this.BlendValues[this.BlendDataIdx_LipSync_C] = 0f;
  958. this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0f;
  959. }
  960. float num4 = this.BlendValues[this.BlendDataIdx_Tear3];
  961. if (this.BlendValues[this.BlendDataIdx_Tear2] + num4 > 1f)
  962. {
  963. this.BlendValues[this.BlendDataIdx_Tear2] = 1f - num4;
  964. num4 = 1f;
  965. }
  966. else
  967. {
  968. num4 += this.BlendValues[this.BlendDataIdx_Tear2];
  969. }
  970. if (this.BlendValues[this.BlendDataIdx_Tear1] + num4 > 1f)
  971. {
  972. this.BlendValues[this.BlendDataIdx_Tear1] = 1f - num4;
  973. }
  974. if (this.boNoseFook)
  975. {
  976. this.BlendValues[this.BlendDataIdx_NoseFook] = 1f;
  977. }
  978. else
  979. {
  980. this.BlendValues[this.BlendDataIdx_NoseFook] = 0f;
  981. }
  982. int num5 = 0;
  983. for (int n = 0; n < this.MorphCount; n++)
  984. {
  985. if (this.BlendValuesCHK[n] != this.BlendValues[n])
  986. {
  987. num5++;
  988. this.BlendValuesCHK[n] = this.BlendValues[n];
  989. }
  990. }
  991. if (num5 == 0)
  992. {
  993. return;
  994. }
  995. this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
  996. this.m_bMorph = true;
  997. if (this.BlendValues[this.IdxHOHO] < 0.5f)
  998. {
  999. this.BlendValues[this.IdxHOHO] = 0f;
  1000. }
  1001. else
  1002. {
  1003. this.BlendValues[this.IdxHOHO] = 1f;
  1004. }
  1005. if (this.BlendValues[this.IdxHOHO2] < 0.5f)
  1006. {
  1007. this.BlendValues[this.IdxHOHO2] = 0f;
  1008. }
  1009. else
  1010. {
  1011. this.BlendValues[this.IdxHOHO2] = 1f;
  1012. }
  1013. for (int num6 = 0; num6 < this.MorphCount; num6++)
  1014. {
  1015. if (this.BlendDatas[num6] == null)
  1016. {
  1017. this.UruUruScaleX = this.BlendValues[num6];
  1018. }
  1019. else
  1020. {
  1021. float num7 = this.BlendValues[num6];
  1022. if (num7 >= 0.01f || num6 == this.m_MayuShapeIn.idx || num6 == this.m_MayuShapeOut.idx)
  1023. {
  1024. int num8 = this.BlendDatas[num6].v_index.Length;
  1025. for (int num9 = 0; num9 < num8; num9++)
  1026. {
  1027. int num10 = this.BlendDatas[num6].v_index[num9];
  1028. this.m_vTmpVert[num10] += this.BlendDatas[num6].vert[num9] * num7;
  1029. }
  1030. }
  1031. }
  1032. }
  1033. this.m_mesh.vertices = this.m_vTmpVert;
  1034. foreach (TAttachPoint tattachPoint in this.dicAttachPoint.Values)
  1035. {
  1036. int vidx = tattachPoint.vidx;
  1037. Vector3 vector = Vector3.zero;
  1038. vector += this.m_bindposes[tattachPoint.bw.boneIndex0].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight0;
  1039. vector += this.m_bindposes[tattachPoint.bw.boneIndex1].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight1;
  1040. vector += this.m_bindposes[tattachPoint.bw.boneIndex2].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight2;
  1041. vector += this.m_bindposes[tattachPoint.bw.boneIndex3].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight3;
  1042. this.BindVert[vidx] = vector;
  1043. }
  1044. }
  1045. public override void FixBlendValues()
  1046. {
  1047. if (this.m_baseBlendValues != null)
  1048. {
  1049. foreach (KeyValuePair<int, List<TMorphSkin.BaseBlendValue>> keyValuePair in this.m_baseBlendValues)
  1050. {
  1051. this.SetBlendValues(keyValuePair.Key, 0f);
  1052. foreach (TMorphSkin.BaseBlendValue baseBlendValue in keyValuePair.Value)
  1053. {
  1054. TBodySkin slot = this.bodyskin.body.GetSlot((int)baseBlendValue.parentSlotId);
  1055. if (slot.boVisible)
  1056. {
  1057. this.SetBlendValues(keyValuePair.Key, baseBlendValue.defValue * this.BaseBlendValue_Kuikomi[(int)baseBlendValue.tag]);
  1058. }
  1059. }
  1060. }
  1061. }
  1062. if (this.m_chikubiTotsuMorphsIdx != null)
  1063. {
  1064. TBodySkin.CHIKUBI_STATE chikubi_STATE = this.bodyskin.body.IsChikubiState();
  1065. foreach (int num in this.m_chikubiTotsuMorphsIdx)
  1066. {
  1067. this.BlendValues[num] = this.BlendValuesBackup[num];
  1068. if (chikubi_STATE == TBodySkin.CHIKUBI_STATE.固定凸)
  1069. {
  1070. this.BlendValues[num] = this.BlendValuesBackup[num] * 1f;
  1071. }
  1072. else if (chikubi_STATE == TBodySkin.CHIKUBI_STATE.基本凹)
  1073. {
  1074. this.BlendValues[num] = this.BlendValuesBackup[num] * this.ChikubiWearTotsu;
  1075. }
  1076. }
  1077. }
  1078. int num2 = 0;
  1079. for (int i = 0; i < this.MorphCount; i++)
  1080. {
  1081. if (this.BlendValuesCHK[i] != this.BlendValues[i])
  1082. {
  1083. num2++;
  1084. this.BlendValuesCHK[i] = this.BlendValues[i];
  1085. }
  1086. }
  1087. if (num2 == 0)
  1088. {
  1089. return;
  1090. }
  1091. this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
  1092. this.m_vOriNorm.CopyTo(this.m_vTmpNorm, 0);
  1093. if (this.m_vOriTan != null)
  1094. {
  1095. this.m_vOriTan.CopyTo(this.m_vTmpTan, 0);
  1096. }
  1097. this.m_bMorph = true;
  1098. for (int j = 0; j < this.MorphCount; j++)
  1099. {
  1100. if (this.BlendDatas[j] == null)
  1101. {
  1102. this.UruUruScaleX = this.BlendValues[j];
  1103. }
  1104. else
  1105. {
  1106. float num3 = this.BlendValues[j];
  1107. if (num3 >= 0.01f || j == this.m_MayuShapeIn.idx || j == this.m_MayuShapeOut.idx)
  1108. {
  1109. int num4 = this.BlendDatas[j].v_index.Length;
  1110. for (int k = 0; k < num4; k++)
  1111. {
  1112. int num5 = this.BlendDatas[j].v_index[k];
  1113. this.m_vTmpVert[num5] += this.BlendDatas[j].vert[k] * num3;
  1114. this.m_vTmpNorm[num5] += this.BlendDatas[j].norm[k] * num3;
  1115. }
  1116. }
  1117. }
  1118. }
  1119. this.m_mesh.vertices = this.m_vTmpVert;
  1120. this.m_mesh.normals = this.m_vTmpNorm;
  1121. this.m_mesh.tangents = this.m_vTmpTan;
  1122. foreach (TAttachPoint tattachPoint in this.dicAttachPoint.Values)
  1123. {
  1124. int vidx = tattachPoint.vidx;
  1125. this.BindVert[vidx] = this.m_bindposes[tattachPoint.bw.boneIndex0].MultiplyPoint3x4(this.m_vTmpVert[vidx]);
  1126. }
  1127. }
  1128. public override void ResetBlendValues()
  1129. {
  1130. if (this.m_bMorph)
  1131. {
  1132. this.m_mesh.vertices = this.m_vTmpVert;
  1133. this.m_mesh.normals = this.m_vTmpNorm;
  1134. this.m_mesh.tangents = this.m_vTmpTan;
  1135. }
  1136. }
  1137. public void AddBaseBlendValue(TBody.SlotID parentSlotId, TMorphSkin.BaseBlendValue.Tag tag, string blendName, float defValue)
  1138. {
  1139. blendName = blendName.ToLower();
  1140. if (this.m_baseBlendValues == null || !this.hash.ContainsKey(blendName))
  1141. {
  1142. return;
  1143. }
  1144. int key = (int)this.hash[blendName];
  1145. List<TMorphSkin.BaseBlendValue> list;
  1146. if (!this.m_baseBlendValues.TryGetValue(key, out list))
  1147. {
  1148. List<TMorphSkin.BaseBlendValue> list2 = new List<TMorphSkin.BaseBlendValue>();
  1149. this.m_baseBlendValues[key] = list2;
  1150. list = list2;
  1151. }
  1152. list.Add(new TMorphSkin.BaseBlendValue
  1153. {
  1154. tag = tag,
  1155. parentSlotId = parentSlotId,
  1156. defValue = defValue
  1157. });
  1158. }
  1159. public void RemoveBaseBlendValue(TBody.SlotID parentSlotId)
  1160. {
  1161. if (this.m_baseBlendValues == null)
  1162. {
  1163. return;
  1164. }
  1165. foreach (KeyValuePair<int, List<TMorphSkin.BaseBlendValue>> keyValuePair in this.m_baseBlendValues)
  1166. {
  1167. keyValuePair.Value.RemoveAll((TMorphSkin.BaseBlendValue a) => a.parentSlotId == parentSlotId);
  1168. }
  1169. }
  1170. public bool IsUseBaseBlendValue(TMorphSkin.BaseBlendValue.Tag tag)
  1171. {
  1172. if (this.m_baseBlendValues == null || this.m_baseBlendValues.Count == 0)
  1173. {
  1174. return false;
  1175. }
  1176. List<List<TMorphSkin.BaseBlendValue>> list = new List<List<TMorphSkin.BaseBlendValue>>(this.m_baseBlendValues.Values);
  1177. return list.Find((List<TMorphSkin.BaseBlendValue> a) => a.Find((TMorphSkin.BaseBlendValue b) => b.tag == tag) != null) != null;
  1178. }
  1179. public TAttachPoint AddNewAttachPoint(TBodySkin childTbskin, string apname)
  1180. {
  1181. this.RemoveNewAttachPoint(apname);
  1182. TAttachPoint tattachPoint = null;
  1183. if (!this.dicAttachPoint.TryGetValue(apname, out tattachPoint))
  1184. {
  1185. TAttachPoint tattachPoint2 = new TAttachPoint();
  1186. this.dicAttachPoint[apname] = tattachPoint2;
  1187. tattachPoint = tattachPoint2;
  1188. }
  1189. tattachPoint.newAttachChild = childTbskin;
  1190. tattachPoint.newAttachPoint = true;
  1191. return tattachPoint;
  1192. }
  1193. public bool RemoveNewAttachPoint(string apname)
  1194. {
  1195. TAttachPoint tattachPoint = null;
  1196. return this.dicAttachPoint.TryGetValue(apname, out tattachPoint) && tattachPoint.newAttachPoint && this.dicAttachPoint.Remove(apname);
  1197. }
  1198. public TAttachPoint GetAttachPoint(string apname)
  1199. {
  1200. TAttachPoint result = null;
  1201. this.dicAttachPoint.TryGetValue(apname, out result);
  1202. return result;
  1203. }
  1204. public override void SetEnableAttachPointEdit(bool f_bEnable, string f_strApName)
  1205. {
  1206. TAttachPoint tattachPoint = this.dicAttachPoint[f_strApName];
  1207. if (tattachPoint.bEditable == f_bEnable)
  1208. {
  1209. return;
  1210. }
  1211. int num = tattachPoint.srcvidx;
  1212. Vector3 vector = Vector3.zero;
  1213. Vector3 vector2 = Vector3.one;
  1214. Quaternion quaternion = tattachPoint.qSrc;
  1215. VtxAttachPos attachPointPos = this.bodyskin.body.maid.GetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, f_strApName);
  1216. if (attachPointPos != null)
  1217. {
  1218. num = attachPointPos.vidx;
  1219. vector = attachPointPos.prs.position;
  1220. quaternion = attachPointPos.prs.rotation;
  1221. vector2 = attachPointPos.prs.scale;
  1222. }
  1223. if (f_bEnable)
  1224. {
  1225. tattachPoint.vidx = num;
  1226. tattachPoint.vOffsLocal = vector;
  1227. tattachPoint.qNow = quaternion;
  1228. tattachPoint.vScaleRate = vector2;
  1229. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1230. }
  1231. else
  1232. {
  1233. tattachPoint.vidx = tattachPoint.srcvidx;
  1234. tattachPoint.vOffsLocal = Vector3.zero;
  1235. tattachPoint.qNow = tattachPoint.qSrc;
  1236. tattachPoint.vScaleRate = Vector3.one;
  1237. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1238. }
  1239. tattachPoint.bEditable = f_bEnable;
  1240. this.bodyskin.body.maid.SetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, f_strApName, num, vector, quaternion, vector2, tattachPoint.bEditable);
  1241. }
  1242. public override bool GetEnableAttachPointEdit(string f_strApName)
  1243. {
  1244. return this.dicAttachPoint[f_strApName].bEditable;
  1245. }
  1246. public override void SetAttachPoint(string apname, Vector3 vc, Quaternion q, bool f_bTemp)
  1247. {
  1248. TAttachPoint tattachPoint = new TAttachPoint();
  1249. float num = (vc - this.DefVert[0]).sqrMagnitude;
  1250. int num2 = 0;
  1251. for (int i = 0; i < this.m_vOriVert.Length; i++)
  1252. {
  1253. float sqrMagnitude = (vc - this.DefVert[i]).sqrMagnitude;
  1254. if (num > sqrMagnitude)
  1255. {
  1256. num = sqrMagnitude;
  1257. num2 = i;
  1258. }
  1259. }
  1260. tattachPoint.srcvidx = (tattachPoint.vidx = num2);
  1261. tattachPoint.vOffsLocal = Vector3.zero;
  1262. TAttachPoint tattachPoint2 = tattachPoint;
  1263. tattachPoint.qNow = q;
  1264. tattachPoint2.qSrc = q;
  1265. tattachPoint.vScaleRate = Vector3.one;
  1266. tattachPoint.bw = this.m_bws[num2];
  1267. this.dicAttachPoint[apname] = tattachPoint;
  1268. if (!f_bTemp)
  1269. {
  1270. VtxAttachPos attachPointPos = this.bodyskin.body.maid.GetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, apname);
  1271. if (attachPointPos != null && attachPointPos.bEnable)
  1272. {
  1273. tattachPoint.vidx = attachPointPos.vidx;
  1274. tattachPoint.vOffsLocal = attachPointPos.prs.position;
  1275. tattachPoint.qNow = attachPointPos.prs.rotation;
  1276. tattachPoint.vScaleRate = attachPointPos.prs.scale;
  1277. tattachPoint.bEditable = true;
  1278. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1279. }
  1280. }
  1281. }
  1282. public override void SetAttachPointOffsetLocal(string apname, VtxAttachPos f_vap)
  1283. {
  1284. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1285. tattachPoint.vidx = f_vap.vidx;
  1286. tattachPoint.vOffsLocal = f_vap.prs.position;
  1287. tattachPoint.qNow = f_vap.prs.rotation;
  1288. tattachPoint.vScaleRate = f_vap.prs.scale;
  1289. tattachPoint.bEditable = true;
  1290. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1291. }
  1292. public override bool CopyAttachObjPoint(string apname)
  1293. {
  1294. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1295. TMorph.TempAttachPos tempAttachPos = new TMorph.TempAttachPos();
  1296. tempAttachPos.m_nVidx = tattachPoint.vidx;
  1297. tempAttachPos.m_vPos = tattachPoint.vOffsLocal;
  1298. tempAttachPos.m_qRot = tattachPoint.qNow;
  1299. tempAttachPos.m_vScale = tattachPoint.vScaleRate;
  1300. this.bodyskin.m_dicTempAttachPoint[apname] = tempAttachPos;
  1301. return true;
  1302. }
  1303. public override bool PastAttachObjPoint(string apname)
  1304. {
  1305. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1306. TMorph.TempAttachPos tempAttachPos = null;
  1307. if (this.bodyskin.m_dicTempAttachPoint.TryGetValue(apname, out tempAttachPos))
  1308. {
  1309. tattachPoint.bEditable = true;
  1310. tattachPoint.vidx = tempAttachPos.m_nVidx;
  1311. tattachPoint.vOffsLocal = tempAttachPos.m_vPos;
  1312. tattachPoint.qNow = tempAttachPos.m_qRot;
  1313. tattachPoint.vScaleRate = tempAttachPos.m_vScale;
  1314. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1315. }
  1316. this.bodyskin.body.maid.SetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, apname, tattachPoint.vidx, tattachPoint.vOffsLocal, tattachPoint.qNow, tattachPoint.vScaleRate, tattachPoint.bEditable);
  1317. return true;
  1318. }
  1319. public override void SetAttachPointWorld(string apname, Vector3 vWorldPos, Quaternion qWorldRot, Vector3 vScaleRate)
  1320. {
  1321. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1322. if (!tattachPoint.bEditable)
  1323. {
  1324. return;
  1325. }
  1326. this.ReclucPointWorldAndScreen(null);
  1327. int vidx = tattachPoint.vidx;
  1328. float num = (this.WorldV[vidx] - vWorldPos).sqrMagnitude;
  1329. int num2 = vidx;
  1330. for (int i = 0; i < this.m_vOriVert.Length; i++)
  1331. {
  1332. float sqrMagnitude = (this.WorldV[i] - vWorldPos).sqrMagnitude;
  1333. if (sqrMagnitude < num)
  1334. {
  1335. num = sqrMagnitude;
  1336. num2 = i;
  1337. }
  1338. }
  1339. tattachPoint.vidx = num2;
  1340. tattachPoint.bw = this.m_bws[num2];
  1341. int num3 = this.BindBone[num2];
  1342. Transform transform = this.m_bones[num3].transform;
  1343. Vector3 vector = Vector3.zero;
  1344. if (this.SlotId == TBody.SlotID.body)
  1345. {
  1346. this.CalcVertexPoint(ref vector, num2, ref tattachPoint.bw);
  1347. }
  1348. else
  1349. {
  1350. vector = this.BindVert[num2];
  1351. vector = transform.TransformPoint(vector);
  1352. tattachPoint.vOffsLocal = transform.InverseTransformPoint(vWorldPos) - transform.InverseTransformPoint(vector);
  1353. }
  1354. tattachPoint.qNow = Quaternion.Inverse(transform.transform.rotation) * qWorldRot;
  1355. tattachPoint.vScaleRate = vScaleRate;
  1356. this.dicAttachPoint[apname] = tattachPoint;
  1357. this.bodyskin.body.maid.SetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, apname, tattachPoint.vidx, tattachPoint.vOffsLocal, tattachPoint.qNow, tattachPoint.vScaleRate, tattachPoint.bEditable);
  1358. Debug.DrawLine(vector, vWorldPos, Color.cyan);
  1359. }
  1360. public override bool GetAttachPoint(string apname, out Vector3 vWorldPos, out Quaternion qWorldRot, out Vector3 vScaleRate, bool f_bTemp = false)
  1361. {
  1362. if (!this.dicAttachPoint.ContainsKey(apname))
  1363. {
  1364. vWorldPos = Vector3.zero;
  1365. qWorldRot = Quaternion.identity;
  1366. vScaleRate = Vector3.one;
  1367. return false;
  1368. }
  1369. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1370. Vector3 vector = Vector3.zero;
  1371. int num = tattachPoint.vidx;
  1372. if (f_bTemp)
  1373. {
  1374. num = tattachPoint.srcvidx;
  1375. }
  1376. Transform transform = this.m_bones[this.BindBone[num]].transform;
  1377. if (this.SlotId == TBody.SlotID.body)
  1378. {
  1379. this.CalcVertexPoint(ref vector, num, ref tattachPoint.bw);
  1380. }
  1381. else
  1382. {
  1383. if (!f_bTemp)
  1384. {
  1385. vector = tattachPoint.vOffsLocal;
  1386. }
  1387. vector += this.BindVert[num];
  1388. vector = transform.TransformPoint(vector);
  1389. }
  1390. vWorldPos = vector;
  1391. if (f_bTemp)
  1392. {
  1393. qWorldRot = transform.rotation * tattachPoint.qSrc;
  1394. vScaleRate = Vector3.one;
  1395. }
  1396. else
  1397. {
  1398. qWorldRot = transform.rotation * tattachPoint.qNow;
  1399. vScaleRate = tattachPoint.vScaleRate;
  1400. }
  1401. return true;
  1402. }
  1403. public override bool ResetAttachPoint(string apname)
  1404. {
  1405. if (!this.dicAttachPoint.ContainsKey(apname))
  1406. {
  1407. Debug.LogError("アタッチポイント " + apname + " はありません。");
  1408. return false;
  1409. }
  1410. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1411. tattachPoint.vidx = tattachPoint.srcvidx;
  1412. tattachPoint.vOffsLocal = Vector3.zero;
  1413. tattachPoint.qNow = tattachPoint.qSrc;
  1414. tattachPoint.vScaleRate = Vector3.one;
  1415. tattachPoint.bw = this.m_bws[tattachPoint.vidx];
  1416. this.bodyskin.body.maid.ClearAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, apname);
  1417. return true;
  1418. }
  1419. public override void ReclucPointWorldAndScreen(Camera cam = null)
  1420. {
  1421. bool flag = cam != null;
  1422. for (int i = 0; i < this.VCount; i++)
  1423. {
  1424. BoneWeight boneWeight = this.m_bws[i];
  1425. Vector3 zero = Vector3.zero;
  1426. this.CalcVertexPoint(ref zero, i, ref boneWeight);
  1427. this.WorldV[i] = zero;
  1428. if (flag)
  1429. {
  1430. this.ScrnV[i] = cam.WorldToScreenPoint(zero);
  1431. }
  1432. }
  1433. }
  1434. private void CalcVertexPoint(ref Vector3 vPosLocalToWorld, int nVtx, ref BoneWeight bw)
  1435. {
  1436. vPosLocalToWorld += this.m_bones[bw.boneIndex0].transform.TransformPoint(this.m_bindposes[bw.boneIndex0].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight0;
  1437. if (bw.weight1 != 0f)
  1438. {
  1439. vPosLocalToWorld += this.m_bones[bw.boneIndex1].TransformPoint(this.m_bindposes[bw.boneIndex1].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight1;
  1440. }
  1441. if (bw.weight2 != 0f)
  1442. {
  1443. vPosLocalToWorld += this.m_bones[bw.boneIndex2].TransformPoint(this.m_bindposes[bw.boneIndex2].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight2;
  1444. }
  1445. if (bw.weight3 != 0f)
  1446. {
  1447. vPosLocalToWorld += this.m_bones[bw.boneIndex3].TransformPoint(this.m_bindposes[bw.boneIndex3].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight3;
  1448. }
  1449. }
  1450. private Vector3 CalcVertexPointWorldToLocal(Vector3 vWorld, int nVtx, ref BoneWeight bw)
  1451. {
  1452. Vector3 vector = Vector3.zero;
  1453. vector += this.m_bones[bw.boneIndex0].transform.InverseTransformPoint(vWorld) * bw.weight0;
  1454. if (bw.weight1 != 0f)
  1455. {
  1456. vector += this.m_bones[bw.boneIndex1].InverseTransformPoint(vWorld) * bw.weight1;
  1457. }
  1458. if (bw.weight2 != 0f)
  1459. {
  1460. vector += this.m_bones[bw.boneIndex2].InverseTransformPoint(vWorld) * bw.weight2;
  1461. }
  1462. if (bw.weight3 != 0f)
  1463. {
  1464. vector += this.m_bones[bw.boneIndex3].InverseTransformPoint(vWorld) * bw.weight3;
  1465. }
  1466. return vector;
  1467. }
  1468. private Vector3 CalcVertexPointLocalToWorld(Vector3 vLocal, int nVtx, ref BoneWeight bw)
  1469. {
  1470. Vector3 vector = Vector3.zero;
  1471. vector += this.m_bones[bw.boneIndex0].transform.TransformPoint(vLocal) * bw.weight0;
  1472. if (bw.weight1 != 0f)
  1473. {
  1474. vector += this.m_bones[bw.boneIndex1].TransformPoint(vLocal) * bw.weight1;
  1475. }
  1476. if (bw.weight2 != 0f)
  1477. {
  1478. vector += this.m_bones[bw.boneIndex2].TransformPoint(vLocal) * bw.weight2;
  1479. }
  1480. if (bw.weight3 != 0f)
  1481. {
  1482. vector += this.m_bones[bw.boneIndex3].TransformPoint(vLocal) * bw.weight3;
  1483. }
  1484. return vector;
  1485. }
  1486. public void FindNearVertex(bool reCalcWorldVtx, Vector3 worldPos, ref float findDistance, ref int findNearVtx, ref Vector3 findNearPoint)
  1487. {
  1488. if (reCalcWorldVtx)
  1489. {
  1490. this.ReclucPointWorldAndScreen(null);
  1491. }
  1492. float num = float.MaxValue;
  1493. int num2 = 0;
  1494. Vector3 vector = Vector3.zero;
  1495. for (int i = 0; i < this.VCount; i++)
  1496. {
  1497. float sqrMagnitude = (this.WorldV[i] - worldPos).sqrMagnitude;
  1498. if (sqrMagnitude < num)
  1499. {
  1500. num = sqrMagnitude;
  1501. num2 = i;
  1502. vector = this.WorldV[i];
  1503. }
  1504. }
  1505. findDistance = num;
  1506. findNearVtx = num2;
  1507. findNearPoint = vector;
  1508. }
  1509. public TAttachPoint AddNewAttachPoint(TBodySkin childTbskin, string apname, int[] vidxs)
  1510. {
  1511. TAttachPoint tattachPoint = this.AddNewAttachPoint(childTbskin, apname);
  1512. tattachPoint.newAttachPoint = true;
  1513. tattachPoint.newAttachVidx[0] = vidxs[0];
  1514. tattachPoint.newAttachVidx[1] = vidxs[1];
  1515. tattachPoint.newAttachVidx[2] = vidxs[2];
  1516. return tattachPoint;
  1517. }
  1518. public bool SearchAdjacentVidx(int vidx, ref int[] vtx)
  1519. {
  1520. bool flag = false;
  1521. for (int i = 0; i < this.m_nSubMeshOriTri.Length; i++)
  1522. {
  1523. int[] array = this.m_nSubMeshOriTri[i];
  1524. for (int j = 0; j < array.Length; j += 3)
  1525. {
  1526. if (!flag)
  1527. {
  1528. if (array[j] == vidx)
  1529. {
  1530. vtx[0] = array[j];
  1531. vtx[1] = array[j + 1];
  1532. vtx[2] = array[j + 2];
  1533. flag = true;
  1534. break;
  1535. }
  1536. if (array[j + 1] == vidx)
  1537. {
  1538. vtx[0] = array[j + 1];
  1539. vtx[1] = array[j + 2];
  1540. vtx[2] = array[j];
  1541. flag = true;
  1542. break;
  1543. }
  1544. if (array[j + 2] == vidx)
  1545. {
  1546. vtx[0] = array[j + 2];
  1547. vtx[1] = array[j];
  1548. vtx[2] = array[j + 1];
  1549. flag = true;
  1550. break;
  1551. }
  1552. }
  1553. }
  1554. if (flag)
  1555. {
  1556. break;
  1557. }
  1558. }
  1559. return flag;
  1560. }
  1561. public Vector3[] GetNewAttachPointWorld(string apname)
  1562. {
  1563. if (!this.dicAttachPoint.ContainsKey(apname))
  1564. {
  1565. return null;
  1566. }
  1567. TAttachPoint tattachPoint = this.dicAttachPoint[apname];
  1568. if (!tattachPoint.newAttachPoint)
  1569. {
  1570. return null;
  1571. }
  1572. Vector3[] result = new Vector3[3];
  1573. this.CalcVidxToPos(tattachPoint.newAttachVidx, ref result);
  1574. return result;
  1575. }
  1576. public void CalcVidxToPos(int vidx, ref Vector3 pos)
  1577. {
  1578. BoneWeight boneWeight = this.m_bws[vidx];
  1579. this.CalcVertexPoint(ref pos, vidx, ref boneWeight);
  1580. }
  1581. public void CalcVidxToPos(int[] vidxs, ref Vector3[] pos)
  1582. {
  1583. for (int i = 0; i < vidxs.Length; i++)
  1584. {
  1585. int num = vidxs[i];
  1586. BoneWeight boneWeight = this.m_bws[num];
  1587. this.CalcVertexPoint(ref pos[i], num, ref boneWeight);
  1588. }
  1589. }
  1590. public int SearchRayToNearVtxDistance(int[] vtxs, Vector3[] poss, MathCM.Segment seg)
  1591. {
  1592. float num = 1f;
  1593. int result = -1;
  1594. Vector3 vector = Vector3.zero;
  1595. for (int i = 0; i < poss.Length; i++)
  1596. {
  1597. Vector3 vector2;
  1598. float num3;
  1599. float num2 = MathCM.calcPointSegmentDist(ref poss[i], ref seg, out vector2, out num3);
  1600. if (num2 < num)
  1601. {
  1602. num = num2;
  1603. int num4 = vtxs[i];
  1604. vector = poss[i];
  1605. result = i;
  1606. }
  1607. }
  1608. return result;
  1609. }
  1610. public override void OnApplicationQuit()
  1611. {
  1612. Debug.LogError("TMorph OnApplicationQuit");
  1613. this.m_mesh.vertices = this.m_vOriVert;
  1614. this.m_mesh.normals = this.m_vOriNorm;
  1615. if (this.m_vOriTan != null)
  1616. {
  1617. this.m_mesh.tangents = this.m_vOriTan;
  1618. }
  1619. }
  1620. public TBodySkin.OriVert m_OriVert;
  1621. private int TriCount;
  1622. private int BoneCount;
  1623. private int m_nSubMeshCount;
  1624. public Vector4[] m_vOriTan;
  1625. private Vector3[] m_vTmpVert;
  1626. private Vector3[] m_vTmpNorm;
  1627. private Vector4[] m_vTmpTan;
  1628. private TMorphSkin.CRC_FACE_TYPE m_crcFaceTypeNow;
  1629. public TMorph.IdxRatePair<float> m_HitomiShapeUp;
  1630. public TMorph.IdxRatePair<float> m_HitomiShapeLow;
  1631. public TMorph.IdxRatePair<float> m_HitomiShapeIn;
  1632. public TMorph.IdxRatePair<float> m_HitomiShapeOutUp;
  1633. public TMorph.IdxRatePair<float> m_HitomiShapeOutLow;
  1634. public TMorph.IdxRatePair<float> m_HohoShape;
  1635. public TMorph.IdxRatePair<float> m_Ha1;
  1636. public TMorph.IdxRatePair<float> m_Ha2;
  1637. public TMorph.IdxRatePair<float> m_Ha3;
  1638. public TMorph.IdxRatePair<float> m_Ha4;
  1639. public TMorph.IdxRatePair<float> m_Ha5;
  1640. public TMorph.IdxRatePair<float> m_Ha6;
  1641. private List<TMorph.IdxMinMaxRatePair> m_IdxMinMaxList;
  1642. private float m_LipSync1;
  1643. private float m_LipSync2;
  1644. private float m_LipSync3;
  1645. public int BlendDataIdx_HipSize;
  1646. public float[] BaseBlendValue_Kuikomi = new float[]
  1647. {
  1648. 1f,
  1649. 1f
  1650. };
  1651. public float ChikubiWearTotsu;
  1652. private SkinnedMeshRenderer smr_src;
  1653. private Transform[] m_bones;
  1654. private Transform tRoot;
  1655. private Mesh m_mesh;
  1656. private BoneWeight[] m_bws;
  1657. private Matrix4x4[] m_bindposes;
  1658. private float[] BlendValues;
  1659. private float[] BlendValuesTemp;
  1660. private float[] BlendValuesBackup;
  1661. private float[] BlendValuesCHK;
  1662. private string Category;
  1663. private TBody.SlotID SlotId;
  1664. private bool m_bIsBody;
  1665. private bool m_bMorph;
  1666. private bool m_isMan;
  1667. private Dictionary<int, List<TMorphSkin.BaseBlendValue>> m_baseBlendValues;
  1668. private string[] m_kuikomiMorphs = new string[]
  1669. {
  1670. "pantsa1",
  1671. "pantsa2",
  1672. "pantsa3",
  1673. "pantsb1",
  1674. "pantsb2",
  1675. "pantsb3",
  1676. "pantsc1",
  1677. "pantsc2",
  1678. "pantsc3",
  1679. "stkg1",
  1680. "stkg2",
  1681. "stkg3",
  1682. "stkg4",
  1683. "stkg5",
  1684. "stkg6",
  1685. "stkg7"
  1686. };
  1687. private string[] m_chikubiTotsuMorphs = new string[]
  1688. {
  1689. "chikubih",
  1690. "chikubik1",
  1691. "chikubik2",
  1692. "chikubik2_munes",
  1693. "chikubir",
  1694. "chikubiw",
  1695. "nyurin1",
  1696. "nyurin2",
  1697. "nyurin3",
  1698. "nyurin4",
  1699. "nyurin5",
  1700. "nyurin6",
  1701. "nyurin7",
  1702. "nyurin8"
  1703. };
  1704. private HashSet<int> m_chikubiTotsuMorphsIdx;
  1705. private bool m_bDut;
  1706. public enum CRC_FACE_TYPE
  1707. {
  1708. NORMAL,
  1709. TARE,
  1710. TSURI,
  1711. MAX
  1712. }
  1713. public class BaseBlendValue
  1714. {
  1715. public TMorphSkin.BaseBlendValue.Tag tag;
  1716. public TBody.SlotID parentSlotId;
  1717. public float defValue;
  1718. public enum Tag
  1719. {
  1720. パンツ,
  1721. 靴下,
  1722. MAX
  1723. }
  1724. }
  1725. }