1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public class TMorphSkin : TMorph
- {
- public TMorphSkin(TBodySkin bs, bool man)
- {
- this.bodyskin = bs;
- this.m_isMan = man;
- this.Category = bs.Category;
- this.SlotId = bs.SlotId;
- this.hash = new Hashtable();
- this.MorphCount = 0;
- this.BlendDatas = new List<BlendData>(20);
- this.BoneNames = new List<string>(200);
- this.BoneVisible = new List<bool>(200);
- }
- ~TMorphSkin()
- {
- this.DeleteObj();
- }
- public override BlendData this[string tag]
- {
- get
- {
- int index = (int)this.hash[tag];
- return this.BlendDatas[index];
- }
- }
- public override bool Contains(string name)
- {
- return this.hash.ContainsKey(name);
- }
- public override float GetBlendValues(int f_nIdx)
- {
- return this.BlendValues[f_nIdx];
- }
- public override void SetBlendValues(int f_nIdx, float f_fValue)
- {
- float[] blendValuesBackup = this.BlendValuesBackup;
- this.BlendValues[f_nIdx] = f_fValue;
- blendValuesBackup[f_nIdx] = f_fValue;
- }
- public override void DeleteObj()
- {
- foreach (KeyValuePair<string, TAttachPoint> keyValuePair in this.dicAttachPoint)
- {
- if (keyValuePair.Value.newAttachChild != null)
- {
- keyValuePair.Value.newAttachChild.ResetAttachPoint();
- }
- }
- this.m_baseBlendValues = null;
- this.m_chikubiTotsuMorphsIdx = null;
- this.bodyskin = null;
- this.m_mesh = null;
- this.smr_src = null;
- this.m_bones = null;
- this.m_vOriVert = null;
- this.m_vOriNorm = null;
- this.m_vOriTan = null;
- this.m_nSubMeshOriTri = null;
- this.m_bws = null;
- }
- public unsafe override void InitGameObject(GameObject o)
- {
- this.m_OriVert = this.bodyskin.m_OriVert;
- SkinnedMeshRenderer skinnedMeshRenderer = null;
- List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(3);
- o.GetComponentsInChildren<SkinnedMeshRenderer>(true, list);
- for (int i = 0; i < list.Count; i++)
- {
- skinnedMeshRenderer = list[i];
- }
- Transform[] bones = skinnedMeshRenderer.bones;
- Transform transform = o.transform;
- this.tRoot = transform;
- if (skinnedMeshRenderer == null)
- {
- Debug.LogError("err init morph " + o.name);
- this.initlp(this.tRoot);
- return;
- }
- this.smr_src = skinnedMeshRenderer;
- this.m_bones = bones;
- this.m_mesh = this.smr_src.sharedMesh;
- this.VCount = this.m_OriVert.VCount;
- this.m_vOriVert = this.m_OriVert.vOriVert;
- this.m_vOriNorm = this.m_OriVert.vOriNorm;
- this.m_vTmpVert = new Vector3[this.VCount];
- this.m_vTmpNorm = new Vector3[this.VCount];
- if (this.m_vOriTan != null)
- {
- this.m_vTmpTan = new Vector4[this.VCount];
- }
- this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
- this.m_vOriNorm.CopyTo(this.m_vTmpNorm, 0);
- if (this.m_vOriTan != null)
- {
- this.m_vOriTan.CopyTo(this.m_vTmpTan, 0);
- }
- this.m_nSubMeshCount = this.m_OriVert.nSubMeshCount;
- this.m_nSubMeshOriTri = this.m_OriVert.nSubMeshOriTri;
- this.m_nSubMeshTmpTri = new int[this.m_nSubMeshCount][];
- for (int j = 0; j < this.m_nSubMeshCount; j++)
- {
- int[] array = this.m_nSubMeshOriTri[j];
- this.m_nSubMeshTmpTri[j] = new int[array.Length];
- }
- this.BoneCount = this.m_bones.Length;
- this.initlp(this.tRoot);
- this.m_EarNoneData.rate = false;
- this.m_EarNoneData.idx = ((!this.hash.ContainsKey("earnone")) ? -1 : ((int)this.hash["earnone"]));
- this.m_EarElfData.rate = 0f;
- this.m_EarElfData.idx = ((!this.hash.ContainsKey("earelf")) ? -1 : ((int)this.hash["earelf"]));
- this.m_FaceShapeData.rate = 0f;
- this.m_FaceShapeData.idx = ((!this.hash.ContainsKey("shape")) ? -1 : ((int)this.hash["shape"]));
- this.m_FaceShapeSlimData.rate = 0f;
- this.m_FaceShapeSlimData.idx = ((!this.hash.ContainsKey("shapeslim")) ? -1 : ((int)this.hash["shapeslim"]));
- this.m_MayuShapeIn.rate = (this.m_MayuShapeOut.rate = 0f);
- this.m_MayuShapeIn.idx = ((!this.hash.ContainsKey("mayueditin")) ? -1 : ((int)this.hash["mayueditin"]));
- this.m_MayuShapeOut.idx = ((!this.hash.ContainsKey("mayueditout")) ? -1 : ((int)this.hash["mayueditout"]));
- if (this.bodyskin.SlotId == TBody.SlotID.head && 120 <= this.bodyskin.PartsVersion)
- {
- Action<string, TMorph.IdxMinMaxRatePair> action = delegate(string no, TMorph.IdxMinMaxRatePair idx)
- {
- bool flag = false;
- flag |= ((idx.idxDwL = ((!this.hash.ContainsKey("eyeeditl" + no + "_dw")) ? -1 : ((int)this.hash["eyeeditl" + no + "_dw"]))) == -1);
- flag |= ((idx.idxUpL = ((!this.hash.ContainsKey("eyeeditl" + no + "_up")) ? -1 : ((int)this.hash["eyeeditl" + no + "_up"]))) == -1);
- flag |= ((idx.idxDwR = ((!this.hash.ContainsKey("eyeeditr" + no + "_dw")) ? -1 : ((int)this.hash["eyeeditr" + no + "_dw"]))) == -1);
- flag |= ((idx.idxUpR = ((!this.hash.ContainsKey("eyeeditr" + no + "_up")) ? -1 : ((int)this.hash["eyeeditr" + no + "_up"]))) == -1);
- if (flag)
- {
- return;
- }
- idx.exec = delegate(float rateL, float rateR)
- {
- float num6 = Mathf.Clamp01((idx.rate - 0.5f) / -0.5f);
- float num7 = Mathf.Clamp01((idx.rate - 0.5f) / 0.5f);
- this.BlendValues[idx.idxDwL] = num6 * rateL;
- this.BlendValues[idx.idxDwR] = num6 * rateR;
- this.BlendValues[idx.idxUpL] = num7 * rateL;
- this.BlendValues[idx.idxUpR] = num7 * rateR;
- };
- if (this.m_IdxMinMaxList == null)
- {
- this.m_IdxMinMaxList = new List<TMorph.IdxMinMaxRatePair>();
- }
- this.m_IdxMinMaxList.Add(idx);
- };
- action("1", this.m_MabutaUpIn);
- action("2", this.m_MabutaUpIn2);
- action("3", this.m_MabutaUpMiddle);
- action("4", this.m_MabutaUpOut);
- action("5", this.m_MabutaUpOut2);
- action("6", this.m_MabutaLowUpOut);
- action("7", this.m_MabutaLowUpMiddle);
- action("8", this.m_MabutaLowIn);
- this.SetIdx<float>("irisedit1", out this.m_HitomiShapeUp, 0f);
- this.SetIdx<float>("irisedit2", out this.m_HitomiShapeLow, 0f);
- this.SetIdx<float>("irisedit3", out this.m_HitomiShapeIn, 0f);
- this.SetIdx<float>("irisedit4", out this.m_HitomiShapeOutUp, 0f);
- this.SetIdx<float>("irisedit5", out this.m_HitomiShapeOutLow, 0f);
- this.SetIdx<float>("shapehoho", out this.m_HohoShape, 0f);
- this.SetIdx<float>("ha1", out this.m_Ha1, 0f);
- this.SetIdx<float>("ha2", out this.m_Ha2, 0f);
- this.SetIdx<float>("ha3", out this.m_Ha3, 0f);
- this.SetIdx<float>("ha4", out this.m_Ha4, 0f);
- this.SetIdx<float>("ha5", out this.m_Ha5, 0f);
- this.SetIdx<float>("ha6", out this.m_Ha6, 0f);
- }
- this.m_fEyeCloseRate = 0f;
- this.BlendDataIdx_EyeClose = new int[][]
- {
- new int[10],
- new int[10],
- new int[10]
- };
- if (this.bodyskin.PartsVersion < 120)
- {
- if (this.hash.ContainsKey("eyeclose"))
- {
- this.BlendDataIdx_EyeClose[0][0] = (int)this.hash["eyeclose"];
- }
- for (int k = 1; k < 10; k++)
- {
- if (this.hash.ContainsKey("eyeclose" + k.ToString()))
- {
- this.BlendDataIdx_EyeClose[0][k] = (int)this.hash["eyeclose" + k.ToString()];
- }
- }
- if (!this.bodyskin.body.boMAN && this.Category == "head" && this.BlendDataIdx_EyeClose[0][0] == 0)
- {
- Debug.LogError("Face[eyeclose]");
- }
- }
- else if (this.m_isMan)
- {
- if (this.hash.ContainsKey("eyeclose"))
- {
- this.BlendDataIdx_EyeClose[0][0] = (int)this.hash["eyeclose"];
- }
- for (int l = 1; l < 10; l++)
- {
- if (this.hash.ContainsKey("eyeclose" + l.ToString()))
- {
- this.BlendDataIdx_EyeClose[0][l] = (int)this.hash["eyeclose" + l.ToString()];
- }
- }
- }
- else
- {
- for (int m = 0; m < 3; m++)
- {
- for (int n = 0; n < 10; n++)
- {
- if (this.hash.ContainsKey("eyeclose" + (n + 1).ToString() + TMorph.crcFaceTypesStr[m]))
- {
- this.BlendDataIdx_EyeClose[m][n] = (int)this.hash["eyeclose" + (n + 1).ToString() + TMorph.crcFaceTypesStr[m]];
- }
- }
- }
- }
- if (this.hash.ContainsKey("toothoff"))
- {
- this.BlendDataIdx_LipSyncTh = (int)this.hash["toothoff"];
- }
- if (this.hash.ContainsKey("moutha"))
- {
- this.BlendDataIdx_LipSync_A = (int)this.hash["moutha"];
- }
- if (this.hash.ContainsKey("mouths"))
- {
- this.BlendDataIdx_LipSync_S = (int)this.hash["mouths"];
- }
- if (this.hash.ContainsKey("mouthc"))
- {
- this.BlendDataIdx_LipSync_C = (int)this.hash["mouthc"];
- }
- if (this.hash.ContainsKey("toothoff"))
- {
- this.BlendDataIdx_LipSync_ToothOFF = (int)this.hash["toothoff"];
- }
- if (this.hash.ContainsKey("mouthdw"))
- {
- this.BlendDataIdx_LipSync_W = (int)this.hash["mouthdw"];
- }
- if (this.hash.ContainsKey("tear1"))
- {
- this.BlendDataIdx_Tear1 = (int)this.hash["tear1"];
- }
- if (this.hash.ContainsKey("tear2"))
- {
- this.BlendDataIdx_Tear2 = (int)this.hash["tear2"];
- }
- if (this.hash.ContainsKey("tear3"))
- {
- this.BlendDataIdx_Tear3 = (int)this.hash["tear3"];
- }
- if (this.hash.ContainsKey("nosefook"))
- {
- this.BlendDataIdx_NoseFook = (int)this.hash["nosefook"];
- }
- if (this.hash.ContainsKey("eyeclose"))
- {
- int count = this.BlendDatas.Count;
- this.hash["uru-uru"] = count;
- this.BlendDatas.Add(null);
- this.MorphCount++;
- }
- if (this.hash.ContainsKey("regfat"))
- {
- this.BlendDataIdx_RegFat = (int)this.hash["regfat"];
- }
- if (this.hash.ContainsKey("regmeet"))
- {
- this.BlendDataIdx_RegMeet = (int)this.hash["regmeet"];
- }
- if (this.hash.ContainsKey("hipsize"))
- {
- this.BlendDataIdx_HipSize = (int)this.hash["hipsize"];
- }
- foreach (string key in this.m_kuikomiMorphs)
- {
- if (this.hash.ContainsKey(key))
- {
- if (this.m_baseBlendValues == null)
- {
- this.m_baseBlendValues = new Dictionary<int, List<TMorphSkin.BaseBlendValue>>();
- }
- this.m_baseBlendValues.Add((int)this.hash[key], new List<TMorphSkin.BaseBlendValue>());
- }
- }
- foreach (string key2 in this.m_chikubiTotsuMorphs)
- {
- if (this.hash.ContainsKey(key2))
- {
- if (this.m_chikubiTotsuMorphsIdx == null)
- {
- this.m_chikubiTotsuMorphsIdx = new HashSet<int>();
- }
- this.m_chikubiTotsuMorphsIdx.Add((int)this.hash[key2]);
- }
- }
- this.ScrnV = new Vector3[this.VCount];
- this.WorldV = new Vector3[this.VCount];
- this.BindVert = new Vector3[this.VCount];
- this.DefVert = new Vector3[this.VCount];
- this.BindBone = new int[this.VCount];
- this.m_bindposes = this.m_mesh.bindposes;
- this.m_bws = this.m_OriVert.bwWeight;
- fixed (BoneWeight* ptr = &this.m_bws[0])
- {
- BoneWeight* ptr2 = ptr;
- for (int num3 = 0; num3 < this.VCount; num3++)
- {
- int num4 = ptr2->boneIndex0;
- float num5 = ptr2->weight0;
- if (ptr2->weight1 > num5)
- {
- num5 = ptr2->weight1;
- num4 = ptr2->boneIndex1;
- }
- if (ptr2->weight2 > num5)
- {
- num5 = ptr2->weight2;
- num4 = ptr2->boneIndex2;
- }
- if (ptr2->weight3 > num5)
- {
- num5 = ptr2->weight3;
- num4 = ptr2->boneIndex3;
- }
- this.BindBone[num3] = num4;
- Vector3 vector = this.m_bindposes[num4].MultiplyPoint3x4(this.m_vOriVert[num3]);
- this.BindVert[num3] = vector;
- this.DefVert[num3] = this.m_bones[num4].TransformPoint(vector);
- ptr2++;
- }
- }
- }
- private void SetIdx<T>(string name, out TMorph.IdxRatePair<T> idx, T initVal) where T : struct
- {
- idx.rate = initVal;
- idx.idx = ((!this.hash.ContainsKey(name)) ? -1 : ((int)this.hash[name]));
- }
- private void initlp(Transform t)
- {
- for (int i = 0; i < this.BoneCount; i++)
- {
- if (this.m_bones[i] != null)
- {
- this.BoneNames.Add(this.m_bones[i].name);
- this.BoneVisible.Add(true);
- }
- else
- {
- this.BoneNames.Add(string.Empty);
- this.BoneVisible.Add(false);
- }
- }
- this.m_bDut = false;
- }
- public override void ClearAllVisibleFlag(bool boSetFlag)
- {
- for (int i = 0; i < this.BoneCount; i++)
- {
- if (this.BoneVisible[i] != boSetFlag)
- {
- this.BoneVisible[i] = boSetFlag;
- this.m_bDut = true;
- }
- }
- }
- public override void SetVisibleFlag1(int idx, bool flag)
- {
- if (this.BoneVisible[idx] != flag)
- {
- this.BoneVisible[idx] = flag;
- this.m_bDut = true;
- }
- }
- public void VisibleVtxByPlane(Vector3Int plane, float pos)
- {
- if (this.smr_src == null)
- {
- return;
- }
- if (this.m_mesh == null)
- {
- return;
- }
- for (int i = 0; i < this.m_nSubMeshCount; i++)
- {
- this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
- int[] array = this.m_nSubMeshTmpTri[i];
- for (int j = 0; j < array.Length / 3; j++)
- {
- int num = 3;
- for (int k = 0; k < 3; k++)
- {
- int num2 = array[j * 3 + k];
- if (plane.x != 0)
- {
- if (plane.x < 0)
- {
- if (pos <= this.m_vOriVert[num2].x)
- {
- num--;
- }
- }
- else if (this.m_vOriVert[num2].x < pos)
- {
- num--;
- }
- }
- else if (plane.y != 0)
- {
- if (plane.y < 0)
- {
- if (pos <= this.m_vOriVert[num2].y)
- {
- num--;
- }
- }
- else if (this.m_vOriVert[num2].y < pos)
- {
- num--;
- }
- }
- else if (plane.z != 0)
- {
- if (plane.z < 0)
- {
- if (pos <= this.m_vOriVert[num2].z)
- {
- num--;
- }
- }
- else if (this.m_vOriVert[num2].z < pos)
- {
- num--;
- }
- }
- }
- if (num != 3)
- {
- for (int l = 0; l < 3; l++)
- {
- array[j * 3 + l] = 0;
- }
- }
- }
- this.m_nSubMeshTmpTri[i].CopyTo(this.m_nSubMeshOriTri[i], 0);
- this.m_mesh.SetTriangles(array, i);
- }
- }
- public void VisibleVtxByBonwWeight(List<int> boneVisibleIdxs)
- {
- if (this.smr_src == null)
- {
- return;
- }
- if (this.m_mesh == null)
- {
- return;
- }
- int[] array = new int[4];
- for (int i = 0; i < this.m_nSubMeshCount; i++)
- {
- this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
- int[] array2 = this.m_nSubMeshTmpTri[i];
- for (int j = 0; j < array2.Length / 3; j++)
- {
- int num = 3;
- for (int k = 0; k < 3; k++)
- {
- int num2 = array2[j * 3 + k];
- BoneWeight boneWeight = this.m_bws[num2];
- array[0] = ((boneWeight.weight0 <= 0f) ? -1 : boneWeight.boneIndex0);
- array[1] = ((boneWeight.weight1 <= 0f) ? -1 : boneWeight.boneIndex1);
- array[2] = ((boneWeight.weight2 <= 0f) ? -1 : boneWeight.boneIndex2);
- array[3] = ((boneWeight.weight3 <= 0f) ? -1 : boneWeight.boneIndex3);
- if (Array.FindIndex<int>(array, (int bi) => boneVisibleIdxs.FindIndex((int fi) => fi == bi) != -1) == -1)
- {
- num--;
- }
- }
- if (num != 3)
- {
- for (int l = 0; l < 3; l++)
- {
- array2[j * 3 + l] = 0;
- }
- }
- }
- this.m_nSubMeshTmpTri[i].CopyTo(this.m_nSubMeshOriTri[i], 0);
- this.m_mesh.SetTriangles(array2, i);
- }
- }
- public override void FixVisibleFlag()
- {
- if (this.smr_src == null)
- {
- return;
- }
- if (this.m_mesh == null)
- {
- return;
- }
- MaterialMgr materialMgr = this.bodyskin.MaterialMgr;
- this.m_bDut |= materialMgr.FixSkinMask();
- if (!this.m_bDut)
- {
- return;
- }
- Vector2[] vOriUV = this.m_OriVert.vOriUV;
- bool flag = vOriUV != null && this.SlotId == TBody.SlotID.body;
- for (int i = 0; i < this.m_nSubMeshCount; i++)
- {
- this.m_nSubMeshOriTri[i].CopyTo(this.m_nSubMeshTmpTri[i], 0);
- int[] array = this.m_nSubMeshTmpTri[i];
- for (int j = 0; j < array.Length / 3; j++)
- {
- int num = 3;
- for (int k = 0; k < 3; k++)
- {
- int num2 = array[j * 3 + k];
- if (flag && materialMgr.CheckSkinMaskUV(vOriUV[num2]))
- {
- num--;
- }
- else
- {
- BoneWeight boneWeight = this.m_bws[num2];
- if (!this.BoneVisible[boneWeight.boneIndex0])
- {
- num--;
- break;
- }
- if (!this.BoneVisible[boneWeight.boneIndex1] && boneWeight.weight1 > 0f)
- {
- num--;
- break;
- }
- if (!this.BoneVisible[boneWeight.boneIndex2] && boneWeight.weight2 > 0f)
- {
- num--;
- break;
- }
- if (!this.BoneVisible[boneWeight.boneIndex3] && boneWeight.weight3 > 0f)
- {
- num--;
- break;
- }
- }
- }
- if (num != 3)
- {
- for (int l = 0; l < 3; l++)
- {
- array[j * 3 + l] = 0;
- }
- }
- }
- this.m_mesh.SetTriangles(array, i);
- }
- this.m_bDut = false;
- }
- public override void LoadMoprhData2(BinaryReader r, int ver)
- {
- string text = r.ReadString();
- int count = this.BlendDatas.Count;
- this.hash[text] = count;
- BlendData blendData = new BlendData();
- blendData.name = text;
- int num = r.ReadInt32();
- blendData.vert = new Vector3[num];
- blendData.norm = new Vector3[num];
- blendData.v_index = new int[num];
- bool flag = false;
- if (2102 <= ver)
- {
- flag = r.ReadBoolean();
- }
- if (flag)
- {
- blendData.tans = new Vector4[num];
- }
- for (int i = 0; i < num; i++)
- {
- blendData.v_index[i] = (int)r.ReadUInt16();
- blendData.vert[i].x = r.ReadSingle();
- blendData.vert[i].y = r.ReadSingle();
- blendData.vert[i].z = r.ReadSingle();
- blendData.norm[i].x = r.ReadSingle();
- blendData.norm[i].y = r.ReadSingle();
- blendData.norm[i].z = r.ReadSingle();
- if (flag)
- {
- blendData.tans[i].x = r.ReadSingle();
- blendData.tans[i].y = r.ReadSingle();
- blendData.tans[i].z = r.ReadSingle();
- blendData.tans[i].w = r.ReadSingle();
- }
- }
- this.MorphCount++;
- this.BlendDatas.Add(blendData);
- this.BlendValues = new float[this.MorphCount + 1];
- this.BlendValuesTemp = new float[this.MorphCount + 1];
- this.BlendValuesBackup = new float[this.MorphCount + 1];
- this.BlendValuesCHK = new float[this.MorphCount + 1];
- }
- public override void NewBlendSet(string BlendSetName)
- {
- float[] array = new float[this.hash.Count];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = 0f;
- }
- if (this.dicBlendSet.ContainsKey(BlendSetName))
- {
- Debug.LogError("\u0093ブレンドセット" + BlendSetName);
- }
- this.dicBlendSet[BlendSetName] = array;
- this.dicBlendAtr[BlendSetName] = 0;
- if (!this.dicBlendSet.ContainsKey("オリジナル"))
- {
- float[] array2 = new float[this.hash.Count];
- for (int j = 0; j < array2.Length; j++)
- {
- array2[j] = 0f;
- }
- this.dicBlendSet["オリジナル"] = array2;
- }
- }
- public override void SetValueBlendSet(string BlendSetName, string tag, float val)
- {
- if (tag == "hoho2")
- {
- Dictionary<string, int> dicBlendAtr = this.dicBlendAtr;
- int value = (this.dicBlendAtr[BlendSetName] & -4) | 2;
- this.dicBlendAtr[BlendSetName] = value;
- dicBlendAtr[BlendSetName] = value;
- }
- if (tag == "hoho" && (this.dicBlendAtr[BlendSetName] & 3) != 1)
- {
- this.dicBlendAtr[BlendSetName] = ((this.dicBlendAtr[BlendSetName] & -4) | 1);
- }
- if (!this.dicBlendSet.ContainsKey(BlendSetName))
- {
- Debug.LogError("表情がありません。" + BlendSetName);
- return;
- }
- if (tag.Contains("*"))
- {
- for (int i = 0; i < 3; i++)
- {
- string text = tag.Replace("*", TMorph.crcFaceTypesStr[i]);
- if (!this.hash.Contains(text))
- {
- Debug.LogError("表情がありません。tag=" + text);
- }
- else
- {
- int num = (int)this.hash[text];
- if (text == "hoho2")
- {
- this.IdxHOHO2 = num;
- }
- if (text == "hoho")
- {
- this.IdxHOHO = num;
- }
- this.dicBlendSet[BlendSetName][num] = val * 0.01f;
- }
- }
- }
- else
- {
- if (!this.hash.Contains(tag))
- {
- Debug.LogError("表情がありません。tag=" + tag);
- return;
- }
- int num2 = (int)this.hash[tag];
- if (tag == "hoho2")
- {
- this.IdxHOHO2 = num2;
- }
- if (tag == "hoho")
- {
- this.IdxHOHO = num2;
- }
- this.dicBlendSet[BlendSetName][num2] = val * 0.01f;
- }
- }
- public override void SetBlendSetValueOriginal(TMorph.AddBlendType add_blend_type_flag)
- {
- float[] array = this.dicBlendSet["オリジナル"];
- array[(int)this.hash["hohol"]] = (array[(int)this.hash["hoho"]] = (array[(int)this.hash["hohos"]] = 0f));
- if ((add_blend_type_flag & TMorph.AddBlendType.Cheek3) == TMorph.AddBlendType.Cheek3)
- {
- array[(int)this.hash["hohol"]] = 1f;
- }
- else if ((add_blend_type_flag & TMorph.AddBlendType.Cheek2) == TMorph.AddBlendType.Cheek2)
- {
- array[(int)this.hash["hoho"]] = 1f;
- }
- else if ((add_blend_type_flag & TMorph.AddBlendType.Cheek1) == TMorph.AddBlendType.Cheek1)
- {
- array[(int)this.hash["hohos"]] = 1f;
- }
- array[(int)this.hash["tear3"]] = (array[(int)this.hash["tear2"]] = (array[(int)this.hash["tear1"]] = 0f));
- if ((add_blend_type_flag & TMorph.AddBlendType.Tear3) == TMorph.AddBlendType.Tear3)
- {
- array[(int)this.hash["tear3"]] = 1f;
- }
- else if ((add_blend_type_flag & TMorph.AddBlendType.Tear2) == TMorph.AddBlendType.Tear2)
- {
- array[(int)this.hash["tear2"]] = 1f;
- }
- else if ((add_blend_type_flag & TMorph.AddBlendType.Tear1) == TMorph.AddBlendType.Tear1)
- {
- array[(int)this.hash["tear1"]] = 1f;
- }
- array[(int)this.hash["hoho2"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Blush) != TMorph.AddBlendType.Blush) ? 0 : 1);
- array[(int)this.hash["namida"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.TearBig) != TMorph.AddBlendType.TearBig) ? 0 : 1);
- array[(int)this.hash["yodare"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Yodare) != TMorph.AddBlendType.Yodare) ? 0 : 1);
- array[(int)this.hash["shock"]] = (float)(((add_blend_type_flag & TMorph.AddBlendType.Shock) != TMorph.AddBlendType.Shock) ? 0 : 1);
- }
- public override void MulBlendSetValues(string BlendSetName, float mul = 1f)
- {
- if (this.dicBlendSet.ContainsKey(BlendSetName))
- {
- float[] array = this.dicBlendSet[BlendSetName];
- for (int i = 0; i < this.MorphCount; i++)
- {
- this.BlendValuesBackup[i] = (this.BlendValues[i] = this.BlendValues[i] * (1f - mul) + array[i] * mul);
- }
- return;
- }
- if (BlendSetName == "頬0涙0")
- {
- return;
- }
- Debug.LogError("表情がありません。" + BlendSetName);
- }
- public override void AddBlendSetValues(string BlendSetName, float add = 1f)
- {
- if (this.dicBlendSet.ContainsKey(BlendSetName))
- {
- float[] array = this.dicBlendSet[BlendSetName];
- for (int i = 0; i < this.MorphCount; i++)
- {
- this.BlendValues[i] += array[i] * add;
- if (this.BlendValues[i] > 1f)
- {
- this.BlendValues[i] = 1f;
- }
- this.BlendValuesBackup[i] = this.BlendValues[i];
- }
- return;
- }
- if (BlendSetName == "頬0涙0")
- {
- return;
- }
- Debug.LogError("表情がありません。" + BlendSetName);
- }
- public override void ClearBlendValues()
- {
- for (int i = 0; i < this.MorphCount; i++)
- {
- this.BlendValuesBackup[i] = (this.BlendValues[i] = 0f);
- }
- }
- public TMorphSkin.CRC_FACE_TYPE GetFaceTypeCRC()
- {
- float num = this.m_MabutaUpOut2.rate - 0.5f;
- float num2 = Mathf.Clamp01(num / -0.5f);
- float num3 = Mathf.Clamp01(num / 0.5f);
- if (num2 < 0.35f && num3 < 0.35f)
- {
- return TMorphSkin.CRC_FACE_TYPE.NORMAL;
- }
- if (0.35f <= num2)
- {
- return TMorphSkin.CRC_FACE_TYPE.TARE;
- }
- if (0.35f <= num3)
- {
- return TMorphSkin.CRC_FACE_TYPE.TSURI;
- }
- return TMorphSkin.CRC_FACE_TYPE.MAX;
- }
- public override void FixBlendValues_Face()
- {
- if (!this.m_isMan && 120 <= this.bodyskin.PartsVersion)
- {
- this.m_crcFaceTypeNow = this.GetFaceTypeCRC();
- for (int i = 0; i < 3; i++)
- {
- if (i != (int)this.m_crcFaceTypeNow)
- {
- int[] array = this.BlendDataIdx_EyeClose[i];
- for (int j = 0; j < array.Length; j++)
- {
- this.BlendValues[array[j]] = 0f;
- }
- }
- }
- }
- int[] array2 = this.BlendDataIdx_EyeClose[(int)this.m_crcFaceTypeNow];
- this.BlendValuesTemp[array2[0]] = this.m_fEyeCloseRate + this.BlendValuesBackup[array2[0]] * (1f - this.m_fEyeCloseRate);
- for (int k = 1; k < 10; k++)
- {
- if (array2[k] != 0)
- {
- this.BlendValuesTemp[array2[k]] = this.BlendValuesBackup[array2[k]] * (1f - this.m_fEyeCloseRate);
- }
- }
- if (0f < this.EyeMabataki)
- {
- float num = 0f;
- for (int l = 0; l < 10; l++)
- {
- if (array2[l] != 0)
- {
- num += this.BlendValuesTemp[array2[l]];
- }
- }
- if (num > 1f)
- {
- num = 1f;
- }
- float num2 = 1f - num;
- float num3 = this.BlendValuesTemp[array2[0]] + num2 * this.EyeMabataki;
- if (num3 > 0f)
- {
- this.BlendValuesTemp[array2[0]] = num3;
- }
- }
- for (int m = 0; m < 10; m++)
- {
- if (array2[m] != 0)
- {
- this.BlendValues[array2[m]] = this.BlendValuesTemp[array2[m]];
- }
- }
- if (this.m_EarNoneData.idx != -1)
- {
- this.BlendValues[this.m_EarNoneData.idx] = (float)((!this.m_EarNoneData.rate) ? 0 : 1);
- }
- if (this.m_EarElfData.idx != -1 && !this.m_EarNoneData.rate)
- {
- this.BlendValues[this.m_EarElfData.idx] = this.m_EarElfData.rate;
- }
- if (this.m_FaceShapeData.idx != -1)
- {
- this.BlendValues[this.m_FaceShapeData.idx] = this.m_FaceShapeData.rate;
- }
- if (this.m_FaceShapeSlimData.idx != -1)
- {
- this.BlendValues[this.m_FaceShapeSlimData.idx] = this.m_FaceShapeSlimData.rate;
- }
- if (this.m_MayuShapeIn.idx != -1)
- {
- this.BlendValues[this.m_MayuShapeIn.idx] = this.m_MayuShapeIn.rate;
- }
- if (this.m_MayuShapeOut.idx != -1)
- {
- this.BlendValues[this.m_MayuShapeOut.idx] = this.m_MayuShapeOut.rate;
- }
- if (120 <= this.bodyskin.PartsVersion && this.m_IdxMinMaxList != null)
- {
- float arg = 1f - Mathf.Clamp01(this.BlendValues[array2[0]] + this.BlendValues[array2[1]] + this.BlendValues[array2[4]] + this.BlendValues[array2[5]]);
- float arg2 = 1f - Mathf.Clamp01(this.BlendValues[array2[0]] + this.BlendValues[array2[1]] + this.BlendValues[array2[6]] + this.BlendValues[array2[7]]);
- foreach (TMorph.IdxMinMaxRatePair idxMinMaxRatePair in this.m_IdxMinMaxList)
- {
- if (idxMinMaxRatePair.exec != null)
- {
- idxMinMaxRatePair.exec(arg, arg2);
- }
- }
- }
- if (this.m_HitomiShapeUp.idx != -1)
- {
- this.BlendValues[this.m_HitomiShapeUp.idx] = this.m_HitomiShapeUp.rate;
- }
- if (this.m_HitomiShapeLow.idx != -1)
- {
- this.BlendValues[this.m_HitomiShapeLow.idx] = this.m_HitomiShapeLow.rate;
- }
- if (this.m_HitomiShapeIn.idx != -1)
- {
- this.BlendValues[this.m_HitomiShapeIn.idx] = this.m_HitomiShapeIn.rate;
- }
- if (this.m_HitomiShapeOutUp.idx != -1)
- {
- this.BlendValues[this.m_HitomiShapeOutUp.idx] = this.m_HitomiShapeOutUp.rate;
- }
- if (this.m_HitomiShapeOutLow.idx != -1)
- {
- this.BlendValues[this.m_HitomiShapeOutLow.idx] = this.m_HitomiShapeOutLow.rate;
- }
- if (this.m_HohoShape.idx != -1)
- {
- this.BlendValues[this.m_HohoShape.idx] = this.m_HohoShape.rate;
- }
- if (this.m_Ha1.idx != -1)
- {
- this.BlendValues[this.m_Ha1.idx] = this.m_Ha1.rate;
- }
- if (this.m_Ha2.idx != -1)
- {
- this.BlendValues[this.m_Ha2.idx] = this.m_Ha2.rate;
- }
- if (this.m_Ha3.idx != -1)
- {
- this.BlendValues[this.m_Ha3.idx] = this.m_Ha3.rate;
- }
- if (this.m_Ha4.idx != -1)
- {
- this.BlendValues[this.m_Ha4.idx] = this.m_Ha4.rate;
- }
- if (this.m_Ha5.idx != -1)
- {
- this.BlendValues[this.m_Ha5.idx] = this.m_Ha5.rate;
- }
- if (this.m_Ha6.idx != -1)
- {
- this.BlendValues[this.m_Ha6.idx] = this.m_Ha6.rate;
- }
- if (this.boLipSync)
- {
- this.BlendValues[this.BlendDataIdx_LipSync_A] = base.LipSync1 * 0.8f;
- this.BlendValues[this.BlendDataIdx_LipSync_C] = base.LipSync3 * 0.7f;
- this.BlendValues[this.BlendDataIdx_LipSync_ToothOFF] = base.LipSync3;
- this.BlendValues[this.BlendDataIdx_LipSync_S] = base.LipSync2 * (1f - base.LipSync1) * 0.5f;
- this.BlendValues[this.BlendDataIdx_LipSync_W] = base.LipSync2 * 0.3f;
- this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0.5f;
- }
- if (this.boLookTooth)
- {
- this.BlendValues[this.BlendDataIdx_LipSync_A] = 0f;
- this.BlendValues[this.BlendDataIdx_LipSync_S] = 0.7f;
- this.BlendValues[this.BlendDataIdx_LipSync_C] = 0f;
- this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0f;
- }
- if (this.boBallGAG)
- {
- this.BlendValues[this.BlendDataIdx_LipSync_A] = 1f;
- this.BlendValues[this.BlendDataIdx_LipSync_S] = 0f;
- this.BlendValues[this.BlendDataIdx_LipSync_C] = 0f;
- this.BlendValues[this.BlendDataIdx_LipSyncTh] = 0f;
- }
- float num4 = this.BlendValues[this.BlendDataIdx_Tear3];
- if (this.BlendValues[this.BlendDataIdx_Tear2] + num4 > 1f)
- {
- this.BlendValues[this.BlendDataIdx_Tear2] = 1f - num4;
- num4 = 1f;
- }
- else
- {
- num4 += this.BlendValues[this.BlendDataIdx_Tear2];
- }
- if (this.BlendValues[this.BlendDataIdx_Tear1] + num4 > 1f)
- {
- this.BlendValues[this.BlendDataIdx_Tear1] = 1f - num4;
- }
- if (this.boNoseFook)
- {
- this.BlendValues[this.BlendDataIdx_NoseFook] = 1f;
- }
- else
- {
- this.BlendValues[this.BlendDataIdx_NoseFook] = 0f;
- }
- int num5 = 0;
- for (int n = 0; n < this.MorphCount; n++)
- {
- if (this.BlendValuesCHK[n] != this.BlendValues[n])
- {
- num5++;
- this.BlendValuesCHK[n] = this.BlendValues[n];
- }
- }
- if (num5 == 0)
- {
- return;
- }
- this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
- this.m_bMorph = true;
- if (this.BlendValues[this.IdxHOHO] < 0.5f)
- {
- this.BlendValues[this.IdxHOHO] = 0f;
- }
- else
- {
- this.BlendValues[this.IdxHOHO] = 1f;
- }
- if (this.BlendValues[this.IdxHOHO2] < 0.5f)
- {
- this.BlendValues[this.IdxHOHO2] = 0f;
- }
- else
- {
- this.BlendValues[this.IdxHOHO2] = 1f;
- }
- for (int num6 = 0; num6 < this.MorphCount; num6++)
- {
- if (this.BlendDatas[num6] == null)
- {
- this.UruUruScaleX = this.BlendValues[num6];
- }
- else
- {
- float num7 = this.BlendValues[num6];
- if (num7 >= 0.01f || num6 == this.m_MayuShapeIn.idx || num6 == this.m_MayuShapeOut.idx)
- {
- int num8 = this.BlendDatas[num6].v_index.Length;
- for (int num9 = 0; num9 < num8; num9++)
- {
- int num10 = this.BlendDatas[num6].v_index[num9];
- this.m_vTmpVert[num10] += this.BlendDatas[num6].vert[num9] * num7;
- }
- }
- }
- }
- this.m_mesh.vertices = this.m_vTmpVert;
- foreach (TAttachPoint tattachPoint in this.dicAttachPoint.Values)
- {
- int vidx = tattachPoint.vidx;
- Vector3 vector = Vector3.zero;
- vector += this.m_bindposes[tattachPoint.bw.boneIndex0].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight0;
- vector += this.m_bindposes[tattachPoint.bw.boneIndex1].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight1;
- vector += this.m_bindposes[tattachPoint.bw.boneIndex2].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight2;
- vector += this.m_bindposes[tattachPoint.bw.boneIndex3].MultiplyPoint3x4(this.m_vTmpVert[vidx]) * tattachPoint.bw.weight3;
- this.BindVert[vidx] = vector;
- }
- }
- public override void FixBlendValues()
- {
- if (this.m_baseBlendValues != null)
- {
- foreach (KeyValuePair<int, List<TMorphSkin.BaseBlendValue>> keyValuePair in this.m_baseBlendValues)
- {
- this.SetBlendValues(keyValuePair.Key, 0f);
- foreach (TMorphSkin.BaseBlendValue baseBlendValue in keyValuePair.Value)
- {
- TBodySkin slot = this.bodyskin.body.GetSlot((int)baseBlendValue.parentSlotId);
- if (slot.boVisible)
- {
- this.SetBlendValues(keyValuePair.Key, baseBlendValue.defValue * this.BaseBlendValue_Kuikomi[(int)baseBlendValue.tag]);
- }
- }
- }
- }
- if (this.m_chikubiTotsuMorphsIdx != null)
- {
- TBodySkin.CHIKUBI_STATE chikubi_STATE = this.bodyskin.body.IsChikubiState();
- foreach (int num in this.m_chikubiTotsuMorphsIdx)
- {
- this.BlendValues[num] = this.BlendValuesBackup[num];
- if (chikubi_STATE == TBodySkin.CHIKUBI_STATE.固定凸)
- {
- this.BlendValues[num] = this.BlendValuesBackup[num] * 1f;
- }
- else if (chikubi_STATE == TBodySkin.CHIKUBI_STATE.基本凹)
- {
- this.BlendValues[num] = this.BlendValuesBackup[num] * this.ChikubiWearTotsu;
- }
- }
- }
- int num2 = 0;
- for (int i = 0; i < this.MorphCount; i++)
- {
- if (this.BlendValuesCHK[i] != this.BlendValues[i])
- {
- num2++;
- this.BlendValuesCHK[i] = this.BlendValues[i];
- }
- }
- if (num2 == 0)
- {
- return;
- }
- this.m_vOriVert.CopyTo(this.m_vTmpVert, 0);
- this.m_vOriNorm.CopyTo(this.m_vTmpNorm, 0);
- if (this.m_vOriTan != null)
- {
- this.m_vOriTan.CopyTo(this.m_vTmpTan, 0);
- }
- this.m_bMorph = true;
- for (int j = 0; j < this.MorphCount; j++)
- {
- if (this.BlendDatas[j] == null)
- {
- this.UruUruScaleX = this.BlendValues[j];
- }
- else
- {
- float num3 = this.BlendValues[j];
- if (num3 >= 0.01f || j == this.m_MayuShapeIn.idx || j == this.m_MayuShapeOut.idx)
- {
- int num4 = this.BlendDatas[j].v_index.Length;
- for (int k = 0; k < num4; k++)
- {
- int num5 = this.BlendDatas[j].v_index[k];
- this.m_vTmpVert[num5] += this.BlendDatas[j].vert[k] * num3;
- this.m_vTmpNorm[num5] += this.BlendDatas[j].norm[k] * num3;
- }
- }
- }
- }
- this.m_mesh.vertices = this.m_vTmpVert;
- this.m_mesh.normals = this.m_vTmpNorm;
- this.m_mesh.tangents = this.m_vTmpTan;
- foreach (TAttachPoint tattachPoint in this.dicAttachPoint.Values)
- {
- int vidx = tattachPoint.vidx;
- this.BindVert[vidx] = this.m_bindposes[tattachPoint.bw.boneIndex0].MultiplyPoint3x4(this.m_vTmpVert[vidx]);
- }
- }
- public override void ResetBlendValues()
- {
- if (this.m_bMorph)
- {
- this.m_mesh.vertices = this.m_vTmpVert;
- this.m_mesh.normals = this.m_vTmpNorm;
- this.m_mesh.tangents = this.m_vTmpTan;
- }
- }
- public void AddBaseBlendValue(TBody.SlotID parentSlotId, TMorphSkin.BaseBlendValue.Tag tag, string blendName, float defValue)
- {
- blendName = blendName.ToLower();
- if (this.m_baseBlendValues == null || !this.hash.ContainsKey(blendName))
- {
- return;
- }
- int key = (int)this.hash[blendName];
- List<TMorphSkin.BaseBlendValue> list;
- if (!this.m_baseBlendValues.TryGetValue(key, out list))
- {
- List<TMorphSkin.BaseBlendValue> list2 = new List<TMorphSkin.BaseBlendValue>();
- this.m_baseBlendValues[key] = list2;
- list = list2;
- }
- list.Add(new TMorphSkin.BaseBlendValue
- {
- tag = tag,
- parentSlotId = parentSlotId,
- defValue = defValue
- });
- }
- public void RemoveBaseBlendValue(TBody.SlotID parentSlotId)
- {
- if (this.m_baseBlendValues == null)
- {
- return;
- }
- foreach (KeyValuePair<int, List<TMorphSkin.BaseBlendValue>> keyValuePair in this.m_baseBlendValues)
- {
- keyValuePair.Value.RemoveAll((TMorphSkin.BaseBlendValue a) => a.parentSlotId == parentSlotId);
- }
- }
- public bool IsUseBaseBlendValue(TMorphSkin.BaseBlendValue.Tag tag)
- {
- if (this.m_baseBlendValues == null || this.m_baseBlendValues.Count == 0)
- {
- return false;
- }
- List<List<TMorphSkin.BaseBlendValue>> list = new List<List<TMorphSkin.BaseBlendValue>>(this.m_baseBlendValues.Values);
- return list.Find((List<TMorphSkin.BaseBlendValue> a) => a.Find((TMorphSkin.BaseBlendValue b) => b.tag == tag) != null) != null;
- }
- public TAttachPoint AddNewAttachPoint(TBodySkin childTbskin, string apname)
- {
- this.RemoveNewAttachPoint(apname);
- TAttachPoint tattachPoint = null;
- if (!this.dicAttachPoint.TryGetValue(apname, out tattachPoint))
- {
- TAttachPoint tattachPoint2 = new TAttachPoint();
- this.dicAttachPoint[apname] = tattachPoint2;
- tattachPoint = tattachPoint2;
- }
- tattachPoint.newAttachChild = childTbskin;
- tattachPoint.newAttachPoint = true;
- return tattachPoint;
- }
- public bool RemoveNewAttachPoint(string apname)
- {
- TAttachPoint tattachPoint = null;
- return this.dicAttachPoint.TryGetValue(apname, out tattachPoint) && tattachPoint.newAttachPoint && this.dicAttachPoint.Remove(apname);
- }
- public TAttachPoint GetAttachPoint(string apname)
- {
- TAttachPoint result = null;
- this.dicAttachPoint.TryGetValue(apname, out result);
- return result;
- }
- public override void SetEnableAttachPointEdit(bool f_bEnable, string f_strApName)
- {
- TAttachPoint tattachPoint = this.dicAttachPoint[f_strApName];
- if (tattachPoint.bEditable == f_bEnable)
- {
- return;
- }
- int num = tattachPoint.srcvidx;
- Vector3 vector = Vector3.zero;
- Vector3 vector2 = Vector3.one;
- Quaternion quaternion = tattachPoint.qSrc;
- VtxAttachPos attachPointPos = this.bodyskin.body.maid.GetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, f_strApName);
- if (attachPointPos != null)
- {
- num = attachPointPos.vidx;
- vector = attachPointPos.prs.position;
- quaternion = attachPointPos.prs.rotation;
- vector2 = attachPointPos.prs.scale;
- }
- if (f_bEnable)
- {
- tattachPoint.vidx = num;
- tattachPoint.vOffsLocal = vector;
- tattachPoint.qNow = quaternion;
- tattachPoint.vScaleRate = vector2;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- }
- else
- {
- tattachPoint.vidx = tattachPoint.srcvidx;
- tattachPoint.vOffsLocal = Vector3.zero;
- tattachPoint.qNow = tattachPoint.qSrc;
- tattachPoint.vScaleRate = Vector3.one;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- }
- tattachPoint.bEditable = f_bEnable;
- this.bodyskin.body.maid.SetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, f_strApName, num, vector, quaternion, vector2, tattachPoint.bEditable);
- }
- public override bool GetEnableAttachPointEdit(string f_strApName)
- {
- return this.dicAttachPoint[f_strApName].bEditable;
- }
- public override void SetAttachPoint(string apname, Vector3 vc, Quaternion q, bool f_bTemp)
- {
- TAttachPoint tattachPoint = new TAttachPoint();
- float num = (vc - this.DefVert[0]).sqrMagnitude;
- int num2 = 0;
- for (int i = 0; i < this.m_vOriVert.Length; i++)
- {
- float sqrMagnitude = (vc - this.DefVert[i]).sqrMagnitude;
- if (num > sqrMagnitude)
- {
- num = sqrMagnitude;
- num2 = i;
- }
- }
- tattachPoint.srcvidx = (tattachPoint.vidx = num2);
- tattachPoint.vOffsLocal = Vector3.zero;
- TAttachPoint tattachPoint2 = tattachPoint;
- tattachPoint.qNow = q;
- tattachPoint2.qSrc = q;
- tattachPoint.vScaleRate = Vector3.one;
- tattachPoint.bw = this.m_bws[num2];
- this.dicAttachPoint[apname] = tattachPoint;
- if (!f_bTemp)
- {
- VtxAttachPos attachPointPos = this.bodyskin.body.maid.GetAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, this.m_vOriVert.Length, apname);
- if (attachPointPos != null && attachPointPos.bEnable)
- {
- tattachPoint.vidx = attachPointPos.vidx;
- tattachPoint.vOffsLocal = attachPointPos.prs.position;
- tattachPoint.qNow = attachPointPos.prs.rotation;
- tattachPoint.vScaleRate = attachPointPos.prs.scale;
- tattachPoint.bEditable = true;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- }
- }
- }
- public override void SetAttachPointOffsetLocal(string apname, VtxAttachPos f_vap)
- {
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- tattachPoint.vidx = f_vap.vidx;
- tattachPoint.vOffsLocal = f_vap.prs.position;
- tattachPoint.qNow = f_vap.prs.rotation;
- tattachPoint.vScaleRate = f_vap.prs.scale;
- tattachPoint.bEditable = true;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- }
- public override bool CopyAttachObjPoint(string apname)
- {
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- TMorph.TempAttachPos tempAttachPos = new TMorph.TempAttachPos();
- tempAttachPos.m_nVidx = tattachPoint.vidx;
- tempAttachPos.m_vPos = tattachPoint.vOffsLocal;
- tempAttachPos.m_qRot = tattachPoint.qNow;
- tempAttachPos.m_vScale = tattachPoint.vScaleRate;
- this.bodyskin.m_dicTempAttachPoint[apname] = tempAttachPos;
- return true;
- }
- public override bool PastAttachObjPoint(string apname)
- {
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- TMorph.TempAttachPos tempAttachPos = null;
- if (this.bodyskin.m_dicTempAttachPoint.TryGetValue(apname, out tempAttachPos))
- {
- tattachPoint.bEditable = true;
- tattachPoint.vidx = tempAttachPos.m_nVidx;
- tattachPoint.vOffsLocal = tempAttachPos.m_vPos;
- tattachPoint.qNow = tempAttachPos.m_qRot;
- tattachPoint.vScaleRate = tempAttachPos.m_vScale;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- }
- 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);
- return true;
- }
- public override void SetAttachPointWorld(string apname, Vector3 vWorldPos, Quaternion qWorldRot, Vector3 vScaleRate)
- {
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- if (!tattachPoint.bEditable)
- {
- return;
- }
- this.ReclucPointWorldAndScreen(null);
- int vidx = tattachPoint.vidx;
- float num = (this.WorldV[vidx] - vWorldPos).sqrMagnitude;
- int num2 = vidx;
- for (int i = 0; i < this.m_vOriVert.Length; i++)
- {
- float sqrMagnitude = (this.WorldV[i] - vWorldPos).sqrMagnitude;
- if (sqrMagnitude < num)
- {
- num = sqrMagnitude;
- num2 = i;
- }
- }
- tattachPoint.vidx = num2;
- tattachPoint.bw = this.m_bws[num2];
- int num3 = this.BindBone[num2];
- Transform transform = this.m_bones[num3].transform;
- Vector3 vector = Vector3.zero;
- if (this.SlotId == TBody.SlotID.body)
- {
- this.CalcVertexPoint(ref vector, num2, ref tattachPoint.bw);
- }
- else
- {
- vector = this.BindVert[num2];
- vector = transform.TransformPoint(vector);
- tattachPoint.vOffsLocal = transform.InverseTransformPoint(vWorldPos) - transform.InverseTransformPoint(vector);
- }
- tattachPoint.qNow = Quaternion.Inverse(transform.transform.rotation) * qWorldRot;
- tattachPoint.vScaleRate = vScaleRate;
- this.dicAttachPoint[apname] = tattachPoint;
- 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);
- Debug.DrawLine(vector, vWorldPos, Color.cyan);
- }
- public override bool GetAttachPoint(string apname, out Vector3 vWorldPos, out Quaternion qWorldRot, out Vector3 vScaleRate, bool f_bTemp = false)
- {
- if (!this.dicAttachPoint.ContainsKey(apname))
- {
- vWorldPos = Vector3.zero;
- qWorldRot = Quaternion.identity;
- vScaleRate = Vector3.one;
- return false;
- }
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- Vector3 vector = Vector3.zero;
- int num = tattachPoint.vidx;
- if (f_bTemp)
- {
- num = tattachPoint.srcvidx;
- }
- Transform transform = this.m_bones[this.BindBone[num]].transform;
- if (this.SlotId == TBody.SlotID.body)
- {
- this.CalcVertexPoint(ref vector, num, ref tattachPoint.bw);
- }
- else
- {
- if (!f_bTemp)
- {
- vector = tattachPoint.vOffsLocal;
- }
- vector += this.BindVert[num];
- vector = transform.TransformPoint(vector);
- }
- vWorldPos = vector;
- if (f_bTemp)
- {
- qWorldRot = transform.rotation * tattachPoint.qSrc;
- vScaleRate = Vector3.one;
- }
- else
- {
- qWorldRot = transform.rotation * tattachPoint.qNow;
- vScaleRate = tattachPoint.vScaleRate;
- }
- return true;
- }
- public override bool ResetAttachPoint(string apname)
- {
- if (!this.dicAttachPoint.ContainsKey(apname))
- {
- Debug.LogError("アタッチポイント " + apname + " はありません。");
- return false;
- }
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- tattachPoint.vidx = tattachPoint.srcvidx;
- tattachPoint.vOffsLocal = Vector3.zero;
- tattachPoint.qNow = tattachPoint.qSrc;
- tattachPoint.vScaleRate = Vector3.one;
- tattachPoint.bw = this.m_bws[tattachPoint.vidx];
- this.bodyskin.body.maid.ClearAttachPointPos(this.bodyskin.m_ParentMPN, this.bodyskin.SlotId, apname);
- return true;
- }
- public override void ReclucPointWorldAndScreen(Camera cam = null)
- {
- bool flag = cam != null;
- for (int i = 0; i < this.VCount; i++)
- {
- BoneWeight boneWeight = this.m_bws[i];
- Vector3 zero = Vector3.zero;
- this.CalcVertexPoint(ref zero, i, ref boneWeight);
- this.WorldV[i] = zero;
- if (flag)
- {
- this.ScrnV[i] = cam.WorldToScreenPoint(zero);
- }
- }
- }
- private void CalcVertexPoint(ref Vector3 vPosLocalToWorld, int nVtx, ref BoneWeight bw)
- {
- vPosLocalToWorld += this.m_bones[bw.boneIndex0].transform.TransformPoint(this.m_bindposes[bw.boneIndex0].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight0;
- if (bw.weight1 != 0f)
- {
- vPosLocalToWorld += this.m_bones[bw.boneIndex1].TransformPoint(this.m_bindposes[bw.boneIndex1].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight1;
- }
- if (bw.weight2 != 0f)
- {
- vPosLocalToWorld += this.m_bones[bw.boneIndex2].TransformPoint(this.m_bindposes[bw.boneIndex2].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight2;
- }
- if (bw.weight3 != 0f)
- {
- vPosLocalToWorld += this.m_bones[bw.boneIndex3].TransformPoint(this.m_bindposes[bw.boneIndex3].MultiplyPoint(this.m_vTmpVert[nVtx])) * bw.weight3;
- }
- }
- private Vector3 CalcVertexPointWorldToLocal(Vector3 vWorld, int nVtx, ref BoneWeight bw)
- {
- Vector3 vector = Vector3.zero;
- vector += this.m_bones[bw.boneIndex0].transform.InverseTransformPoint(vWorld) * bw.weight0;
- if (bw.weight1 != 0f)
- {
- vector += this.m_bones[bw.boneIndex1].InverseTransformPoint(vWorld) * bw.weight1;
- }
- if (bw.weight2 != 0f)
- {
- vector += this.m_bones[bw.boneIndex2].InverseTransformPoint(vWorld) * bw.weight2;
- }
- if (bw.weight3 != 0f)
- {
- vector += this.m_bones[bw.boneIndex3].InverseTransformPoint(vWorld) * bw.weight3;
- }
- return vector;
- }
- private Vector3 CalcVertexPointLocalToWorld(Vector3 vLocal, int nVtx, ref BoneWeight bw)
- {
- Vector3 vector = Vector3.zero;
- vector += this.m_bones[bw.boneIndex0].transform.TransformPoint(vLocal) * bw.weight0;
- if (bw.weight1 != 0f)
- {
- vector += this.m_bones[bw.boneIndex1].TransformPoint(vLocal) * bw.weight1;
- }
- if (bw.weight2 != 0f)
- {
- vector += this.m_bones[bw.boneIndex2].TransformPoint(vLocal) * bw.weight2;
- }
- if (bw.weight3 != 0f)
- {
- vector += this.m_bones[bw.boneIndex3].TransformPoint(vLocal) * bw.weight3;
- }
- return vector;
- }
- public void FindNearVertex(bool reCalcWorldVtx, Vector3 worldPos, ref float findDistance, ref int findNearVtx, ref Vector3 findNearPoint)
- {
- if (reCalcWorldVtx)
- {
- this.ReclucPointWorldAndScreen(null);
- }
- float num = float.MaxValue;
- int num2 = 0;
- Vector3 vector = Vector3.zero;
- for (int i = 0; i < this.VCount; i++)
- {
- float sqrMagnitude = (this.WorldV[i] - worldPos).sqrMagnitude;
- if (sqrMagnitude < num)
- {
- num = sqrMagnitude;
- num2 = i;
- vector = this.WorldV[i];
- }
- }
- findDistance = num;
- findNearVtx = num2;
- findNearPoint = vector;
- }
- public TAttachPoint AddNewAttachPoint(TBodySkin childTbskin, string apname, int[] vidxs)
- {
- TAttachPoint tattachPoint = this.AddNewAttachPoint(childTbskin, apname);
- tattachPoint.newAttachPoint = true;
- tattachPoint.newAttachVidx[0] = vidxs[0];
- tattachPoint.newAttachVidx[1] = vidxs[1];
- tattachPoint.newAttachVidx[2] = vidxs[2];
- return tattachPoint;
- }
- public bool SearchAdjacentVidx(int vidx, ref int[] vtx)
- {
- bool flag = false;
- for (int i = 0; i < this.m_nSubMeshOriTri.Length; i++)
- {
- int[] array = this.m_nSubMeshOriTri[i];
- for (int j = 0; j < array.Length; j += 3)
- {
- if (!flag)
- {
- if (array[j] == vidx)
- {
- vtx[0] = array[j];
- vtx[1] = array[j + 1];
- vtx[2] = array[j + 2];
- flag = true;
- break;
- }
- if (array[j + 1] == vidx)
- {
- vtx[0] = array[j + 1];
- vtx[1] = array[j + 2];
- vtx[2] = array[j];
- flag = true;
- break;
- }
- if (array[j + 2] == vidx)
- {
- vtx[0] = array[j + 2];
- vtx[1] = array[j];
- vtx[2] = array[j + 1];
- flag = true;
- break;
- }
- }
- }
- if (flag)
- {
- break;
- }
- }
- return flag;
- }
- public Vector3[] GetNewAttachPointWorld(string apname)
- {
- if (!this.dicAttachPoint.ContainsKey(apname))
- {
- return null;
- }
- TAttachPoint tattachPoint = this.dicAttachPoint[apname];
- if (!tattachPoint.newAttachPoint)
- {
- return null;
- }
- Vector3[] result = new Vector3[3];
- this.CalcVidxToPos(tattachPoint.newAttachVidx, ref result);
- return result;
- }
- public void CalcVidxToPos(int vidx, ref Vector3 pos)
- {
- BoneWeight boneWeight = this.m_bws[vidx];
- this.CalcVertexPoint(ref pos, vidx, ref boneWeight);
- }
- public void CalcVidxToPos(int[] vidxs, ref Vector3[] pos)
- {
- for (int i = 0; i < vidxs.Length; i++)
- {
- int num = vidxs[i];
- BoneWeight boneWeight = this.m_bws[num];
- this.CalcVertexPoint(ref pos[i], num, ref boneWeight);
- }
- }
- public int SearchRayToNearVtxDistance(int[] vtxs, Vector3[] poss, MathCM.Segment seg)
- {
- float num = 1f;
- int result = -1;
- Vector3 vector = Vector3.zero;
- for (int i = 0; i < poss.Length; i++)
- {
- Vector3 vector2;
- float num3;
- float num2 = MathCM.calcPointSegmentDist(ref poss[i], ref seg, out vector2, out num3);
- if (num2 < num)
- {
- num = num2;
- int num4 = vtxs[i];
- vector = poss[i];
- result = i;
- }
- }
- return result;
- }
- public override void OnApplicationQuit()
- {
- Debug.LogError("TMorph OnApplicationQuit");
- this.m_mesh.vertices = this.m_vOriVert;
- this.m_mesh.normals = this.m_vOriNorm;
- if (this.m_vOriTan != null)
- {
- this.m_mesh.tangents = this.m_vOriTan;
- }
- }
- public TBodySkin.OriVert m_OriVert;
- private int TriCount;
- private int BoneCount;
- private int m_nSubMeshCount;
- public Vector4[] m_vOriTan;
- private Vector3[] m_vTmpVert;
- private Vector3[] m_vTmpNorm;
- private Vector4[] m_vTmpTan;
- private TMorphSkin.CRC_FACE_TYPE m_crcFaceTypeNow;
- public TMorph.IdxRatePair<float> m_HitomiShapeUp;
- public TMorph.IdxRatePair<float> m_HitomiShapeLow;
- public TMorph.IdxRatePair<float> m_HitomiShapeIn;
- public TMorph.IdxRatePair<float> m_HitomiShapeOutUp;
- public TMorph.IdxRatePair<float> m_HitomiShapeOutLow;
- public TMorph.IdxRatePair<float> m_HohoShape;
- public TMorph.IdxRatePair<float> m_Ha1;
- public TMorph.IdxRatePair<float> m_Ha2;
- public TMorph.IdxRatePair<float> m_Ha3;
- public TMorph.IdxRatePair<float> m_Ha4;
- public TMorph.IdxRatePair<float> m_Ha5;
- public TMorph.IdxRatePair<float> m_Ha6;
- private List<TMorph.IdxMinMaxRatePair> m_IdxMinMaxList;
- private float m_LipSync1;
- private float m_LipSync2;
- private float m_LipSync3;
- public int BlendDataIdx_HipSize;
- public float[] BaseBlendValue_Kuikomi = new float[]
- {
- 1f,
- 1f
- };
- public float ChikubiWearTotsu;
- private SkinnedMeshRenderer smr_src;
- private Transform[] m_bones;
- private Transform tRoot;
- private Mesh m_mesh;
- private BoneWeight[] m_bws;
- private Matrix4x4[] m_bindposes;
- private float[] BlendValues;
- private float[] BlendValuesTemp;
- private float[] BlendValuesBackup;
- private float[] BlendValuesCHK;
- private string Category;
- private TBody.SlotID SlotId;
- private bool m_bIsBody;
- private bool m_bMorph;
- private bool m_isMan;
- private Dictionary<int, List<TMorphSkin.BaseBlendValue>> m_baseBlendValues;
- private string[] m_kuikomiMorphs = new string[]
- {
- "pantsa1",
- "pantsa2",
- "pantsa3",
- "pantsb1",
- "pantsb2",
- "pantsb3",
- "pantsc1",
- "pantsc2",
- "pantsc3",
- "stkg1",
- "stkg2",
- "stkg3",
- "stkg4",
- "stkg5",
- "stkg6",
- "stkg7"
- };
- private string[] m_chikubiTotsuMorphs = new string[]
- {
- "chikubih",
- "chikubik1",
- "chikubik2",
- "chikubik2_munes",
- "chikubir",
- "chikubiw",
- "nyurin1",
- "nyurin2",
- "nyurin3",
- "nyurin4",
- "nyurin5",
- "nyurin6",
- "nyurin7",
- "nyurin8"
- };
- private HashSet<int> m_chikubiTotsuMorphsIdx;
- private bool m_bDut;
- public enum CRC_FACE_TYPE
- {
- NORMAL,
- TARE,
- TSURI,
- MAX
- }
- public class BaseBlendValue
- {
- public TMorphSkin.BaseBlendValue.Tag tag;
- public TBody.SlotID parentSlotId;
- public float defValue;
- public enum Tag
- {
- パンツ,
- 靴下,
- MAX
- }
- }
- }
|