133 lines
7.5 KiB
C#
133 lines
7.5 KiB
C#
// 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<SkinnedMeshRenderer> sourceBodyMeshes, GameObject targetAvatar, IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshes, out Dictionary<Transform, Transform> sourceToProxy, float neckTargetHeight = 1.5f, bool onlyScaling = false)
|
|
{
|
|
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_040a: Unknown result type (might be due to invalid IL or missing references)
|
|
Animator component = sourceAvatar.GetComponent<Animator>();
|
|
Animator component2 = targetAvatar.GetComponent<Animator>();
|
|
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
|
|
{
|
|
Debug.LogError((object)"[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다.");
|
|
sourceToProxy = new Dictionary<Transform, Transform>();
|
|
return null;
|
|
}
|
|
Dictionary<HumanBodyBones, HashSet<Transform>> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component, sourceBodyMeshes);
|
|
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes);
|
|
BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil();
|
|
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight);
|
|
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary, neckTargetHeight);
|
|
List<SkinnedMeshRenderer> proxyBodyMeshes;
|
|
GameObject val = bodyPoseMatchSetupUtil.CreateBodyProxy(component, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy);
|
|
Animator component3 = val.GetComponent<Animator>();
|
|
if (onlyScaling)
|
|
{
|
|
val.transform.SetParent(targetAvatar.transform);
|
|
val.transform.localPosition = Vector3.zero;
|
|
return val;
|
|
}
|
|
Dictionary<HumanBodyBones, HashSet<Transform>> 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");
|
|
}
|
|
val.transform.SetParent(targetAvatar.transform);
|
|
val.transform.localPosition = Vector3.zero;
|
|
List<BakedBodyMesh> list = new List<BakedBodyMesh>();
|
|
foreach (SkinnedMeshRenderer item in proxyBodyMeshes)
|
|
{
|
|
list.Add(new BakedBodyMesh(item));
|
|
}
|
|
List<BakedBodyMesh> list2 = new List<BakedBodyMesh>();
|
|
foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes)
|
|
{
|
|
list2.Add(new BakedBodyMesh(targetBodyMesh));
|
|
}
|
|
BodyPoseMatch_Torso bodyPoseMatch_Torso = new BodyPoseMatch_Torso();
|
|
bodyPoseMatch_Torso.AlignTorsoByNeck(val, list, dictionary2, targetAvatar, list2, dictionary);
|
|
if (this.doDebug)
|
|
{
|
|
bodyPoseMatch_Torso.DrawTorsoPcaDebug(val, 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(val, 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(val, list, dictionary2, targetAvatar, list2, dictionary);
|
|
foreach (BakedBodyMesh item5 in list)
|
|
{
|
|
item5.ReBakeMesh();
|
|
}
|
|
bodyPoseMatch_Leg.ScalingBothLegsAndFoots(val, list, dictionary2, targetAvatar, list2, dictionary);
|
|
if (this.doDebug)
|
|
{
|
|
foreach (BakedBodyMesh item6 in list)
|
|
{
|
|
item6.ReBakeMesh();
|
|
}
|
|
bodyPoseMatch_Leg.DrawLegPcaDebug(val, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 5f);
|
|
bodyPoseMatch_Leg.DrawLegPcaDebug(val, 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(val.gameObject, proxyBodyMeshes, targetAvatar, targetBodyMeshes, isLeft: true, 1f, 5f);
|
|
}
|
|
return val;
|
|
}
|
|
}
|