12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220 |
- 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 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;
- }
- 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.DeleteObj();
- 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.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.morph.InitGameObject(gameObject);
- 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;
- 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;
- }
- }
- 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;
- }
- }
- 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>();
- private Transform m_trMaid;
- private Transform m_trMaidOffs;
- private Dictionary<int, Shader> m_dicBackupShader = new Dictionary<int, Shader>();
- private bool m_bTemp;
- public TBodySkin.OriVert m_OriVert = new TBodySkin.OriVert();
- public TBodySkin.HairLengthCtrl m_HairLengthCtrl;
- private Animation m_animItem;
- 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.SearchObjName(f_strGroupName, this.m_tbskin.obj_tr, new Regex(pattern), mode);
- TBodySkin.HairLengthCtrl.HairLength hairLength;
- if (this.m_dicHairLenght.TryGetValue(f_strGroupName, out hairLength))
- {
- hairLength.vScaleMin = f_vScaleMin;
- hairLength.vScaleMax = f_vScaleMax;
- }
- 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 SearchObjName(string f_strGroupName, Transform t, Regex regex, TBodySkin.HairLengthCtrl.SerchMode mode)
- {
- 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
- });
- 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.SearchObjName(f_strGroupName, child, regex, mode);
- 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(keyValuePair.Value.vScaleMin, hairLengthTarget.vScaleDef, lengthRate / 0.5f);
- }
- else if (0.5f < lengthRate)
- {
- localScale = Vector3.Lerp(hairLengthTarget.vScaleDef, keyValuePair.Value.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 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 Vector3 vScaleMin;
- public Vector3 vScaleMax;
- 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;
- }
- }
|