12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Runtime.InteropServices;
- using UnityEngine;
- public class DynamicSkirtBone : MonoBehaviour
- {
- [DllImport("kernel32.dll")]
- private static extern IntPtr LoadLibraryW(byte[] dllToLoad);
- [DllImport("kernel32.dll")]
- private static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
- [DllImport("kernel32.dll")]
- private static extern bool FreeLibrary(IntPtr hModule);
- public bool SerializeWrite(BinaryWriter f_bw)
- {
- f_bw.Write("CM3D21_PSK");
- f_bw.Write(1130);
- f_bw.Write(this.m_fPanierRadius);
- this.SerializeWriteAnimationCurve(f_bw, this.m_PanierRadiusDistrib);
- int num = (this.m_PanierRadiusDistribGroup == null) ? 0 : this.m_PanierRadiusDistribGroup.Length;
- f_bw.Write(num);
- for (int i = 0; i < num; i++)
- {
- DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = this.m_PanierRadiusDistribGroup[i];
- f_bw.Write(panierRadiusGroup.strBoneName);
- f_bw.Write(panierRadiusGroup.fRadius);
- this.SerializeWriteAnimationCurve(f_bw, panierRadiusGroup.Curve);
- }
- f_bw.Write(this.m_fPanierForce);
- this.SerializeWriteAnimationCurve(f_bw, this.m_PanierForceDistrib);
- f_bw.Write(this.m_fPanierStressForce);
- f_bw.Write(this.m_fStressDgreeMin);
- f_bw.Write(this.m_fStressDgreeMax);
- f_bw.Write(this.m_fStressMinScale);
- f_bw.Write(this.m_fScaleEaseSpeed);
- f_bw.Write(this.m_fPanierForceDistanceThreshold);
- f_bw.Write(this.m_nCalcTime);
- f_bw.Write(this.m_fVelocityForceRate);
- this.SerializeWriteAnimationCurve(f_bw, this.m_VelocityForceRateDistrib);
- f_bw.Write(this.m_vGravity.x);
- f_bw.Write(this.m_vGravity.y);
- f_bw.Write(this.m_vGravity.z);
- this.SerializeWriteAnimationCurve(f_bw, this.m_GravityDistrib);
- f_bw.Write(this.m_aryHard[0]);
- f_bw.Write(this.m_aryHard[1]);
- f_bw.Write(this.m_aryHard[2]);
- f_bw.Write(this.m_aryHard[3]);
- return true;
- }
- private void SerializeWriteAnimationCurve(BinaryWriter f_bw, AnimationCurve f_ac)
- {
- Keyframe[] keys = f_ac.keys;
- f_bw.Write(keys.Length);
- for (int i = 0; i < keys.Length; i++)
- {
- f_bw.Write(keys[i].time);
- f_bw.Write(keys[i].value);
- f_bw.Write(keys[i].inTangent);
- f_bw.Write(keys[i].outTangent);
- }
- }
- public void SerializeRead(BinaryReader f_br)
- {
- string a = f_br.ReadString();
- if (a != "CM3D21_PSK")
- {
- NDebug.Assert("物理スカート定義ヘッダー不正", false);
- }
- int num = f_br.ReadInt32();
- this.m_fPanierRadius = f_br.ReadSingle();
- this.SerializeReadAnimationCurve(f_br, out this.m_PanierRadiusDistrib);
- if (217 <= num)
- {
- int num2 = f_br.ReadInt32();
- if (num2 != 0)
- {
- this.m_PanierRadiusDistribGroup = new DynamicSkirtBone.PanierRadiusGroup[num2];
- }
- for (int i = 0; i < num2; i++)
- {
- DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = new DynamicSkirtBone.PanierRadiusGroup();
- panierRadiusGroup.strBoneName = f_br.ReadString();
- panierRadiusGroup.fRadius = f_br.ReadSingle();
- this.SerializeReadAnimationCurve(f_br, out panierRadiusGroup.Curve);
- this.m_PanierRadiusDistribGroup[i] = panierRadiusGroup;
- }
- }
- this.m_fPanierForce = f_br.ReadSingle();
- this.SerializeReadAnimationCurve(f_br, out this.m_PanierForceDistrib);
- this.m_fPanierStressForce = f_br.ReadSingle();
- this.m_fStressDgreeMin = f_br.ReadSingle();
- this.m_fStressDgreeMax = f_br.ReadSingle();
- this.m_fStressMinScale = f_br.ReadSingle();
- this.m_fScaleEaseSpeed = f_br.ReadSingle();
- this.m_fPanierForceDistanceThreshold = f_br.ReadSingle();
- this.m_nCalcTime = f_br.ReadInt32();
- this.m_fVelocityForceRate = f_br.ReadSingle();
- this.SerializeReadAnimationCurve(f_br, out this.m_VelocityForceRateDistrib);
- this.m_vGravity.x = f_br.ReadSingle();
- this.m_vGravity.y = f_br.ReadSingle();
- this.m_vGravity.z = f_br.ReadSingle();
- this.SerializeReadAnimationCurve(f_br, out this.m_GravityDistrib);
- this.m_aryHard[0] = f_br.ReadSingle();
- this.m_aryHard[1] = f_br.ReadSingle();
- this.m_aryHard[2] = f_br.ReadSingle();
- this.m_aryHard[3] = f_br.ReadSingle();
- this.UpdateParameters();
- }
- private void SerializeReadAnimationCurve(BinaryReader f_br, out AnimationCurve f_ac)
- {
- int num = f_br.ReadInt32();
- f_ac = null;
- if (num != 0)
- {
- Keyframe[] array = new Keyframe[num];
- for (int i = 0; i < num; i++)
- {
- array[i] = new Keyframe
- {
- time = f_br.ReadSingle(),
- value = f_br.ReadSingle(),
- inTangent = f_br.ReadSingle(),
- outTangent = f_br.ReadSingle()
- };
- }
- f_ac = new AnimationCurve(array);
- }
- }
- public bool InitGameObject(GameObject f_objRoot, TBodySkin bodyskin, Transform f_trSkirtRoot)
- {
- this.m_BodySkin = bodyskin;
- this.m_Body = bodyskin.body;
- if (DynamicSkirtBone.m_PluginDll == IntPtr.Zero)
- {
- string text = Application.dataPath + '/' + "Plugins/clothpp.dll";
- Debug.Log("Application.dataPath is " + text);
- DynamicSkirtBone.m_PluginDll = DynamicSkirtBone.LoadLibraryW(NUty.ConvStringToByte(text, NUty.ENCO.UTF_16));
- IntPtr procAddress = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_PhysicsCreate");
- DynamicSkirtBone.m_dgExport_PhysicsCreate = (DynamicSkirtBone.Export_PhysicsCreate)Marshal.GetDelegateForFunctionPointer(procAddress, typeof(DynamicSkirtBone.Export_PhysicsCreate));
- IntPtr procAddress2 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_PhysicsDelete");
- DynamicSkirtBone.m_dgExport_PhysicsDelete = (DynamicSkirtBone.Export_PhysicsDelete)Marshal.GetDelegateForFunctionPointer(procAddress2, typeof(DynamicSkirtBone.Export_PhysicsDelete));
- IntPtr procAddress3 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_InitSkirt");
- DynamicSkirtBone.m_dgExport_InitSkirt = (DynamicSkirtBone.Export_InitSkirt)Marshal.GetDelegateForFunctionPointer(procAddress3, typeof(DynamicSkirtBone.Export_InitSkirt));
- IntPtr procAddress4 = DynamicSkirtBone.GetProcAddress(DynamicSkirtBone.m_PluginDll, "Export_GetBonePos");
- DynamicSkirtBone.m_dgExport_GetBonePos = (DynamicSkirtBone.Export_GetBonePos)Marshal.GetDelegateForFunctionPointer(procAddress4, typeof(DynamicSkirtBone.Export_GetBonePos));
- }
- NDebug.Assert(this.m_nDllPhysicsInstanceID == -1, () => "Skirt DLL多重ロード。");
- this.m_nDllPhysicsInstanceID = DynamicSkirtBone.m_dgExport_PhysicsCreate();
- this.m_nBoneCount = 0;
- this.m_listBoneScaleDef.Clear();
- this.m_listHookBoneTrs = new List<Transform>();
- int num = -1;
- int num2 = f_trSkirtRoot.childCount - 1;
- while (0 <= num2)
- {
- Transform child = f_trSkirtRoot.GetChild(num2);
- if (child.name.Contains("Skirt") && child.name.Contains("_A_"))
- {
- int num3 = int.Parse(child.name.Substring(5, 2)) - 1;
- if (num == -1)
- {
- num = num3;
- }
- num3 = num - num3;
- Vector3 position = child.position;
- this.m_aryBonePos[num3 * 3] = position.x;
- this.m_aryBonePos[num3 * 3 + 1] = position.y;
- this.m_aryBonePos[num3 * 3 + 2] = position.z;
- this.m_aryBoneTrs[num3] = child;
- this.m_listHookBoneTrs.Add(child);
- }
- num2--;
- }
- this.m_nHookBoneCount = this.m_listHookBoneTrs.Count;
- this.m_nBoneCount = this.m_nHookBoneCount;
- this.m_bOldBone = (this.m_nHookBoneCount <= 12);
- float num4 = 0f;
- for (int i = 0; i < this.m_nHookBoneCount; i++)
- {
- int num5 = 0;
- Transform transform = this.m_listHookBoneTrs[i];
- if (transform.localScale.x < 0.999f || 1.001f < transform.localScale.x || transform.localScale.y < 0.999f || 1.001f < transform.localScale.y || transform.localScale.z < 0.999f || 1.001f < transform.localScale.z)
- {
- this.m_listBoneScaleDef.Add(new BoneScaleDef(transform, transform.localPosition, transform.localRotation, transform.localScale));
- }
- this.m_aryBoneLength[i] = 0f;
- float num6 = 0f;
- while (transform.childCount > 0)
- {
- Vector3 position2 = transform.position;
- transform = transform.GetChild(0);
- if (transform.localScale.x < 0.999f || 1.001f < transform.localScale.x || transform.localScale.y < 0.999f || 1.001f < transform.localScale.y || transform.localScale.z < 0.999f || 1.001f < transform.localScale.z)
- {
- this.m_listBoneScaleDef.Add(new BoneScaleDef(transform, transform.localPosition, transform.localRotation, transform.localScale));
- }
- num6 += (position2 - transform.position).magnitude;
- Vector3 position3 = transform.position;
- this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3] = position3.x;
- this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3 + 1] = position3.y;
- this.m_aryBonePos[(num5 + 1) * (this.m_nHookBoneCount * 3) + i * 3 + 2] = position3.z;
- this.m_aryBoneTrs[(num5 + 1) * this.m_nHookBoneCount + i] = transform;
- this.m_aryBoneLength[(num5 + 1) * this.m_nHookBoneCount + i] = num6;
- this.m_nBoneCount++;
- num5++;
- }
- if (num4 < num6)
- {
- num4 = num6;
- }
- }
- this.m_fMaxLenght = num4;
- for (int j = 0; j < this.m_nBoneCount; j++)
- {
- this.m_aryBoneLengthRate[j] = this.m_aryBoneLength[j] / this.m_fMaxLenght;
- }
- this.m_aryVelocityForceRate = new float[this.m_nBoneCount];
- this.m_aryGravity = new float[this.m_nBoneCount * 3];
- this.m_trPanierParent = new GameObject("Skirt_P").transform;
- this.m_trPanierParent.SetParent(f_trSkirtRoot, false);
- this.m_trPanierParent.position = f_trSkirtRoot.position;
- this.m_trPanierParent.rotation = f_trSkirtRoot.rotation;
- this.m_aryPanierBoneTrs = new Transform[this.m_nBoneCount];
- this.m_aryPanierForce = new float[this.m_nBoneCount];
- this.m_aryPanierRadius = new float[this.m_nBoneCount];
- this.m_aryPanierBoneToLegSegRate = new float[this.m_nBoneCount];
- this.m_aryPanierBoneBeforeRotAngle = new float[this.m_nBoneCount];
- this.m_fPanierStress = new float[this.m_nHookBoneCount];
- this.m_fPanierVecAngle = new float[this.m_nHookBoneCount];
- this.m_aryPanierLastChildDef = new Transform[this.m_nHookBoneCount];
- Dictionary<string, ImportCM.OldSkirtBoneRev> dictionary = null;
- if (this.m_bOldBone)
- {
- dictionary = ImportCM.LoadOldSkirtBoneRev(f_objRoot.name);
- this.m_bPanierOldBoneRotRev = new bool[this.m_nBoneCount];
- this.m_vPanierOldBoneRotRevInit = new Vector3[this.m_nBoneCount];
- this.m_vPanierOldBoneRotRevAfter = new Vector3[this.m_nBoneCount];
- }
- int num7 = 0;
- for (int k = 0; k < this.m_nHookBoneCount; k++)
- {
- GameObject gameObject = new GameObject("Skirt_P_" + k + "_0");
- gameObject.transform.SetParent(this.m_trPanierParent, false);
- Transform transform2 = this.m_listHookBoneTrs[k];
- gameObject.transform.position = transform2.position;
- gameObject.transform.rotation = transform2.rotation;
- bool flag = false;
- Vector3 vector = Vector3.zero;
- Vector3 vector2 = Vector3.zero;
- if (this.m_bOldBone)
- {
- ImportCM.OldSkirtBoneRev oldSkirtBoneRev;
- if (dictionary != null && dictionary.TryGetValue(transform2.name, out oldSkirtBoneRev))
- {
- this.m_bPanierOldBoneRotRev[k] = true;
- this.m_vPanierOldBoneRotRevInit[k] = oldSkirtBoneRev.vRotRevInit;
- this.m_vPanierOldBoneRotRevAfter[k] = oldSkirtBoneRev.vRotRevAfter;
- flag = oldSkirtBoneRev.bRecursiv;
- if (flag)
- {
- vector = oldSkirtBoneRev.vRotRevInit;
- vector2 = oldSkirtBoneRev.vRotRevAfter;
- }
- }
- else
- {
- Vector3 normalized = (this.m_listHookBoneTrs[(k + 1 >= this.m_nHookBoneCount) ? 0 : (k + 1)].position - this.m_listHookBoneTrs[k].position).normalized;
- float num8 = Vector3.Dot(normalized, -this.m_listHookBoneTrs[k].forward);
- if (num8 < 0.1f)
- {
- this.m_bPanierOldBoneRotRev[k] = true;
- flag = true;
- float num9 = Vector3.Dot(normalized, this.m_listHookBoneTrs[k].forward);
- if (-0.1 < (double)num9 && num9 < 0.5f)
- {
- Vector3[] vPanierOldBoneRotRevInit = this.m_vPanierOldBoneRotRevInit;
- int num10 = k;
- vector = new Vector3(90f, 0f, 0f);
- vPanierOldBoneRotRevInit[num10] = vector;
- Vector3[] vPanierOldBoneRotRevAfter = this.m_vPanierOldBoneRotRevAfter;
- int num11 = k;
- vector2 = new Vector3(-90f, 0f, 0f);
- vPanierOldBoneRotRevAfter[num11] = vector2;
- }
- else
- {
- Vector3[] vPanierOldBoneRotRevInit2 = this.m_vPanierOldBoneRotRevInit;
- int num12 = k;
- vector = new Vector3(180f, 0f, 0f);
- vPanierOldBoneRotRevInit2[num12] = vector;
- Vector3[] vPanierOldBoneRotRevAfter2 = this.m_vPanierOldBoneRotRevAfter;
- int num13 = k;
- vector2 = new Vector3(-180f, 0f, 0f);
- vPanierOldBoneRotRevAfter2[num13] = vector2;
- }
- }
- }
- if (this.m_bPanierOldBoneRotRev[k])
- {
- gameObject.transform.Rotate(this.m_vPanierOldBoneRotRevInit[k], Space.Self);
- }
- }
- this.m_aryPanierBoneTrs[k] = gameObject.transform;
- int num14 = 0;
- int num15 = 0;
- Transform transform3 = this.m_listHookBoneTrs[k];
- while (transform3.childCount > 0)
- {
- transform3 = transform3.GetChild(0);
- int num16 = num15 * this.m_nHookBoneCount + k;
- int num17 = (num15 + 1) * this.m_nHookBoneCount + k;
- GameObject gameObject2 = new GameObject(string.Concat(new object[]
- {
- "Skirt_P_",
- k,
- "_",
- 1 + num15
- }));
- gameObject2.transform.SetParent(this.m_aryPanierBoneTrs[num16], false);
- gameObject2.transform.position = transform3.position;
- gameObject2.transform.rotation = transform3.rotation;
- if (this.m_bOldBone)
- {
- ImportCM.OldSkirtBoneRev oldSkirtBoneRev2;
- if (flag)
- {
- this.m_bPanierOldBoneRotRev[num17] = true;
- this.m_vPanierOldBoneRotRevInit[num17] = vector;
- this.m_vPanierOldBoneRotRevAfter[num17] = vector2;
- }
- else if (!flag && dictionary != null && dictionary.TryGetValue(transform2.name, out oldSkirtBoneRev2))
- {
- this.m_bPanierOldBoneRotRev[num17] = true;
- this.m_vPanierOldBoneRotRevInit[num17] = oldSkirtBoneRev2.vRotRevInit;
- this.m_vPanierOldBoneRotRevAfter[num17] = oldSkirtBoneRev2.vRotRevAfter;
- flag = oldSkirtBoneRev2.bRecursiv;
- if (flag)
- {
- vector = oldSkirtBoneRev2.vRotRevInit;
- vector2 = oldSkirtBoneRev2.vRotRevAfter;
- }
- }
- if (this.m_bPanierOldBoneRotRev[num17])
- {
- gameObject2.transform.Rotate(this.m_vPanierOldBoneRotRevInit[num17], Space.Self);
- }
- }
- this.m_aryPanierBoneTrs[num17] = gameObject2.transform;
- num15++;
- num14++;
- }
- if (num7 < num14)
- {
- num7 = num14;
- }
- }
- this.m_aryPanierBoneDefRot = new Quaternion[this.m_nBoneCount];
- for (int l = 0; l < this.m_nHookBoneCount; l++)
- {
- Transform transform4 = this.m_aryPanierBoneTrs[l];
- this.m_aryPanierBoneDefRot[l] = transform4.localRotation;
- int num18 = 0;
- while (transform4.childCount > 0)
- {
- transform4 = transform4.GetChild(0);
- this.m_aryPanierBoneDefRot[(num18 + 1) * this.m_nHookBoneCount + l] = transform4.localRotation;
- num18++;
- }
- }
- this.m_aryLegSeqRadius[0] = 0.1630143f;
- this.m_aryLegSeqRadius[1] = 0.2130143f;
- this.m_aryLegSeqRadius[2] = 0.5f;
- this.m_aryLegSeqRadius[3] = 0.5f;
- this.m_aryLegSeqRadius[4] = 0.5f;
- this.m_aryLegSeqRadius[5] = 0.5f;
- this.m_nPanierBoneCount = this.m_nBoneCount;
- for (int m = 0; m < this.m_nBoneCount * 3; m++)
- {
- this.m_aryPanierBonePos[m] = this.m_aryBonePos[m];
- }
- this.m_nBodyBallCount = 2;
- Transform pelvis = this.m_Body.Pelvis;
- int num19 = 0;
- GameObject gameObject3 = new GameObject("Hit_HipL");
- gameObject3.transform.SetParent(pelvis);
- this.m_listBodyBallPos.Add(gameObject3.transform);
- DynamicBoneCollider dynamicBoneCollider;
- this.m_listBodyBall.Add(dynamicBoneCollider = gameObject3.AddComponent<DynamicBoneCollider>());
- dynamicBoneCollider.m_Radius = 0.09f;
- gameObject3.transform.localPosition = new Vector3(-0.0181f, -0.0319f, 0.0573f);
- gameObject3.transform.localScale = new Vector3(1f, 1f, 1f);
- this.m_aryBodyBallPos[3 * num19] = gameObject3.transform.position.x;
- this.m_aryBodyBallPos[3 * num19 + 1] = gameObject3.transform.position.y;
- this.m_aryBodyBallPos[3 * num19 + 2] = gameObject3.transform.position.z;
- this.m_aryBodyBallRadius[num19] = dynamicBoneCollider.GetLossyScale();
- num19 = 1;
- GameObject gameObject4 = new GameObject("Hit_HipR");
- gameObject4.transform.SetParent(pelvis);
- this.m_listBodyBallPos.Add(gameObject4.transform);
- this.m_listBodyBall.Add(dynamicBoneCollider = gameObject4.AddComponent<DynamicBoneCollider>());
- dynamicBoneCollider.m_Radius = 0.09f;
- gameObject4.transform.localPosition = new Vector3(-0.0181f, -0.0319f, -0.0573f);
- gameObject4.transform.localScale = new Vector3(1f, 1f, 1f);
- this.m_aryBodyBallPos[3 * num19] = gameObject4.transform.position.x;
- this.m_aryBodyBallPos[3 * num19 + 1] = gameObject4.transform.position.y;
- this.m_aryBodyBallPos[3 * num19 + 2] = gameObject4.transform.position.z;
- this.m_aryBodyBallRadius[num19] = dynamicBoneCollider.GetLossyScale();
- GameObject gameObject5 = new GameObject("Hit_Vag");
- gameObject5.transform.SetParent(pelvis);
- this.m_listBodyBallPos.Add(gameObject5.transform);
- this.m_listBodyBall.Add(dynamicBoneCollider = gameObject5.AddComponent<DynamicBoneCollider>());
- dynamicBoneCollider.m_Radius = 0.09f;
- gameObject5.transform.localPosition = new Vector3(-0.022f, 0.023f, 0f);
- gameObject5.transform.localScale = new Vector3(1f, 1f, 1f);
- this.m_nBodyCapsuleCount = 4;
- this.m_aryCapsuleBoneTrs = new Transform[this.m_nBodyCapsuleCount * 2];
- this.m_aryCapsuleBoneTrs[0] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Thigh", true);
- this.m_aryCapsuleBoneTrs[1] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Calf", true);
- this.m_aryCapsuleBoneTrs[2] = this.m_aryCapsuleBoneTrs[1];
- this.m_aryCapsuleBoneTrs[3] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 L Foot", true);
- this.m_aryCapsuleBoneTrs[4] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Thigh", true);
- this.m_aryCapsuleBoneTrs[5] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Calf", true);
- this.m_aryCapsuleBoneTrs[6] = this.m_aryCapsuleBoneTrs[5];
- this.m_aryCapsuleBoneTrs[7] = CMT.SearchObjName(this.m_Body.m_Bones.transform, "Bip01 R Foot", true);
- this.m_aryTestCapsule = new Transform[this.m_nBodyCapsuleCount * 2];
- for (int n = 0; n < this.m_nBodyCapsuleCount; n++)
- {
- this.m_aryBodyCapsulePos[6 * n] = this.m_aryCapsuleBoneTrs[2 * n].position.x;
- this.m_aryBodyCapsulePos[6 * n + 1] = this.m_aryCapsuleBoneTrs[2 * n].position.y;
- this.m_aryBodyCapsulePos[6 * n + 2] = this.m_aryCapsuleBoneTrs[2 * n].position.z;
- this.m_aryBodyCapsulePos[6 * n + 3] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.x;
- this.m_aryBodyCapsulePos[6 * n + 4] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.y;
- this.m_aryBodyCapsulePos[6 * n + 5] = this.m_aryCapsuleBoneTrs[2 * n + 1].position.z;
- this.m_aryBodyCapsuleRadius[n] = this.m_fRegDefaultRadius;
- }
- Vector3 vector3 = this.m_Body.Pelvis.TransformPoint(new Vector3(-1f, 0f, 0f));
- this.m_vLegPelvisToSpine[0] = vector3.x;
- this.m_vLegPelvisToSpine[1] = vector3.y;
- this.m_vLegPelvisToSpine[2] = vector3.z;
- Vector3 vector4 = this.m_Body.Pelvis.TransformPoint(new Vector3(0f, 1f, 0f)) - this.m_Body.Pelvis.position;
- this.m_vLegPelvisToSpine[3] = vector4.x;
- this.m_vLegPelvisToSpine[4] = vector4.y;
- this.m_vLegPelvisToSpine[5] = vector4.z;
- this.m_aryLegSeqRadius[0] = this.m_fLegSeqRad0;
- this.m_aryLegSeqRadius[1] = this.m_fLegSeqRad1;
- this.m_aryLegSeqRadius[2] = this.m_fLegSeqRad1;
- this.m_aryLegSeqRadius[3] = this.m_fLegSeqRad2;
- this.m_aryLegSeqRadius[4] = this.m_fLegSeqRad2;
- this.m_aryLegSeqRadius[5] = this.m_fLegSeqRad3;
- this.UpdateParameters();
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBonePos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryPanierBonePos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryHookBonePos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyBallPos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyBallRadius, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyCapsulePos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBodyCapsuleRadius, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryDebugLegSeqPos, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryLegSeqRadius, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_vLegPelvisToSpine, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryBoneParam, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryPanierForce, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryVelocityForceRate, GCHandleType.Pinned));
- this.m_listGcHandle.Add(GCHandle.Alloc(this.m_aryGravity, GCHandleType.Pinned));
- DynamicSkirtBone.m_dgExport_InitSkirt(this.m_nDllPhysicsInstanceID, this.m_aryHard[0], this.m_aryHard[1], this.m_aryHard[2], this.m_aryHard[3], this.m_aryBonePos, this.m_nBoneCount, this.m_nHookBoneCount, this.m_nBodyBallCount, this.m_aryBodyBallPos, this.m_aryBodyBallRadius, this.m_nBodyCapsuleCount, this.m_aryBodyCapsulePos, this.m_aryBodyCapsuleRadius, this.m_vLegPelvisToSpine, this.m_aryLegSeqRadius);
- return true;
- }
- public void OnPreFinalize()
- {
- if (DynamicSkirtBone.m_PluginDll != IntPtr.Zero)
- {
- if (this.m_nDllPhysicsInstanceID != -1)
- {
- DynamicSkirtBone.m_dgExport_PhysicsDelete(this.m_nDllPhysicsInstanceID);
- this.m_nDllPhysicsInstanceID = -1;
- }
- DynamicSkirtBone.FreeLibrary(DynamicSkirtBone.m_PluginDll);
- DynamicSkirtBone.m_PluginDll = IntPtr.Zero;
- }
- DynamicSkirtBone.m_dgExport_PhysicsCreate = null;
- DynamicSkirtBone.m_dgExport_PhysicsDelete = null;
- DynamicSkirtBone.m_dgExport_InitSkirt = null;
- DynamicSkirtBone.m_dgExport_GetBonePos = null;
- }
- private void OnDestroy()
- {
- this.Uninit();
- }
- private void OnValidate()
- {
- this.UpdateParameters();
- }
- public void Uninit()
- {
- if (this.m_nDllPhysicsInstanceID != -1)
- {
- if (DynamicSkirtBone.m_dgExport_PhysicsDelete != null)
- {
- DynamicSkirtBone.m_dgExport_PhysicsDelete(this.m_nDllPhysicsInstanceID);
- }
- this.m_nDllPhysicsInstanceID = -1;
- }
- foreach (Transform transform in this.m_listBodyBallPos)
- {
- UnityEngine.Object.Destroy(transform.gameObject);
- }
- this.m_listBodyBallPos.Clear();
- this.m_listBodyBall.Clear();
- for (int i = 0; i < this.m_listGcHandle.Count; i++)
- {
- GCHandle gchandle = this.m_listGcHandle[i];
- if (gchandle.IsAllocated)
- {
- gchandle.Free();
- }
- }
- this.m_listGcHandle.Clear();
- if (this.m_aryTestCapsule != null)
- {
- foreach (Transform transform2 in this.m_aryTestCapsule)
- {
- if (transform2 != null && transform2.gameObject != null)
- {
- UnityEngine.Object.DestroyImmediate(transform2.gameObject);
- }
- }
- this.m_aryTestCapsule = null;
- }
- }
- private void UpdateParameters()
- {
- bool flag = this.m_PanierRadiusDistrib != null && this.m_PanierRadiusDistrib.length != 0;
- bool flag2 = this.m_PanierForceDistrib != null && this.m_PanierForceDistrib.length != 0;
- bool flag3 = this.m_VelocityForceRateDistrib != null && this.m_VelocityForceRateDistrib.length != 0;
- bool flag4 = this.m_GravityDistrib != null && this.m_GravityDistrib.length != 0;
- int nH;
- for (nH = 0; nH < this.m_nHookBoneCount; nH++)
- {
- DynamicSkirtBone.PanierRadiusGroup panierRadiusGroup = null;
- if (this.m_PanierRadiusDistribGroup != null)
- {
- panierRadiusGroup = Array.Find<DynamicSkirtBone.PanierRadiusGroup>(this.m_PanierRadiusDistribGroup, (DynamicSkirtBone.PanierRadiusGroup a) => a.strBoneName == this.m_aryBoneTrs[nH].name);
- }
- int num = this.m_nBoneCount / this.m_nHookBoneCount;
- for (int i = 0; i < num; i++)
- {
- int num2 = i * this.m_nHookBoneCount + nH;
- float time = this.m_aryBoneLength[num2];
- if (panierRadiusGroup == null)
- {
- float num3 = this.m_fPanierRadius;
- if (flag)
- {
- num3 *= this.m_PanierRadiusDistrib.Evaluate(time);
- }
- this.m_aryPanierRadius[num2] = num3;
- }
- else
- {
- float num4 = panierRadiusGroup.fRadius;
- if (panierRadiusGroup.Curve != null && panierRadiusGroup.Curve.length != 0)
- {
- num4 *= panierRadiusGroup.Curve.Evaluate(time);
- }
- this.m_aryPanierRadius[num2] = num4;
- }
- float num5 = this.m_fPanierForce;
- if (flag2)
- {
- num5 *= this.m_PanierForceDistrib.Evaluate(time);
- }
- this.m_aryPanierForce[num2] = num5;
- float num6 = this.m_fVelocityForceRate;
- if (flag3)
- {
- num6 *= this.m_VelocityForceRateDistrib.Evaluate(time);
- }
- this.m_aryVelocityForceRate[num2] = num6;
- Vector3 a2 = this.m_vGravity;
- if (flag4)
- {
- a2 *= this.m_GravityDistrib.Evaluate(time);
- }
- this.m_aryGravity[num2 * 3] = a2.x;
- this.m_aryGravity[num2 * 3 + 1] = a2.y;
- this.m_aryGravity[num2 * 3 + 2] = a2.z;
- }
- }
- }
- public void UpdateSelf()
- {
- if (DynamicSkirtBone.m_dgExport_GetBonePos == null)
- {
- return;
- }
- if (this.m_listBoneScaleDef.Count != 0)
- {
- for (int i = 0; i < this.m_listBoneScaleDef.Count; i++)
- {
- BoneScaleDef boneScaleDef = this.m_listBoneScaleDef[i];
- boneScaleDef.trTarget.localScale = Vector3.one;
- }
- }
- Transform transform = this.m_aryCapsuleBoneTrs[0];
- Transform transform2 = this.m_aryCapsuleBoneTrs[1];
- Transform transform3 = this.m_aryCapsuleBoneTrs[4];
- Transform transform4 = this.m_aryCapsuleBoneTrs[5];
- Vector3 vector = transform.position;
- Vector3 vector2 = transform3.position;
- Vector3 position = transform2.position;
- Vector3 position2 = transform4.position;
- Plane plane = new Plane(vector, position2, position);
- bool flag;
- if (!plane.GetSide(vector2))
- {
- flag = false;
- float distanceToPoint = plane.GetDistanceToPoint(vector2);
- Vector3 vector3 = vector2 - plane.normal.normalized * distanceToPoint;
- vector2 = vector3;
- }
- else
- {
- Plane plane2 = new Plane(vector2, position2, position);
- flag = true;
- float distanceToPoint2 = plane2.GetDistanceToPoint(vector);
- Vector3 vector4 = vector - plane2.normal.normalized * distanceToPoint2;
- vector = vector4;
- }
- Vector3 a = transform2.position - vector;
- Vector3 a2 = transform4.position - vector2;
- int num = 1;
- int num2 = num * 2;
- Vector3 a3 = a * (1f / (float)num);
- Vector3 a4 = a2 * (1f / (float)num);
- if (this.m_aryLegSegPory == null || this.m_aryLegSegPory.Length != num2 * 3)
- {
- this.m_aryLegSegPory = new Vector3[num2 * 3];
- this.m_aryLegSegPoryVec = new Vector3[num2 * 2];
- this.m_aryLegSegPlane = new Plane[num2];
- }
- for (int j = 0; j < num; j++)
- {
- Vector3 vector5 = vector + a3 * (float)j;
- Vector3 vector6 = vector2 + a4 * (float)j;
- Vector3 vector7 = vector + a3 * (float)(j + 1);
- Vector3 vector8 = vector2 + a4 * (float)(j + 1);
- if (flag)
- {
- this.m_aryLegSegPory[6 * j] = vector5;
- this.m_aryLegSegPory[6 * j + 1] = vector6;
- this.m_aryLegSegPory[6 * j + 2] = vector7;
- this.m_aryLegSegPoryVec[4 * j] = vector6 - vector5;
- this.m_aryLegSegPoryVec[4 * j + 1] = vector7 - vector5;
- this.m_aryLegSegPlane[2 * j].Set3Points(vector7, vector6, vector5);
- this.m_aryLegSegPory[6 * j + 3] = vector6;
- this.m_aryLegSegPory[6 * j + 4] = vector8;
- this.m_aryLegSegPory[6 * j + 5] = vector7;
- this.m_aryLegSegPoryVec[4 * j + 2] = vector8 - vector6;
- this.m_aryLegSegPoryVec[4 * j + 3] = vector7 - vector6;
- this.m_aryLegSegPlane[2 * j + 1].Set3Points(vector7, vector8, vector6);
- }
- else
- {
- this.m_aryLegSegPory[6 * j] = vector5;
- this.m_aryLegSegPory[6 * j + 1] = vector6;
- this.m_aryLegSegPory[6 * j + 2] = vector8;
- this.m_aryLegSegPoryVec[4 * j] = vector6 - vector5;
- this.m_aryLegSegPoryVec[4 * j + 1] = vector8 - vector5;
- this.m_aryLegSegPlane[2 * j].Set3Points(vector8, vector6, vector5);
- this.m_aryLegSegPory[6 * j + 3] = vector5;
- this.m_aryLegSegPory[6 * j + 4] = vector8;
- this.m_aryLegSegPory[6 * j + 5] = vector7;
- this.m_aryLegSegPoryVec[4 * j + 2] = vector8 - vector5;
- this.m_aryLegSegPoryVec[4 * j + 3] = vector7 - vector5;
- this.m_aryLegSegPlane[2 * j + 1].Set3Points(vector7, vector8, vector5);
- }
- }
- float num3 = this.m_fRegDefaultRadius;
- TMorph morph = this.m_Body.goSlot[0].morph;
- float blendValues = morph.GetBlendValues(morph.BlendDataIdx_RegFat);
- float blendValues2 = morph.GetBlendValues(morph.BlendDataIdx_RegMeet);
- float num4 = (blendValues + blendValues2) * 0.5f;
- if (this.m_fRegFatThrethold <= num4)
- {
- num3 *= this.m_fRegFatRateMin + (this.m_fRegFatRateMax - this.m_fRegFatRateMin) * (num4 - this.m_fRegFatThrethold);
- }
- float num5 = 0f;
- this.m_fEasingScale = Mathf.SmoothDamp(this.m_fEasingScale, this.m_fScaleTo, ref num5, this.m_fScaleEaseSpeed);
- float num6 = 0f;
- for (int k = 0; k < this.m_nHookBoneCount; k++)
- {
- float num7 = 0f;
- float num8 = 0f;
- Transform transform5 = this.m_aryPanierBoneTrs[k];
- Transform transform6 = transform5;
- Vector3 position3 = transform6.position;
- Vector3 up = transform6.up;
- Transform transform7 = transform5;
- transform5.localRotation = this.m_aryPanierBoneDefRot[k];
- int num9 = k;
- int num10 = 0;
- Transform transform8 = transform5;
- while (transform8.childCount != 0)
- {
- int num11 = (num10 + 1) * this.m_nHookBoneCount + k;
- Transform transform9 = this.m_aryPanierBoneTrs[num11];
- transform9.localRotation = this.m_aryPanierBoneDefRot[num11];
- transform8 = (transform7 = transform9);
- num10++;
- }
- if (this.m_bEnableStressScale)
- {
- transform5.localScale = new Vector3(this.m_fEasingScale, this.m_fEasingScale, this.m_fEasingScale);
- this.m_aryBoneTrs[k].localScale = new Vector3(this.m_fEasingScale, this.m_fEasingScale, this.m_fEasingScale);
- }
- else
- {
- transform5.localScale = Vector3.one;
- this.m_aryBoneTrs[k].localScale = Vector3.one;
- }
- Vector3 vector9 = transform6.position + transform6.TransformVector(Vector3.right);
- this.m_fPanierVecAngle[k] = 0f;
- for (int l = 0; l < num2; l++)
- {
- float d = 0f;
- float distanceToPoint3 = this.m_aryLegSegPlane[l].GetDistanceToPoint(position3);
- if (-this.m_fAdjustRegSegPoly < distanceToPoint3 && distanceToPoint3 < this.m_fAdjustRegSegPoly)
- {
- Vector3 b;
- if (distanceToPoint3 < 0f)
- {
- b = this.m_aryLegSegPlane[l].normal * this.m_fAdjustRegSegPoly;
- }
- else
- {
- b = this.m_aryLegSegPlane[l].normal * -this.m_fAdjustRegSegPoly;
- }
- if (flag)
- {
- this.m_aryLegSegPory[l * 3] += b;
- this.m_aryLegSegPory[l * 3 + 1] += b;
- this.m_aryLegSegPory[l * 3 + 2] += b;
- this.m_aryLegSegPlane[l].Set3Points(this.m_aryLegSegPory[l * 3 + 2], this.m_aryLegSegPory[l * 3 + 1], this.m_aryLegSegPory[l * 3]);
- }
- else
- {
- this.m_aryLegSegPory[l * 3] += b;
- this.m_aryLegSegPory[l * 3 + 1] += b;
- this.m_aryLegSegPory[l * 3 + 2] += b;
- this.m_aryLegSegPlane[l].Set3Points(this.m_aryLegSegPory[l * 3 + 2], this.m_aryLegSegPory[l * 3 + 1], this.m_aryLegSegPory[l * 3]);
- }
- }
- Vector3 tvec = position3 - this.m_aryLegSegPory[l * 3];
- if (MathCM.TriangleLineIntersect(position3, vector9, tvec, this.m_aryLegSegPory[l * 3], this.m_aryLegSegPoryVec[l * 2], this.m_aryLegSegPoryVec[l * 2 + 1], ref d))
- {
- this.m_fPanierVecAngle[k] = 1f;
- Vector3 a5 = vector9;
- Vector3 b2 = (a5 - position3).normalized * d;
- Vector3 a6 = position3 + b2;
- transform6.Rotate(-Vector3.forward, 1f, Space.Self);
- float d2 = 0f;
- Vector3 a7 = position3 + transform6.TransformVector(Vector3.right);
- Vector3 direction = a7 - position3;
- if (this.m_aryLegSegPlane[l].Raycast(new Ray(position3, direction), out d2))
- {
- this.m_fPanierVecAngle[k] = 2f;
- Vector3 vector10 = position3 + direction.normalized * d2;
- Vector3 vector11 = a6 - vector10;
- Vector3 zero = Vector3.zero;
- if (MathCM.SphireRayIntersect(vector10 + vector11.normalized * 10f, -vector11.normalized, position3, (position3 - transform7.position).magnitude, ref zero))
- {
- this.m_fPanierVecAngle[k] = 3f;
- float num12 = Vector3.Angle(zero - position3, transform7.position - position3);
- transform6.Rotate(-Vector3.forward, num12 + 1f);
- num8 += num12 + 1f;
- break;
- }
- }
- }
- }
- num10 = 0;
- while (transform5.childCount != 0)
- {
- int num13 = (num10 + 1) * this.m_nHookBoneCount + k;
- Transform transform9 = this.m_aryPanierBoneTrs[num13];
- bool flag2 = false;
- float num14 = 10f;
- for (int m = 0; m < this.m_listBodyBall.Count; m++)
- {
- DynamicBoneCollider dynamicBoneCollider = this.m_listBodyBall[m] as DynamicBoneCollider;
- Transform transform10 = dynamicBoneCollider.transform;
- float lossyScale = dynamicBoneCollider.GetLossyScale();
- float num15 = this.m_aryPanierRadius[num13];
- Vector3 position4 = transform9.position;
- float magnitude = (transform10.position - transform9.position).magnitude;
- if (dynamicBoneCollider.Collide(ref position4, num15))
- {
- flag2 = true;
- for (float num16 = 0f; num16 < 360f; num16 += 1f)
- {
- transform5.Rotate(-Vector3.forward, 1f, Space.Self);
- position4 = transform9.position;
- num8 += 1f;
- magnitude = (transform10.position - transform9.position).magnitude;
- if (!dynamicBoneCollider.Collide(ref position4, num15))
- {
- break;
- }
- }
- }
- if (magnitude - (lossyScale + num15) < num14)
- {
- num14 = magnitude - (lossyScale + num15);
- }
- }
- bool flag3 = false;
- for (int n = 0; n < this.m_nBodyCapsuleCount; n++)
- {
- float num17 = this.m_fRegDefaultRadius;
- if (n == 0 || n == 2)
- {
- num17 = num3;
- }
- this.m_aryBodyCapsuleRadius[n] = num17;
- Transform transform11 = this.m_aryCapsuleBoneTrs[2 * n];
- Transform transform12 = this.m_aryCapsuleBoneTrs[2 * n + 1];
- MathCM.Segment segment = new MathCM.Segment(transform11.position, transform12.position);
- float num18 = this.m_aryPanierRadius[num13];
- Vector3 position5 = transform9.position;
- Vector3 vector12;
- float num20;
- float num19 = MathCM.calcPointSegmentDist(ref position5, ref segment, out vector12, out num20);
- if (num19 < num17 + num18)
- {
- flag2 = (flag3 = true);
- Vector3 position6 = transform5.position;
- float num21 = 0f;
- float num22;
- for (num22 = 0f; num22 < 360f; num22 += 1f)
- {
- transform5.Rotate(-Vector3.forward, 1f, Space.Self);
- position5 = transform9.position;
- num21 += 1f;
- num8 += 1f;
- if (MathCM.calcPointSegmentDist(ref position5, ref segment, out vector12, out num20) > num17 + num18)
- {
- this.m_aryPanierBoneBeforeRotAngle[num9] = num21;
- break;
- }
- }
- if (358f <= num22)
- {
- if (this.m_bGizmoDraw)
- {
- Debug.DrawLine(transform5.position, transform9.position, Color.red);
- }
- transform5.Rotate(-Vector3.forward, this.m_aryPanierBoneBeforeRotAngle[num9], Space.Self);
- }
- }
- if (num19 - (num17 + num18) < num14)
- {
- num14 = num19 - (num17 + num18);
- }
- }
- if (!flag3)
- {
- this.m_aryPanierBoneBeforeRotAngle[num9] = 0f;
- }
- if (!flag2)
- {
- float num23 = this.m_fPanierForce;
- if (this.m_PanierForceDistrib != null && this.m_PanierForceDistrib.length != 0)
- {
- num23 *= this.m_PanierForceDistrib.Evaluate(this.m_aryBoneLengthRate[num13]);
- }
- this.m_aryPanierForce[num13] = num23;
- if (0f < this.m_fPanierForceDistanceThreshold && num14 <= this.m_fPanierForceDistanceThreshold)
- {
- this.m_aryPanierForce[num13] += (1f - num23) * (1f - num14 / this.m_fPanierForceDistanceThreshold) * this.m_fPanierStressForce;
- }
- }
- else
- {
- this.m_aryPanierForce[num13] = 1f * this.m_fPanierStressForce;
- }
- num7 += num8;
- num8 = 0f;
- Quaternion quaternion = this.m_aryPanierBoneDefRot[num13];
- num9 = num13;
- transform5 = transform9;
- num10++;
- }
- if (this.m_bEnableLegSegHit)
- {
- for (int num24 = 0; num24 < num2; num24++)
- {
- float d3 = 0f;
- Vector3 tvec2 = position3 - this.m_aryLegSegPory[num24 * 3];
- if (MathCM.TriangleLineIntersect(position3, transform7.position, tvec2, this.m_aryLegSegPory[num24 * 3], this.m_aryLegSegPoryVec[num24 * 2], this.m_aryLegSegPoryVec[num24 * 2 + 1], ref d3))
- {
- Vector3 position7 = transform7.position;
- Vector3 b3 = (position7 - position3).normalized * d3;
- Vector3 a8 = position3 + b3;
- transform6.Rotate(-Vector3.forward, 1f, Space.Self);
- float d4 = 0f;
- Vector3 direction2 = transform7.position - position3;
- if (this.m_aryLegSegPlane[num24].Raycast(new Ray(position3, direction2), out d4))
- {
- Vector3 vector13 = position3 + direction2.normalized * d4;
- Vector3 vector14 = a8 - vector13;
- Vector3 zero2 = Vector3.zero;
- if (MathCM.SphireRayIntersect(vector13 - vector14.normalized * 10f, vector14.normalized, position3, (position3 - position7).magnitude, ref zero2))
- {
- float num25 = Vector3.Angle(zero2 - position3, position7 - position3);
- transform6.Rotate(-Vector3.forward, num25 + 1f);
- num7 += num25 + 1f;
- break;
- }
- }
- }
- }
- }
- this.m_fPanierStress[k] = num7;
- if (num6 < num7)
- {
- num6 = num7;
- }
- }
- if (this.m_fStressDgreeMin < num6)
- {
- float num26 = Mathf.Clamp(num6, this.m_fStressDgreeMin, this.m_fStressDgreeMax);
- this.m_fScaleTo = 1f - (1f - this.m_fStressMinScale) * ((num26 - this.m_fStressDgreeMin) / (this.m_fStressDgreeMax - this.m_fStressDgreeMin));
- }
- else
- {
- this.m_fScaleTo = 1f;
- }
- for (int num27 = 0; num27 < this.m_nHookBoneCount; num27++)
- {
- Vector3 position8 = this.m_listHookBoneTrs[num27].position;
- this.m_aryHookBonePos[3 * num27] = position8.x;
- this.m_aryHookBonePos[3 * num27 + 1] = position8.y;
- this.m_aryHookBonePos[3 * num27 + 2] = position8.z;
- }
- for (int num28 = 0; num28 < this.m_aryPanierBoneTrs.Length; num28++)
- {
- Transform transform13 = this.m_aryPanierBoneTrs[num28].transform;
- this.m_aryPanierBonePos[3 * num28] = transform13.position.x;
- this.m_aryPanierBonePos[3 * num28 + 1] = transform13.position.y;
- this.m_aryPanierBonePos[3 * num28 + 2] = transform13.position.z;
- }
- for (int num29 = 0; num29 < this.m_nBodyBallCount; num29++)
- {
- Transform transform14 = this.m_listBodyBallPos[num29];
- this.m_aryBodyBallPos[3 * num29] = transform14.position.x;
- this.m_aryBodyBallPos[3 * num29 + 1] = transform14.position.y;
- this.m_aryBodyBallPos[3 * num29 + 2] = transform14.position.z;
- }
- for (int num30 = 0; num30 < this.m_nBodyCapsuleCount; num30++)
- {
- this.m_aryBodyCapsulePos[6 * num30] = this.m_aryCapsuleBoneTrs[2 * num30].position.x;
- this.m_aryBodyCapsulePos[6 * num30 + 1] = this.m_aryCapsuleBoneTrs[2 * num30].position.y;
- this.m_aryBodyCapsulePos[6 * num30 + 2] = this.m_aryCapsuleBoneTrs[2 * num30].position.z;
- this.m_aryBodyCapsulePos[6 * num30 + 3] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.x;
- this.m_aryBodyCapsulePos[6 * num30 + 4] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.y;
- this.m_aryBodyCapsulePos[6 * num30 + 5] = this.m_aryCapsuleBoneTrs[2 * num30 + 1].position.z;
- }
- Vector3 vector15 = this.m_Body.Pelvis.TransformPoint(new Vector3(-1f, 0f, 0f));
- this.m_vLegPelvisToSpine[0] = vector15.x;
- this.m_vLegPelvisToSpine[1] = vector15.y;
- this.m_vLegPelvisToSpine[2] = vector15.z;
- Vector3 vector16 = this.m_Body.Pelvis.TransformPoint(new Vector3(0f, 1f, 0f)) - this.m_Body.Pelvis.position;
- this.m_vLegPelvisToSpine[3] = vector16.x;
- this.m_vLegPelvisToSpine[4] = vector16.y;
- this.m_vLegPelvisToSpine[5] = vector16.z;
- this.m_aryLegSeqRadius[0] = this.m_fLegSeqRad0;
- this.m_aryLegSeqRadius[1] = this.m_fLegSeqRad1;
- this.m_aryLegSeqRadius[2] = this.m_fLegSeqRad1;
- this.m_aryLegSeqRadius[3] = this.m_fLegSeqRad2;
- this.m_aryLegSeqRadius[4] = this.m_fLegSeqRad2;
- this.m_aryLegSeqRadius[5] = this.m_fLegSeqRad3;
- DynamicSkirtBone.m_dgExport_GetBonePos(this.m_nDllPhysicsInstanceID, this.m_nCalcTime, this.m_aryHookBonePos, this.m_nHookBoneCount, this.m_aryPanierBonePos, this.m_nPanierBoneCount, this.m_aryBonePos, this.m_nBoneCount, this.m_aryPanierForce, this.m_nBodyBallCount, this.m_aryBodyBallPos, this.m_nBodyCapsuleCount, this.m_aryBodyCapsulePos, this.m_aryBoneNormal, this.m_aryDebugLegSeqPos, this.m_aryLegSeqRadius, this.m_vLegPelvisToSpine, this.m_aryBoneParam, this.m_aryVelocityForceRate, this.m_aryGravity, this.m_aryHard, (!this.m_bResetPos) ? 0 : 1, this.m_Body.BoneHitHeightY + this.m_fFloorOffsetY);
- for (int num31 = 0; num31 < this.m_nHookBoneCount; num31++)
- {
- int num32 = this.m_nBoneCount / this.m_nHookBoneCount;
- for (int num33 = 0; num33 < num32; num33++)
- {
- int num34 = num31 + num33 * this.m_nHookBoneCount;
- Vector3 vector17 = new Vector3(this.m_aryBonePos[3 * num34], this.m_aryBonePos[3 * num34 + 1], this.m_aryBonePos[3 * num34 + 2]);
- Transform transform15 = this.m_aryBoneTrs[num34];
- transform15.position = vector17;
- if (num33 < num32 - 1)
- {
- int num35 = num31 + (num33 + 1) * this.m_nHookBoneCount;
- Vector3 a9 = new Vector3(this.m_aryBonePos[3 * num35], this.m_aryBonePos[3 * num35 + 1], this.m_aryBonePos[3 * num35 + 2]);
- Vector3 lhs = new Vector3(this.m_aryBoneNormal[3 * num34], this.m_aryBoneNormal[3 * num34 + 1], this.m_aryBoneNormal[3 * num34 + 2]);
- Vector3 vector18 = a9 - vector17;
- Vector3 vector19 = Vector3.Cross(lhs, vector18);
- Quaternion rotation = Quaternion.AngleAxis(-90f, vector19);
- vector18 = rotation * vector18;
- transform15.rotation = Quaternion.LookRotation(vector19, vector18);
- }
- if (this.m_bOldBone && this.m_bPanierOldBoneRotRev[num34])
- {
- transform15.Rotate(this.m_vPanierOldBoneRotRevAfter[num34], Space.Self);
- }
- }
- }
- if (this.m_listBoneScaleDef.Count != 0)
- {
- for (int num36 = 0; num36 < this.m_listBoneScaleDef.Count; num36++)
- {
- BoneScaleDef boneScaleDef2 = this.m_listBoneScaleDef[num36];
- boneScaleDef2.trTarget.localScale = boneScaleDef2.vDefScale;
- }
- }
- this.m_bResetPos = false;
- }
- [Header("■パニエ ノードサイズ")]
- public float m_fPanierRadius = 0.025f;
- public AnimationCurve m_PanierRadiusDistrib;
- public bool m_bPanierNodeGizmoDraw;
- [Header("■パニエ ノードサイズの上書き")]
- [SerializeField]
- public DynamicSkirtBone.PanierRadiusGroup[] m_PanierRadiusDistribGroup;
- [Header("■パニエ 力")]
- [Range(0f, 1f)]
- public float m_fPanierForce = 0.134f;
- public AnimationCurve m_PanierForceDistrib;
- public bool m_bPanierLineGizmoDraw;
- [Header("■パニエ 重力適応割合(初期パニエノード回転から重力方向への力の割合)")]
- [Range(0f, 1f)]
- public float m_fPanierGravityRate;
- [Header("■パニエ 当たっていない場合の戻る力")]
- [Range(0f, 2f)]
- public float m_fPanierStiffnessRate;
- [Header("■パニエ 足に当っていた場合の強制パニエ力")]
- [Range(0f, 1f)]
- public float m_fPanierStressForce = 0.4f;
- [Header("■パニエ 足との距離によるパニエ力")]
- public float m_fPanierForceDistanceThreshold = 0.1f;
- [Header("■パニエ 角度による全体のスケーリング")]
- [Tooltip("水平方向に伸びて見えるのを防ぐ。")]
- public bool m_bEnableStressScale = true;
- public float m_fStressDgreeMin = 45f;
- public float m_fStressDgreeMax = 90f;
- public float m_fStressMinScale = 0.75f;
- [ReadOnly]
- public float m_fScaleTo = 1f;
- [ReadOnly]
- public float m_fEasingScale = 1f;
- public float m_fScaleEaseSpeed = 5f;
- [ReadOnly]
- public float[] m_fPanierStress;
- [ReadOnly]
- public float[] m_fPanierVecAngle;
- [Header("■パニエ 足の間の当たり判定")]
- public bool m_bEnableLegSegHit = true;
- public float m_fLegSegHitDgree = 45f;
- [Header("■パニエ 足側カプセル初期半径")]
- public float m_fRegDefaultRadius = 0.1f;
- [Header("■パニエ 腿判定の足の太さによる補正 掛け算")]
- public bool m_bEnableRegFatAndMeetAdjust = true;
- public float m_fRegFatThrethold = 0.5f;
- public float m_fRegFatRateMin = 1f;
- public float m_fRegFatRateMax = 1.3f;
- [Header("■パニエ 股間ポリゴン判定 親自体がポリゴンに近接している場合のポリゴン位置補正")]
- public float m_fAdjustRegSegPoly = 0.005f;
- [Header("■物理 計算回数")]
- public int m_nCalcTime = 16;
- [Header("■物理 惰性割合")]
- public float m_fVelocityForceRate = 0.8f;
- public AnimationCurve m_VelocityForceRateDistrib;
- [Header("■物理 重力")]
- public Vector3 m_vGravity = new Vector3(0f, -0.005f, 0f);
- public AnimationCurve m_GravityDistrib;
- [Header("■物理 繋がり力(横縮,横伸,縦縮,縦伸)(物理計算回数に依存)")]
- public float[] m_aryHard = new float[]
- {
- 0f,
- 0.01f,
- 0f,
- 0.7f
- };
- [Header("■物理 床判定オフセット")]
- public float m_fFloorOffsetY = -0.03f;
- public bool m_RealBoneAndNormalGizmoDraw = true;
- [Header("")]
- public float m_fLegSeqRad0 = 0.1f;
- public float m_fLegSeqRad1 = 0.1f;
- public float m_fLegSeqRad2 = 0.1f;
- public float m_fLegSeqRad3 = 0.1f;
- [Header("")]
- public bool m_bGizmoDraw = true;
- public bool m_bResetPos;
- public const int SKIRT_W_MAX = 24;
- public const int SKIRT_H_MAX = 48;
- private Transform[] m_aryBoneTrs = new Transform[1152];
- private float[] m_aryBonePos = new float[6144];
- private int m_nBoneCount;
- private int[] m_aryBoneParam = new int[2048];
- private float[] m_aryBoneLength = new float[1152];
- private float[] m_aryBoneLengthRate = new float[1152];
- private float[] m_aryBoneNormal = new float[6144];
- private Transform m_trPanierParent;
- private float[] m_aryPanierBonePos = new float[6144];
- private int m_nPanierBoneCount;
- private Transform[] m_aryPanierBoneTrs;
- private Transform[] m_aryPanierPanierBoneTrs;
- private float[] m_aryPanierForce;
- private Quaternion[] m_aryPanierBoneDefRot;
- private float[] m_aryPanierBoneToLegSegRate;
- private float[] m_aryPanierBoneBeforeRotAngle;
- private bool[] m_bPanierOldBoneRotRev;
- private Vector3[] m_vPanierOldBoneRotRevInit;
- private Vector3[] m_vPanierOldBoneRotRevAfter;
- private Transform[] m_aryPanierLastChildDef;
- private float[] m_aryPanierRadius;
- private float[] m_aryVelocityForceRate;
- private float[] m_aryGravity;
- private List<Transform> m_listHookBoneTrs;
- private float[] m_aryHookBonePos = new float[6144];
- private int m_nHookBoneCount;
- private List<Transform> m_listBodyBallPos = new List<Transform>();
- private float[] m_aryBodyBallPos = new float[6144];
- private float[] m_aryBodyBallRadius = new float[2048];
- private int m_nBodyBallCount;
- public List<DynamicBoneColliderBase> m_listBodyBall = new List<DynamicBoneColliderBase>();
- private Transform[] m_aryCapsuleBoneTrs;
- private float[] m_aryBodyCapsulePos = new float[12288];
- private float[] m_aryBodyCapsuleRadius = new float[2048];
- private int m_nBodyCapsuleCount;
- private float[] m_aryDebugLegSeqPos = new float[120];
- private float[] m_vLegPelvisToSpine = new float[6];
- private float[] m_aryLegSeqRadius = new float[20];
- private TBody m_Body;
- private TBodySkin m_BodySkin;
- private Transform[] m_aryTestCapsule;
- private List<BoneScaleDef> m_listBoneScaleDef = new List<BoneScaleDef>();
- private bool m_bOldBone;
- private const string kUseDllPath_x64 = "Plugins/";
- private static IntPtr m_PluginDll = IntPtr.Zero;
- private List<GCHandle> m_listGcHandle = new List<GCHandle>();
- private int m_nDllPhysicsInstanceID = -1;
- private static DynamicSkirtBone.Export_PhysicsCreate m_dgExport_PhysicsCreate = null;
- private static DynamicSkirtBone.Export_PhysicsDelete m_dgExport_PhysicsDelete = null;
- private static DynamicSkirtBone.Export_InitSkirt m_dgExport_InitSkirt = null;
- private static DynamicSkirtBone.Export_GetBonePos m_dgExport_GetBonePos = null;
- private GameObject m_point;
- private GameObject m_capsule;
- private float m_fMaxLenght;
- private Vector3 m_testLineA;
- private Transform m_testGoRay;
- private Transform m_testGoTriA;
- private Transform m_testGoTriB;
- private Transform m_testGoTriC;
- private Vector3[] m_aryLegSegPory;
- private Vector3[] m_aryLegSegPoryVec;
- private Plane[] m_aryLegSegPlane;
- [Serializable]
- public class PanierRadiusGroup
- {
- [SerializeField]
- public string strBoneName;
- [SerializeField]
- public float fRadius;
- [SerializeField]
- public AnimationCurve Curve;
- }
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate int Export_PhysicsCreate();
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate void Export_PhysicsDelete(int f_nID);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate void Export_InitSkirt(int f_nID, float f_fHardHShort, float f_fHardHLong, float f_HardVShort, float f_HardVLong, float[] f_aryBonePos, int f_nBoneCount, int f_nSWidth, int f_nBallCount, float[] f_aryBallPos, float[] f_aryBallRadius, int f_nCapsuleCount, float[] f_aryCapsulePos, float[] f_aryCapsuleRadius, float[] f_vLegPelvisToSpine, float[] f_aryLegSeqRadius);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- private delegate void Export_GetBonePos(int f_nID, int f_nCalcTime, float[] f_aryHookBonePos, int f_nHookBoneCount, float[] f_aryPanierBonePos, int f_nPanierBoneCount, float[] f_aryBonePos, int f_nBoneCount, float[] f_aryPanierForce, int f_nBallCount, float[] f_aryBallPos, int f_nCapsuleCount, float[] f_aryCapsulePos, float[] f_aryNodeNormal, float[] f_aryDebugLegSeqPos, float[] f_aryLegSeqRadius, float[] f_aryLegPelvisToSpine, int[] f_aryBoneParam, float[] f_aryVelocityForceRate, float[] f_aryGravity, float[] f_aryHard, int f_bReset, float f_fFloorY);
- }
|