1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- 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 if (material.HasProperty(f_strPropName))
- {
- if (f_strTypeName == "Color")
- {
- string[] array = f_strValue.Split(new char[]
- {
- ':'
- });
- material.SetColor(f_strPropName, new Color(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3])));
- }
- else
- {
- 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.LogError(f_strPropName + "はありませんでした。");
- }
- }
- }
- }
- public string GetMaterialProperty(int f_nMatNo, string f_strPropName, string f_strType = "AUTO")
- {
- if (this.obj == null)
- {
- return string.Empty;
- }
- 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 (f_strType == "DEFINE")
- {
- return (!material.IsKeywordEnabled(f_strPropName)) ? "0" : "1";
- }
- if (f_strType == "Color")
- {
- Color color = material.GetColor(f_strPropName);
- return string.Concat(new string[]
- {
- color.r.ToString(),
- ":",
- color.g.ToString(),
- ":",
- color.b.ToString(),
- ":",
- color.a.ToString()
- });
- }
- 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 float MayuThick
- {
- set
- {
- if (this.SlotId == TBody.SlotID.head && 120 <= this.PartsVersion)
- {
- SkinnedMeshRenderer componentInChildren = this.obj.GetComponentInChildren<SkinnedMeshRenderer>();
- Material material = componentInChildren.materials[3];
- float num = 0.5f * (value - 0.5f) / -0.5f;
- material.SetTextureScale("_MainTex", new Vector2(1f, 1f + num));
- material.SetTextureOffset("_MainTex", new Vector2(0f, -(num / 2f)));
- }
- }
- }
- 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);
- }
- }
- }
- }
- }
- if (this.m_bMan && Product.isEnglish && !Product.isPublic)
- {
- foreach (Transform transform2 in gameObject.GetComponentsInChildren<Transform>(true))
- {
- Renderer component2 = transform2.GetComponent<Renderer>();
- if (!(component2 == null) && component2.materials != null)
- {
- foreach (Material material2 in component2.materials)
- {
- if (material2.shader.name == "CM3D2/Mosaic")
- {
- material2.shader = Shader.Find("CM3D2/Mosaic_en");
- }
- }
- }
- }
- }
- this.morph.InitGameObject(gameObject);
- if (Product.isEnglish && !Product.isPublic)
- {
- if (mpn == MPN.body)
- {
- this.kupaCtrl = new KupaCtrl(this.body, this.morph);
- }
- else if (mpn == MPN.moza)
- {
- this.body.GetSlot(0).kupaCtrl.AddMozaMorph(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
- }
- }
|