123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Reflection;
- using System.Text.RegularExpressions;
- using UnityEngine;
- public class TBodySkin
- {
- public TBodySkin(TBody body_, string cate_, TBody.SlotID slot_id_, bool man)
- {
- this.boVisible = true;
- this.body = body_;
- this.Category = cate_;
- this.SlotId = slot_id_;
- this.m_bMan = man;
- this.m_trMaid = this.body.maid.transform;
- this.m_trMaidOffs = this.body.maid.m_goOffset.transform;
- this.bonehair = new TBoneHair_(this);
- this.TextureCache = new InfinityColorTextureCache(body_.maid);
- this.bonehair2 = new BoneHair2(this);
- this.bonehair3 = new BoneHair3(this);
- this.m_HairLengthCtrl = new TBodySkin.HairLengthCtrl(this);
- }
- public void AddRtMaterial(Material f_mat)
- {
- this.m_listRtMaterial.Add(f_mat);
- }
- public int PartsVersion
- {
- get
- {
- return this.m_partsVersion;
- }
- }
- public KupaCtrl kupaCtrl { get; private set; }
- public void DeleteObj()
- {
- this.m_ParentMPN = MPN.null_mpn;
- this.m_mp = null;
- this.m_animItem = null;
- this.body.MulTexRemove(this.Category);
- this.TextureCache.RemoveTexture();
- this.m_listManAlphaMat.Clear();
- this.m_HairLengthCtrl.NotExistThenClearHairLength();
- this.listTrs = null;
- this.listTrsScr = null;
- this.trsBoneAttach = null;
- foreach (UnityEngine.Object @object in this.listDEL)
- {
- UnityEngine.Object.DestroyImmediate(@object);
- }
- this.listDEL = new List<UnityEngine.Object>();
- this.boMizugi = false;
- if (this.morph != null)
- {
- this.morph.DeleteObj();
- this.morph = null;
- }
- this.boVisible = false;
- this.listMaskSlot = new List<int>();
- this.m_dicBackupShader.Clear();
- if (this.bonehair != null)
- {
- this.bonehair.Init();
- }
- if (this.bonehair2 != null)
- {
- this.bonehair2.Uninit();
- }
- if (this.bonehair3 != null)
- {
- this.bonehair3.Uninit();
- }
- if (this.obj != null)
- {
- this.obj_tr.parent = null;
- UnityEngine.Object.DestroyImmediate(this.obj);
- this.obj = null;
- this.obj_tr = null;
- }
- this.m_dicDelNodeParts.Clear();
- this.m_dicParam.Clear();
- this.m_dicParam2.Clear();
- this.m_OriVert.Clear();
- this.m_ParentMPN = MPN.null_mpn;
- this.m_mp = null;
- this.m_bHitFloorY = true;
- this.m_partsVersion = 0;
- this.kupaCtrl = null;
- }
- public void NewParamSet(string A)
- {
- string[] stringList = UTY.GetStringList(A);
- string key = stringList[1];
- int num = (stringList.Length - 2) / 2;
- KeyValuePair<float, string>[] array = new KeyValuePair<float, string>[num];
- for (int i = 0; i < num; i++)
- {
- string value = stringList[3 + i * 2];
- float key2 = float.Parse(stringList[2 + i * 2]);
- array[i] = new KeyValuePair<float, string>(key2, value);
- }
- this.dicParamSet[key] = array;
- }
- public void SetParam(string f_strTag, string f_strValue)
- {
- if (this.m_dicParam.ContainsKey(f_strTag))
- {
- this.m_dicParam[f_strTag] = f_strValue;
- }
- else
- {
- this.m_dicParam.Add(f_strTag, f_strValue);
- }
- }
- public string GetParam(string f_strTag)
- {
- string empty;
- this.m_dicParam.TryGetValue(f_strTag, out empty);
- if (empty == null)
- {
- empty = string.Empty;
- }
- return empty;
- }
- public void SetParam2(string f_strTag, string f_strValue)
- {
- if (this.m_dicParam2.ContainsKey(f_strTag))
- {
- this.m_dicParam2[f_strTag] = f_strValue;
- }
- else
- {
- this.m_dicParam2.Add(f_strTag, f_strValue);
- }
- }
- public string GetParam2(string f_strTag)
- {
- string empty;
- this.m_dicParam2.TryGetValue(f_strTag, out empty);
- if (empty == null)
- {
- empty = string.Empty;
- }
- return empty;
- }
- public void SetMaterialProperty(MPN f_SrcMpn, int f_nMatNo, string f_strPropName, string f_strTypeName, string f_strValue, bool f_bEditSave)
- {
- if (this.obj == null)
- {
- return;
- }
- foreach (Transform transform in this.obj.transform.GetComponentsInChildren<Transform>(true))
- {
- Renderer component = transform.GetComponent<Renderer>();
- if (component != null && component.material != null && f_nMatNo < component.materials.Length)
- {
- Material material = component.materials[f_nMatNo];
- if (f_strTypeName == "DEFINE")
- {
- if (f_strValue == "0")
- {
- material.DisableKeyword(f_strPropName);
- }
- else if (f_strValue == "1")
- {
- material.EnableKeyword(f_strPropName);
- }
- }
- else
- {
- Type type = Assembly.Load("UnityEngine.dll").GetType(f_strTypeName);
- if (type == null)
- {
- type = Type.GetType(f_strTypeName, false, true);
- }
- if (type == null)
- {
- Debug.LogError("タイプ " + f_strTypeName + " は存在しません。");
- return;
- }
- if (material.HasProperty(f_strPropName))
- {
- material.SetFloat(f_strPropName, float.Parse(f_strValue));
- if (f_bEditSave)
- {
- this.body.maid.SetMaterialProperty(f_SrcMpn, this.SlotId, f_nMatNo, f_strPropName, f_strTypeName, f_strValue);
- }
- else
- {
- MatPropSave materialProperty = this.body.maid.GetMaterialProperty(f_SrcMpn, this.SlotId);
- if (materialProperty != null)
- {
- this.SetMaterialProperty(f_SrcMpn, materialProperty.nMatNo, materialProperty.strPropName, materialProperty.strTypeName, materialProperty.strValue, true);
- }
- }
- }
- else
- {
- Debug.LogWarning(f_strPropName + "はありませんでした。");
- }
- }
- }
- }
- }
- public string GetMaterialProperty(int f_nMatNo, string f_strPropName, string f_strType = "AUTO")
- {
- if (this.obj == null)
- {
- return string.Empty;
- }
- bool flag = f_strType == "DEFINE";
- Transform[] componentsInChildren = this.obj.transform.GetComponentsInChildren<Transform>(true);
- int i = 0;
- while (i < componentsInChildren.Length)
- {
- Transform transform = componentsInChildren[i];
- Renderer component = transform.GetComponent<Renderer>();
- if (component != null && component.material != null && f_nMatNo < component.materials.Length)
- {
- Material material = component.materials[f_nMatNo];
- if (flag)
- {
- return (!material.IsKeywordEnabled(f_strPropName)) ? "0" : "1";
- }
- return material.GetFloat(f_strPropName).ToString();
- }
- else
- {
- i++;
- }
- }
- return string.Empty;
- }
- public void ChangeShader(int f_nMatNo, string f_strShaderFileName)
- {
- this.ChangeShader(f_nMatNo, Resources.Load<Shader>("Shaders/" + f_strShaderFileName));
- }
- private void ChangeShader(int f_nMatNo, Shader f_shader)
- {
- GameObject gameObject = this.obj;
- if (gameObject == null)
- {
- return;
- }
- foreach (Transform transform in gameObject.transform.GetComponentsInChildren<Transform>(true))
- {
- Renderer component = transform.GetComponent<Renderer>();
- if (component != null && component.material != null && f_nMatNo < component.materials.Length)
- {
- if (!this.m_dicBackupShader.ContainsKey(f_nMatNo))
- {
- this.m_dicBackupShader[f_nMatNo] = component.materials[f_nMatNo].shader;
- }
- Material material = component.materials[f_nMatNo];
- int renderQueue = material.renderQueue;
- material.shader = f_shader;
- material.renderQueue = renderQueue;
- }
- }
- }
- public void RestoreShader()
- {
- foreach (KeyValuePair<int, Shader> keyValuePair in this.m_dicBackupShader)
- {
- this.ChangeShader(keyValuePair.Key, keyValuePair.Value);
- }
- this.m_dicBackupShader.Clear();
- }
- public bool EnablePartsPosEdit
- {
- get
- {
- return this.m_bEnablePartPosEdit;
- }
- set
- {
- if (this.m_bEnablePartPosEdit == value)
- {
- return;
- }
- if (value)
- {
- BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
- if (tbodySkinPos != null && this.obj_tr != null)
- {
- Vector3 vector = tbodySkinPos.pss.position;
- this.obj_tr.localPosition = vector;
- this.m_vPosLocal = vector;
- Quaternion rotation = tbodySkinPos.pss.rotation;
- this.obj_tr.localRotation = rotation;
- this.m_qRotLocal = rotation;
- vector = tbodySkinPos.pss.scale;
- this.obj_tr.localScale = vector;
- this.m_vScaleRate = vector;
- }
- }
- else if (this.obj_tr != null)
- {
- this.obj_tr.localPosition = this.m_vDefPosLocal;
- this.obj_tr.localRotation = this.m_qDefRotLocal;
- this.obj_tr.localScale = this.m_vDefScaleLocal;
- }
- if (this.center_tr != null)
- {
- this.center_tr.localPosition = this.m_vCenterPosLocal;
- this.center_tr.localRotation = Quaternion.identity;
- this.center_tr.localScale = Vector3.one;
- }
- this.m_bEnablePartPosEdit = value;
- this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
- }
- }
- public bool GetAttachObjPointLocal(out Vector3 f_vPosLocal, out Quaternion f_vRotLocal, out Vector3 f_vScaleLocal)
- {
- f_vPosLocal = Vector3.zero;
- f_vRotLocal = Quaternion.identity;
- f_vScaleLocal = Vector3.zero;
- return false;
- }
- public bool SetAttachObjPointLocal(Vector3 f_vPosLocal, Quaternion f_vRotLocal, Vector3 f_vScaleLocal)
- {
- return false;
- }
- public bool CopyAttachObjPoint()
- {
- if (this.center_tr == null || this.obj_tr == null)
- {
- return false;
- }
- this.m_vTempAttachPointPos = this.obj_tr.localPosition;
- this.m_qTempAttachPointRot = this.obj_tr.localRotation;
- this.m_vTempAttachPointScale = this.obj_tr.localScale;
- return true;
- }
- public bool PastAttachObjPoint()
- {
- if (this.center_tr == null || this.obj_tr == null || !this.m_bEnablePartPosEdit)
- {
- return false;
- }
- Vector3 vector = this.m_vTempAttachPointPos;
- this.obj_tr.localPosition = vector;
- this.m_vPosLocal = vector;
- Quaternion qTempAttachPointRot = this.m_qTempAttachPointRot;
- this.obj_tr.localRotation = qTempAttachPointRot;
- this.m_qRotLocal = qTempAttachPointRot;
- vector = this.m_vTempAttachPointScale;
- this.obj_tr.localScale = vector;
- this.m_vScaleRate = vector;
- this.center_tr.localPosition = this.m_vCenterPosLocal;
- this.center_tr.localRotation = Quaternion.identity;
- this.center_tr.localScale = Vector3.one;
- this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
- return true;
- }
- public bool GetAttachCenterPointWorld(out Vector3 f_vPosWorld, out Quaternion f_vRotWorld, out Vector3 f_vScaleLocal)
- {
- if (this.center_tr == null)
- {
- f_vPosWorld = Vector3.zero;
- f_vRotWorld = Quaternion.identity;
- f_vScaleLocal = Vector3.zero;
- return false;
- }
- f_vPosWorld = this.center_tr.position;
- f_vRotWorld = this.center_tr.rotation;
- f_vScaleLocal = this.m_vScaleRate;
- return true;
- }
- public bool SetAttachCenterPointWorld(Vector3 f_vPosWorld, Quaternion f_vRotWorld, Vector3 f_vScaleLocal)
- {
- if (this.center_tr == null || !this.m_bEnablePartPosEdit)
- {
- return false;
- }
- Transform parent = this.center_tr.parent;
- Transform parent2 = this.obj_tr.parent;
- this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
- this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
- this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
- this.center_tr.localPosition = this.m_vCenterPosLocal;
- this.center_tr.localRotation = Quaternion.identity;
- this.center_tr.localScale = Vector3.one;
- this.center_tr.SetParent(this.obj_tr.parent, true);
- this.obj_tr.SetParent(this.center_tr, true);
- this.center_tr.position = f_vPosWorld;
- this.center_tr.rotation = f_vRotWorld;
- this.center_tr.localScale = f_vScaleLocal;
- this.obj_tr.SetParent(parent2, true);
- this.center_tr.SetParent(parent, true);
- this.center_tr.localPosition = this.m_vCenterPosLocal;
- this.center_tr.localRotation = Quaternion.identity;
- this.center_tr.localScale = Vector3.one;
- this.m_vPosLocal = this.obj_tr.localPosition;
- this.m_qRotLocal = this.obj_tr.localRotation;
- this.m_vScaleRate = this.obj_tr.localScale;
- this.body.maid.SetTBodySkinPos(this.m_ParentMPN, this.SlotId, this.m_vPosLocal, this.m_qRotLocal, this.m_vScaleRate, this.m_bEnablePartPosEdit);
- return true;
- }
- public bool ResetAttachCenterPoint()
- {
- if (this.center_tr == null)
- {
- return false;
- }
- this.obj_tr.localPosition = (this.m_vPosLocal = this.m_vDefPosLocal);
- this.obj_tr.localRotation = (this.m_qRotLocal = this.m_qDefRotLocal);
- this.obj_tr.localScale = (this.m_vScaleRate = this.m_vDefScaleLocal);
- this.center_tr.localPosition = this.m_vCenterPosLocal;
- this.center_tr.localRotation = Quaternion.identity;
- this.center_tr.localScale = Vector3.one;
- this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
- return true;
- }
- public void LoadHitcheckData(Transform body_bone, string fn, int rot, string tag)
- {
- this.bonehair.Init();
- this.bonehair.LoadHitCheck(body_bone, fn + ".hitcheck", rot, tag);
- this.bonehair2.Init();
- this.bonehair3.Init();
- }
- public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp)
- {
- this.Load(mpn, srcbody, body1, trans, bonename, filename, slotname, AttachSlot, layer, f_bTemp, 100);
- }
- public void Load(MPN mpn, Transform srcbody, Transform body1, Dictionary<string, Transform> trans, string bonename, string filename, string slotname, string AttachSlot, int layer, bool f_bTemp, int version)
- {
- this.DeleteObj();
- this.m_partsVersion = version;
- if (mpn == MPN.accashi || mpn == MPN.shoes)
- {
- this.m_bHitFloorY = false;
- }
- this.m_ParentMPN = mpn;
- if (this.m_ParentMPN != MPN.null_mpn)
- {
- this.m_mp = this.body.maid.GetProp(this.m_ParentMPN);
- }
- this.m_bTemp = f_bTemp;
- this.boVisible = true;
- Vector3 position = srcbody.position;
- Quaternion rotation = srcbody.rotation;
- Vector3 localScale = srcbody.localScale;
- Vector3 position2 = body1.position;
- Quaternion rotation2 = body1.rotation;
- Vector3 localScale2 = body1.localScale;
- srcbody.position = Vector3.zero;
- srcbody.rotation = Quaternion.identity;
- srcbody.localScale = new Vector3(1f / srcbody.lossyScale.x, 1f / srcbody.lossyScale.y, 1f / srcbody.lossyScale.z);
- body1.position = Vector3.zero;
- body1.rotation = Quaternion.identity;
- body1.localScale = new Vector3(1f / body1.lossyScale.x, 1f / body1.lossyScale.y, 1f / body1.lossyScale.z);
- this.morph = new TMorph(this);
- GameObject gameObject = ImportCM.LoadSkinMesh_R(filename, this.morph, slotname, this, layer);
- if (this.m_bMan)
- {
- foreach (Transform transform in gameObject.GetComponentsInChildren<Transform>(true))
- {
- Renderer component = transform.GetComponent<Renderer>();
- if (!(component == null) && component.materials != null)
- {
- foreach (Material material in component.materials)
- {
- if (material.shader.name == "CM3D2/Man")
- {
- this.m_listManAlphaMat.Add(material);
- }
- if (material.shader.name == "CM3D2/Mosaic")
- {
- material.SetFloat("_FloatValue1", 15f);
- }
- }
- }
- }
- }
- this.morph.InitGameObject(gameObject);
- if (Product.SIBD && !Product.VBA && mpn == MPN.body)
- {
- this.kupaCtrl = new KupaCtrl(this.body, this.morph);
- }
- gameObject.transform.parent = CMT.SearchObjName(srcbody, bonename, true);
- Vector3 localPosition = gameObject.transform.localPosition;
- Vector3 localScale3 = gameObject.transform.localScale;
- Quaternion localRotation = gameObject.transform.localRotation;
- gameObject.transform.parent = CMT.SearchObjName(body1, bonename, true);
- if (!string.IsNullOrEmpty(AttachSlot))
- {
- this.AttachVisible = true;
- }
- if (AttachSlot == "ボーンにアタッチ" && (bonename == "_IK_handR" || bonename == "_IK_handL"))
- {
- localPosition = Vector3.zero;
- localRotation = Quaternion.identity;
- localScale3 = Vector3.one;
- }
- gameObject.transform.localPosition = localPosition;
- gameObject.transform.localRotation = localRotation;
- gameObject.transform.localScale = localScale3;
- this.obj = gameObject;
- this.obj_tr = this.obj.transform;
- this.listTrs = new List<Transform>(200);
- this.listTrsScr = new List<Transform>(4);
- CMT.BindTrans(this.listTrs, this.listTrsScr, trans, gameObject.transform);
- srcbody.position = position;
- srcbody.rotation = rotation;
- srcbody.localScale = localScale;
- body1.position = position2;
- body1.rotation = rotation2;
- body1.localScale = localScale2;
- if (this.body.m_bNewPhyscs)
- {
- if (!this.bonehair2.InitGameObject(gameObject, mpn))
- {
- bool bNoSkirt = this.bonehair3.InitGameObject(gameObject, mpn);
- this.bonehair.SearchGameObj(gameObject, bNoSkirt);
- }
- }
- else
- {
- this.bonehair.SearchGameObj(gameObject, false);
- }
- this.ItemScaleReset();
- this.OnChangeScreenSizeOrAA();
- if (this.m_bMan)
- {
- this.ManColorUpdate();
- }
- foreach (KeyValuePair<string, float> keyValuePair in this.m_BonehairBodyhitScaleBackup)
- {
- this.bonehair.bodyhit.ScaleMune(keyValuePair.Key, keyValuePair.Value);
- }
- IEnumerator enumerator2 = this.morph.hash.Keys.GetEnumerator();
- try
- {
- while (enumerator2.MoveNext())
- {
- object obj = enumerator2.Current;
- string key = (string)obj;
- int f_nIdx = (int)this.morph.hash[key];
- float f_fValue;
- if (this.body.m_MorphBlendValues.TryGetValue(key, out f_fValue))
- {
- this.morph.SetBlendValues(f_nIdx, f_fValue);
- }
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator2 as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- this.morph.FixBlendValues();
- this.m_vDefPosLocal = (this.m_vPosLocal = this.obj_tr.localPosition);
- this.m_qDefRotLocal = (this.m_qRotLocal = this.obj_tr.localRotation);
- this.m_vDefScaleLocal = (this.m_vScaleRate = this.obj_tr.localScale);
- if (!f_bTemp && (this.SlotId == TBody.SlotID.accHat || this.SlotId == TBody.SlotID.headset || this.SlotId == TBody.SlotID.hairT || this.SlotId == TBody.SlotID.accSenaka || this.SlotId == TBody.SlotID.accKubi || this.SlotId == TBody.SlotID.accKubiwa || this.SlotId == TBody.SlotID.accShippo || this.SlotId == TBody.SlotID.accKubiwa))
- {
- SkinnedMeshRenderer componentInChildren = this.obj_tr.GetComponentInChildren<SkinnedMeshRenderer>(true);
- if (componentInChildren != null)
- {
- Bounds bounds = componentInChildren.bounds;
- GameObject gameObject2 = new GameObject("center");
- gameObject2.transform.SetParent(this.obj_tr, false);
- gameObject2.transform.position = bounds.center;
- GameObject gameObject3 = new GameObject("center2");
- gameObject3.transform.SetParent(gameObject2.transform, false);
- gameObject3.transform.position = bounds.center;
- this.m_vCenterPosLocal = gameObject2.transform.localPosition;
- this.center_tr = gameObject2.transform;
- this.center_tr2 = gameObject3.transform;
- BoneAttachPos tbodySkinPos = this.body.maid.GetTBodySkinPos(this.m_ParentMPN, this.SlotId);
- if (tbodySkinPos != null)
- {
- this.m_vPosLocal = tbodySkinPos.pss.position;
- this.m_qRotLocal = tbodySkinPos.pss.rotation;
- this.m_vScaleRate = tbodySkinPos.pss.scale;
- this.m_bEnablePartPosEdit = tbodySkinPos.bEnable;
- if (this.m_bEnablePartPosEdit)
- {
- this.obj_tr.localPosition = tbodySkinPos.pss.position;
- this.obj_tr.localRotation = tbodySkinPos.pss.rotation;
- this.obj_tr.localScale = tbodySkinPos.pss.scale;
- }
- }
- else
- {
- this.body.maid.ClearTBodySkinPos(this.m_ParentMPN, this.SlotId);
- }
- }
- }
- this.m_HairLengthCtrl.NotExistThenClearHairLength();
- if (OvrIK.IsModeVRIK && OvrIK.Instance != null && OvrIK.Instance.NowMaid == this.body.maid && (this.SlotId == TBody.SlotID.head || this.SlotId == TBody.SlotID.megane || this.SlotId == TBody.SlotID.accHead))
- {
- this.LayerCheck(this.obj);
- }
- }
- public void ItemScaleReset()
- {
- if (this.m_mp != null && this.m_mp.bNoScale)
- {
- Transform parent = this.obj_tr.parent;
- this.obj_tr.SetParent(null, true);
- this.obj_tr.localScale = Vector3.one;
- this.obj_tr.SetParent(parent, true);
- }
- }
- private void LayerCheck(GameObject goParent)
- {
- for (int i = 0; i < goParent.transform.childCount; i++)
- {
- this.LayerCheck(goParent.transform.GetChild(i).gameObject);
- }
- goParent.layer = LayerMask.NameToLayer("Face");
- }
- public void SetVisibleFlag(bool boSetFlag, string name, Transform t = null, bool boTgt = false)
- {
- if (t.name.IndexOf(name) >= 0)
- {
- boTgt = true;
- }
- if (name == "_ALL_")
- {
- boTgt = true;
- }
- if (boTgt)
- {
- this.m_dicDelNodeBody[t.name] = boSetFlag;
- }
- IEnumerator enumerator = t.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform t2 = (Transform)obj;
- this.SetVisibleFlag(boSetFlag, name, t2, boTgt);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- }
- public void SetVisibleFlagParts(bool f_bSetFlag, string f_strTargetSlot, string f_strBoneName, Transform t = null, bool boTgt = false)
- {
- if (t.name.IndexOf(f_strBoneName) >= 0)
- {
- boTgt = true;
- }
- if (f_strBoneName == "_ALL_")
- {
- boTgt = true;
- }
- if (boTgt)
- {
- Dictionary<string, bool> dictionary;
- if (!this.m_dicDelNodeParts.TryGetValue(f_strTargetSlot, out dictionary))
- {
- dictionary = new Dictionary<string, bool>();
- this.m_dicDelNodeParts.Add(f_strTargetSlot, dictionary);
- }
- dictionary[t.name] = f_bSetFlag;
- }
- IEnumerator enumerator = t.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform t2 = (Transform)obj;
- this.SetVisibleFlagParts(f_bSetFlag, f_strTargetSlot, f_strBoneName, t2, boTgt);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- }
- public void CopyTrans()
- {
- for (int i = 0; i < this.listTrs.Count; i += 2)
- {
- this.listTrs[i].localRotation = this.listTrs[i + 1].localRotation;
- this.listTrs[i].localPosition = this.listTrs[i + 1].localPosition;
- }
- for (int j = 0; j < this.listTrsScr.Count; j += 2)
- {
- this.listTrsScr[j].localScale = this.listTrsScr[j + 1].localScale;
- }
- this.TightSkirt();
- }
- public void TightSkirt()
- {
- }
- private void LookAtAxis(Transform f_trSrc, Vector3 f_vTargetPosWorld, TBodySkin.Axis f_axis, Vector3 f_vForwardWorld)
- {
- Vector3 position = f_trSrc.InverseTransformPoint(f_vTargetPosWorld);
- if (f_axis == TBodySkin.Axis.X)
- {
- position.x = 0f;
- }
- else if (f_axis == TBodySkin.Axis.Y)
- {
- position.y = 0f;
- }
- else
- {
- position.z = 0f;
- }
- Vector3 vector = f_trSrc.TransformPoint(position);
- Debug.DrawLine(vector, f_trSrc.position, Color.cyan);
- Quaternion lhs = Quaternion.FromToRotation(f_vForwardWorld, (vector - f_trSrc.position).normalized);
- f_trSrc.rotation = lhs * f_trSrc.rotation;
- }
- public void OnChangeScreenSizeOrAA()
- {
- bool flag = QualitySettings.antiAliasing != 0;
- if (this.obj == null)
- {
- return;
- }
- bool flag2 = !flag && !GameMain.Instance.MainCamera.IsBloomEnabled;
- if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode)
- {
- flag2 = false;
- }
- this.obj.GetComponentsInChildren<Renderer>(true, this.m_listRnederTemp);
- for (int i = 0; i < this.m_listRnederTemp.Count; i++)
- {
- Renderer renderer = this.m_listRnederTemp[i];
- if (!(renderer.material == null))
- {
- foreach (Material material in renderer.materials)
- {
- if (flag2)
- {
- material.EnableKeyword("UV_POS_REVERSE");
- material.DisableKeyword("UV_POS_NORMAL");
- }
- else
- {
- material.DisableKeyword("UV_POS_NORMAL");
- material.DisableKeyword("UV_POS_REVERSE");
- }
- }
- }
- }
- }
- private IEnumerator CoReFixBlendValues()
- {
- yield return null;
- this.morph.ResetBlendValues();
- yield break;
- }
- public void ManColorUpdate()
- {
- for (int i = 0; i < this.m_listManAlphaMat.Count; i++)
- {
- Material material = this.m_listManAlphaMat[i];
- material.SetFloat("_FloatValue2", (float)GameMain.Instance.CMSystem.ManAlpha / 100f);
- material.SetColor("_Color", this.body.maid.ManColor);
- }
- }
- public bool AnimationLoad(string f_strAnimName)
- {
- if (this.m_animItem == null)
- {
- this.m_animItem = this.obj.AddComponent<Animation>();
- }
- if (this.m_animItem.GetClip(f_strAnimName) == null)
- {
- string text = f_strAnimName;
- if (string.IsNullOrEmpty(Path.GetExtension(text)))
- {
- text += ".anm";
- }
- AnimationClip animationClip = ImportCM.LoadAniClipNative(GameUty.FileSystem, text, true, true, true);
- if (animationClip == null)
- {
- NDebug.Assert("アニメーション " + text + " が見つかりません。", false);
- return false;
- }
- this.m_animItem.Stop();
- this.m_animItem.AddClip(animationClip, f_strAnimName);
- this.m_animItem.clip = animationClip;
- this.m_animItem.playAutomatically = true;
- }
- this.m_animItem.Stop();
- return true;
- }
- public bool AnimationPlay(string f_strAnimName, bool f_bLoop)
- {
- if (this.m_animItem == null)
- {
- Debug.LogError("まだアイテムアニメが読まれていません。");
- return false;
- }
- this.m_animItem.Stop();
- this.m_animItem.wrapMode = ((!f_bLoop) ? WrapMode.Once : WrapMode.Loop);
- if (this.m_animItem.GetClip(f_strAnimName) == null)
- {
- NDebug.Assert("アニメーション " + f_strAnimName + " は設定されていません。", false);
- return false;
- }
- this.m_animItem[f_strAnimName].time = 0f;
- this.m_animItem.Play(f_strAnimName);
- return true;
- }
- public bool AnimationStop()
- {
- if (this.m_animItem == null)
- {
- return false;
- }
- this.m_animItem.Stop();
- return true;
- }
- public bool MaterialAnimatorAdd(int f_nMateNo)
- {
- Renderer componentInChildren = this.obj.GetComponentInChildren<Renderer>();
- if (componentInChildren != null)
- {
- MaterialAnimator materialAnimator = componentInChildren.gameObject.AddComponent<MaterialAnimator>();
- materialAnimator.m_nMateNo = f_nMateNo;
- materialAnimator.Init();
- }
- return true;
- }
- public void Update()
- {
- if (this.obj == null)
- {
- return;
- }
- if (this.obj.activeSelf != this.boVisible)
- {
- CMT.SetActiveFlag(this.obj_tr, this.boVisible);
- if (this.boVisible)
- {
- this.body.StartCoroutine(this.CoReFixBlendValues());
- }
- }
- if (!this.boVisible)
- {
- return;
- }
- if (this.trsBoneAttach != null)
- {
- this.obj_tr.position = this.trsBoneAttach.position;
- this.obj_tr.rotation = this.trsBoneAttach.rotation;
- }
- if (this.AttachName != null && this.body.goSlot[this.AttachSlotIdx].morph != null)
- {
- Vector3 position;
- Quaternion rotation;
- Vector3 vector;
- if (this.body.goSlot[this.AttachSlotIdx].morph.GetAttachPoint(this.AttachName, out position, out rotation, out vector, this.m_bTemp))
- {
- if (!this.AttachVisible)
- {
- this.obj_tr.localScale = Vector3.one;
- this.AttachVisible = true;
- }
- this.obj_tr.position = position;
- this.obj_tr.rotation = rotation;
- this.obj_tr.localScale = new Vector3(this.m_vDefScaleLocal.x * vector.x, this.m_vDefScaleLocal.y * vector.y, this.m_vDefScaleLocal.z * vector.z);
- }
- else if (this.AttachVisible)
- {
- this.obj_tr.localScale = Vector3.zero;
- this.AttachVisible = false;
- }
- }
- if (this.kupaCtrl != null)
- {
- this.kupaCtrl.SelfUpdate();
- }
- Vector3 localScale = this.m_trMaid.localScale;
- Vector3 localScale2 = this.m_trMaidOffs.localScale;
- if (localScale.x < 0.998f || 1.002f < localScale.x || localScale2.x < 0.998f || 1.002f < localScale2.x)
- {
- this.m_trMaid.localScale = Vector3.one;
- this.m_trMaidOffs.localScale = Vector3.one;
- this.bonehair.Update();
- this.bonehair3.UpdateSelf();
- this.m_trMaid.localScale = localScale;
- this.m_trMaidOffs.localScale = localScale2;
- }
- else
- {
- this.bonehair.Update();
- this.bonehair3.UpdateSelf();
- }
- }
- public TBody body;
- public string Category;
- public TBody.SlotID SlotId;
- public bool boVisible = true;
- public List<int> listMaskSlot = new List<int>();
- public GameObject obj;
- public Transform obj_tr;
- public Transform center_tr;
- public Transform center_tr2;
- private List<Transform> listTrs;
- private List<Transform> listTrsScr;
- public List<UnityEngine.Object> listDEL = new List<UnityEngine.Object>();
- public Dictionary<string, UnityEngine.Object> dicDel = new Dictionary<string, UnityEngine.Object>();
- private List<Material> m_listRtMaterial = new List<Material>();
- public TMorph morph;
- public Dictionary<string, bool> m_dicDelNodeBody = new Dictionary<string, bool>();
- public Dictionary<string, Dictionary<string, bool>> m_dicDelNodeParts = new Dictionary<string, Dictionary<string, bool>>();
- public TBoneHair_ bonehair;
- public BoneHair2 bonehair2;
- public BoneHair3 bonehair3;
- public bool boMizugi;
- public Dictionary<string, KeyValuePair<float, string>[]> dicParamSet = new Dictionary<string, KeyValuePair<float, string>[]>();
- private Dictionary<string, string> m_dicParam = new Dictionary<string, string>();
- private Dictionary<string, string> m_dicParam2 = new Dictionary<string, string>();
- public Transform trsBoneAttach;
- public string AttachName;
- public bool AttachVisible;
- public int AttachSlotIdx;
- private Quaternion AttachRotation;
- public Vector3 m_vDefScaleLocal;
- public Vector3 m_vScaleRate;
- public Vector3 m_vTempAttachPointScale;
- public Vector3 m_vDefPosLocal;
- public Vector3 m_vPosLocal;
- public Vector3 m_vCenterPosLocal;
- public Vector3 m_vTempAttachPointPos;
- public Quaternion m_qDefRotLocal;
- public Quaternion m_qRotLocal;
- public Quaternion m_qTempAttachPointRot;
- public int RID;
- public int SyojiType;
- public string m_strModelFileName = string.Empty;
- public MPN m_ParentMPN;
- public MaidProp m_mp;
- private bool m_bMan;
- private List<Material> m_listManAlphaMat = new List<Material>();
- public InfinityColorTextureCache TextureCache;
- private bool m_bEnablePartPosEdit;
- public Dictionary<string, float> m_BonehairBodyhitScaleBackup = new Dictionary<string, float>();
- public Dictionary<string, TMorph.TempAttachPos> m_dicTempAttachPoint = new Dictionary<string, TMorph.TempAttachPos>();
- public bool m_bHitFloorY = true;
- private Transform m_trMaid;
- private Transform m_trMaidOffs;
- private Dictionary<int, Shader> m_dicBackupShader = new Dictionary<int, Shader>();
- private bool m_bTemp;
- private Transform m_trThigh_L;
- private Transform m_trThigh_R;
- private Transform m_trCalf_L;
- private Transform m_trCalf_R;
- private Transform m_trFoot_L;
- private Transform m_trFoot_R;
- public TBodySkin.OriVert m_OriVert = new TBodySkin.OriVert();
- public TBodySkin.HairLengthCtrl m_HairLengthCtrl;
- private Animation m_animItem;
- private int m_partsVersion;
- private List<Renderer> m_listRnederTemp = new List<Renderer>(4);
- public class HairLengthCtrl
- {
- public HairLengthCtrl(TBodySkin f_trTbodySkin)
- {
- this.m_tbskin = f_trTbodySkin;
- this.m_maid = this.m_tbskin.body.maid;
- }
- public bool IsHairLengthEditable
- {
- get
- {
- return this.m_dicHairLenght != null && this.m_dicHairLenght.Count != 0;
- }
- }
- public Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> HairLengthGroupList
- {
- get
- {
- return this.m_dicHairLenght;
- }
- }
- public void NotExistThenClearHairLength()
- {
- if (this.m_maid.NotExistThenClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId))
- {
- }
- this.m_dicHairLenght.Clear();
- }
- public void SearchAndAddHairLengthTarget(string f_strGroupName, string f_strBoneSearchType, string f_strBoneName, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
- {
- if (this.m_tbskin == null || this.m_tbskin.obj_tr == null)
- {
- NDebug.Assert("髪ボーン拡縮検索 親が未だありません。", false);
- }
- string pattern = f_strBoneName.Replace("*", ".*");
- TBodySkin.HairLengthCtrl.SerchMode mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
- if (f_strBoneSearchType == "fbrother")
- {
- mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER;
- }
- else if (f_strBoneSearchType == "fchild")
- {
- mode = TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD;
- }
- else if (f_strBoneSearchType == "all")
- {
- mode = TBodySkin.HairLengthCtrl.SerchMode.ALL;
- }
- else
- {
- NDebug.Assert("髪ボーン検索タイプが不正です。 " + f_strBoneSearchType, false);
- }
- this.SearchObjAndAdd(f_strGroupName, this.m_tbskin.obj_tr, new Regex(pattern), mode, f_vScaleMin, f_vScaleMax);
- TBodySkin.HairLengthCtrl.HairLength hairLength;
- if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
- {
- Debug.LogError("髪ボーングループがありません。");
- return;
- }
- float lengthRate = 0.5f;
- if (this.m_maid.GetHairLengthFromMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId, f_strGroupName, out lengthRate))
- {
- hairLength.SetLengthRate(lengthRate);
- }
- else
- {
- this.m_maid.ClearHairLengthMP(this.m_tbskin.m_ParentMPN, this.m_tbskin.SlotId);
- }
- this.HairLenghtBlend();
- }
- private Transform SearchObjAndAdd(string f_strGroupName, Transform t, Regex regex, TBodySkin.HairLengthCtrl.SerchMode mode, Vector3 f_vScaleMin, Vector3 f_vScaleMax)
- {
- string name = t.name;
- if (regex.IsMatch(name))
- {
- TBodySkin.HairLengthCtrl.HairLength hairLength;
- if (!this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
- {
- hairLength = new TBodySkin.HairLengthCtrl.HairLength(this.m_tbskin, f_strGroupName);
- this.m_dicHairLenght[f_strGroupName] = hairLength;
- }
- hairLength.listTarget.Add(new TBodySkin.HairLengthCtrl.HairLengthTarget
- {
- trTarget = t,
- vScaleDef = t.localScale,
- vScaleMin = f_vScaleMin,
- vScaleMax = f_vScaleMax
- });
- if (mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_BROTHER || mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
- {
- return t;
- }
- }
- for (int i = 0; i < t.childCount; i++)
- {
- Transform child = t.GetChild(i);
- Transform transform = this.SearchObjAndAdd(f_strGroupName, child, regex, mode, f_vScaleMin, f_vScaleMax);
- if (transform != null && mode == TBodySkin.HairLengthCtrl.SerchMode.FIRST_CHILD)
- {
- return transform;
- }
- }
- return null;
- }
- public void HairLenghtBlend()
- {
- foreach (KeyValuePair<string, TBodySkin.HairLengthCtrl.HairLength> keyValuePair in this.m_dicHairLenght)
- {
- float lengthRate = keyValuePair.Value.GetLengthRate();
- for (int i = 0; i < keyValuePair.Value.listTarget.Count; i++)
- {
- TBodySkin.HairLengthCtrl.HairLengthTarget hairLengthTarget = keyValuePair.Value.listTarget[i];
- Vector3 localScale = hairLengthTarget.vScaleDef;
- if (lengthRate < 0.5f)
- {
- localScale = Vector3.Lerp(hairLengthTarget.vScaleMin, hairLengthTarget.vScaleDef, lengthRate / 0.5f);
- }
- else if (0.5f < lengthRate)
- {
- localScale = Vector3.Lerp(hairLengthTarget.vScaleDef, hairLengthTarget.vScaleMax, (lengthRate - 0.5f) / 0.5f);
- }
- hairLengthTarget.trTarget.localScale = localScale;
- }
- }
- }
- private Dictionary<string, TBodySkin.HairLengthCtrl.HairLength> m_dicHairLenght = new Dictionary<string, TBodySkin.HairLengthCtrl.HairLength>();
- private TBodySkin m_tbskin;
- private Maid m_maid;
- public class HairLengthTarget
- {
- public Transform trTarget;
- public Vector3 vScaleDef;
- public Vector3 vScaleMin;
- public Vector3 vScaleMax;
- }
- public class HairLength
- {
- public HairLength(TBodySkin f_tbskin, string f_strGroupName)
- {
- this.m_tbskin = f_tbskin;
- this.strGroupName = f_strGroupName;
- }
- public float GetLengthRate()
- {
- return this.fLenghtRate;
- }
- public void SetLengthRate(float f_fRate)
- {
- Maid maid = this.m_tbskin.body.maid;
- MPN parentMPN = this.m_tbskin.m_ParentMPN;
- TBody.SlotID slotId = this.m_tbskin.SlotId;
- string f_strName = this.strGroupName;
- this.fLenghtRate = f_fRate;
- maid.SetHairLengthSaveToMP(parentMPN, slotId, f_strName, f_fRate);
- }
- private TBodySkin m_tbskin;
- private string strGroupName;
- private float fLenghtRate = 0.5f;
- public List<TBodySkin.HairLengthCtrl.HairLengthTarget> listTarget = new List<TBodySkin.HairLengthCtrl.HairLengthTarget>();
- }
- private enum SerchMode
- {
- FIRST_CHILD,
- FIRST_BROTHER,
- ALL
- }
- }
- public class OriVert
- {
- public void Clear()
- {
- this.VCount = 0;
- this.vOriVert = null;
- this.vOriNorm = null;
- this.nSubMeshCount = 0;
- this.nSubMeshOriTri = null;
- this.bwWeight = null;
- }
- public int VCount;
- public Vector3[] vOriVert;
- public Vector3[] vOriNorm;
- public int nSubMeshCount;
- public int[][] nSubMeshOriTri;
- public BoneWeight[] bwWeight;
- }
- private enum Axis
- {
- X,
- Y,
- Z
- }
- }
|