// Decompiled with JetBrains decompiler // Type: Eden.AutoMorpher.BodyPoseMatchUtil // Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0 // Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll using System.Collections.Generic; using UnityEngine; namespace Eden.AutoMorpher { public class BodyPoseMatchUtil { private WorldVertexUtil _worldVertexUtil; private MeshClassifier meshClassifier; private BodyPoseMatch_CommonUtil poseMatchCommonUtil; private bool doDebug; public BodyPoseMatchUtil() { this._worldVertexUtil = new WorldVertexUtil(); this.meshClassifier = new MeshClassifier(); this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); } public GameObject AutoAdjustBodyPose( GameObject sourceAvatar, IReadOnlyList sourceBodyMeshes, GameObject targetAvatar, IReadOnlyList targetBodyMeshes, out Dictionary sourceToProxy, float neckTargetHeight = 1.5f, bool onlyScaling = false) { Animator component1 = sourceAvatar.GetComponent(); Animator component2 = targetAvatar.GetComponent(); if (Object.op_Equality((Object)component1, (Object)null) || Object.op_Equality((Object)component2, (Object)null)) { Debug.LogError((object)"[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다."); sourceToProxy = new Dictionary(); return (GameObject)null; } Dictionary> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component1, sourceBodyMeshes); Dictionary> dictionary1 = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes); BodyPoseMatchSetupUtil poseMatchSetupUtil = new BodyPoseMatchSetupUtil(); poseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight); poseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary1, neckTargetHeight); List proxyBodyMeshes; GameObject bodyProxy = poseMatchSetupUtil.CreateBodyProxy(component1, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy); Animator component3 = bodyProxy.GetComponent(); if (onlyScaling) { bodyProxy.transform.SetParent(targetAvatar.transform); bodyProxy.transform.localPosition = Vector3.zero; return bodyProxy; } Dictionary> dictionary2 = this.meshClassifier.MeshHumanoidBoneMatcher(component3, (IReadOnlyList)proxyBodyMeshes); if (dictionary2 == null || dictionary2.Count == 0) throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); bodyProxy.transform.SetParent(targetAvatar.transform); bodyProxy.transform.localPosition = Vector3.zero; List bakedBodyMeshList1 = new List(); foreach (SkinnedMeshRenderer _smr in proxyBodyMeshes) bakedBodyMeshList1.Add(new BakedBodyMesh(_smr)); List bakedBodyMeshList2 = new List(); foreach (SkinnedMeshRenderer targetBodyMesh in (IEnumerable)targetBodyMeshes) bakedBodyMeshList2.Add(new BakedBodyMesh(targetBodyMesh)); BodyPoseMatch_Torso bodyPoseMatchTorso = new BodyPoseMatch_Torso(); bodyPoseMatchTorso.AlignTorsoByNeck(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1); if (this.doDebug) { bodyPoseMatchTorso.DrawTorsoPcaDebug(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, Color.yellow, Color.cyan, duration: 20f); bodyPoseMatchTorso.DrawTorsoPcaDebug(targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1, Color.red, Color.green, duration: 20f); } foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1) bakedBodyMesh.ReBakeMesh(); BodyPoseMatch_Arm bodyPoseMatchArm = new BodyPoseMatch_Arm(); bodyPoseMatchArm.AlignUpperArmByArmPcaCenters((IReadOnlyList)bakedBodyMeshList1, dictionary2, (IReadOnlyList)bakedBodyMeshList2, dictionary1); if (this.doDebug) { bodyPoseMatchArm.DrawArmPcaDebug(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, true, Color.yellow, Color.cyan, duration: 20f); bodyPoseMatchArm.DrawArmPcaDebug(targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1, true, Color.red, Color.green, duration: 20f); } foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1) bakedBodyMesh.ReBakeMesh(); bodyPoseMatchArm.ScalingBothArmsLength((IReadOnlyList)bakedBodyMeshList1, dictionary2, (IReadOnlyList)bakedBodyMeshList2, dictionary1); foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1) bakedBodyMesh.ReBakeMesh(); BodyPoseMatch_Leg bodyPoseMatchLeg = new BodyPoseMatch_Leg(); bodyPoseMatchLeg.AlignBothUpperLegs(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1); foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1) bakedBodyMesh.ReBakeMesh(); bodyPoseMatchLeg.ScalingBothLegsAndFoots(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1); if (this.doDebug) { foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1) bakedBodyMesh.ReBakeMesh(); bodyPoseMatchLeg.DrawLegPcaDebug(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, true, Color.yellow, Color.cyan, duration: 5f); bodyPoseMatchLeg.DrawLegPcaDebug(bodyProxy, (IReadOnlyList)bakedBodyMeshList1, dictionary2, false, Color.yellow, Color.cyan, duration: 5f); bodyPoseMatchLeg.DrawLegPcaDebug(targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1, true, Color.magenta, Color.green, duration: 5f); bodyPoseMatchLeg.DrawLegPcaDebug(targetAvatar, (IReadOnlyList)bakedBodyMeshList2, dictionary1, false, Color.magenta, Color.green, duration: 5f); bodyPoseMatchArm.DrawForearmExtremeDebugPair(bodyProxy.gameObject, (IReadOnlyList)proxyBodyMeshes, targetAvatar, targetBodyMeshes, true, 1f, 5f); } return bodyProxy; } } }