// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, // for ex. property getter/setter access. To get optimal decompilation results, please manually add the missing references to the list of loaded assemblies. // EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // Eden.AutoMorpher.BodyPoseMatchUtil using System.Collections.Generic; using UnityEngine; 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 component = sourceAvatar.GetComponent(); Animator component2 = targetAvatar.GetComponent(); if (component == null || component2 == null) { Debug.LogError("[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다."); sourceToProxy = new Dictionary(); return null; } Dictionary> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component, sourceBodyMeshes); Dictionary> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes); BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight); bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary, neckTargetHeight); List proxyBodyMeshes; GameObject gameObject = bodyPoseMatchSetupUtil.CreateBodyProxy(component, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy); Animator component3 = gameObject.GetComponent(); if (onlyScaling) { gameObject.transform.SetParent(targetAvatar.transform); gameObject.transform.localPosition = Vector3.zero; return gameObject; } Dictionary> dictionary2 = this.meshClassifier.MeshHumanoidBoneMatcher(component3, proxyBodyMeshes); if (dictionary2 == null || dictionary2.Count == 0) { throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); } gameObject.transform.SetParent(targetAvatar.transform); gameObject.transform.localPosition = Vector3.zero; List list = new List(); foreach (SkinnedMeshRenderer item in proxyBodyMeshes) { list.Add(new BakedBodyMesh(item)); } List list2 = new List(); foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes) { list2.Add(new BakedBodyMesh(targetBodyMesh)); } BodyPoseMatch_Torso bodyPoseMatch_Torso = new BodyPoseMatch_Torso(); bodyPoseMatch_Torso.AlignTorsoByNeck(gameObject, list, dictionary2, targetAvatar, list2, dictionary); if (this.doDebug) { bodyPoseMatch_Torso.DrawTorsoPcaDebug(gameObject, list, dictionary2, Color.yellow, Color.cyan, 1f, 20f); bodyPoseMatch_Torso.DrawTorsoPcaDebug(targetAvatar, list2, dictionary, Color.red, Color.green, 1f, 20f); } foreach (BakedBodyMesh item2 in list) { item2.ReBakeMesh(); } BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm(); bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary2, list2, dictionary); if (this.doDebug) { bodyPoseMatch_Arm.DrawArmPcaDebug(gameObject, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 20f); bodyPoseMatch_Arm.DrawArmPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.red, Color.green, 1f, 20f); } foreach (BakedBodyMesh item3 in list) { item3.ReBakeMesh(); } bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary2, list2, dictionary); foreach (BakedBodyMesh item4 in list) { item4.ReBakeMesh(); } BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg(); bodyPoseMatch_Leg.AlignBothUpperLegs(gameObject, list, dictionary2, targetAvatar, list2, dictionary); foreach (BakedBodyMesh item5 in list) { item5.ReBakeMesh(); } bodyPoseMatch_Leg.ScalingBothLegsAndFoots(gameObject, list, dictionary2, targetAvatar, list2, dictionary); if (this.doDebug) { foreach (BakedBodyMesh item6 in list) { item6.ReBakeMesh(); } bodyPoseMatch_Leg.DrawLegPcaDebug(gameObject, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 5f); bodyPoseMatch_Leg.DrawLegPcaDebug(gameObject, list, dictionary2, isLeft: false, Color.yellow, Color.cyan, 1f, 5f); bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.magenta, Color.green, 1f, 5f); bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: false, Color.magenta, Color.green, 1f, 5f); bodyPoseMatch_Arm.DrawForearmExtremeDebugPair(gameObject.gameObject, proxyBodyMeshes, targetAvatar, targetBodyMeshes, isLeft: true, 1f, 5f); } return gameObject; } }