Files
AutoMorpherDecompiled/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfilePoseMatchUtil.cs

88 lines
5.6 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.profile.ProfilePoseMatchUtil
using System.Collections.Generic;
using UnityEngine;
public class ProfilePoseMatchUtil
{
private WorldVertexUtil _worldVertexUtil;
private MeshClassifier meshClassifier;
public ProfilePoseMatchUtil()
{
this._worldVertexUtil = new WorldVertexUtil();
this.meshClassifier = new MeshClassifier();
}
public void ProfilePoseMatcher(GameObject targetAvatar, IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshes, GameObject targetCloth, ProfileData profileData, Dictionary<HumanBodyBones, HashSet<Transform>> clothHumanBonesMap, Dictionary<Transform, ClothBoneType> clothBoneTypeMap, float neckTargetHeight = 1.5f)
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)targetAvatar == (Object)null)
{
throw new AutoMorpherException("Target Avatar is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar is null");
}
if ((Object)(object)targetAvatar.GetComponent<Animator>() == (Object)null)
{
throw new AutoMorpherException("Target Avatar Animator is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar has no animator");
}
if (targetBodyMeshes == null || targetBodyMeshes.Count == 0)
{
throw new AutoMorpherException("Target Body Meshes are Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetBodyMeshes is null or empty");
}
if ((Object)(object)targetCloth == (Object)null)
{
throw new AutoMorpherException("Target Cloth is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetCloth is null");
}
if (profileData == null)
{
throw new AutoMorpherException("Profile Data is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profileData is null");
}
if (clothHumanBonesMap == null || clothHumanBonesMap.Count == 0 || clothBoneTypeMap == null || clothBoneTypeMap.Count == 0)
{
throw new AutoMorpherException("Clothing Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profile Clothe Bone Match Data is null or empty");
}
Transform transform = targetAvatar.transform;
Transform transform2 = targetCloth.transform;
Transform parent = transform.parent;
transform.SetParent((Transform)null, true);
Transform parent2 = transform2.parent;
transform2.SetParent((Transform)null, true);
transform2.position = transform.position;
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(targetAvatar.GetComponent<Animator>(), targetBodyMeshes);
if (dictionary == null || dictionary.Count == 0)
{
throw new AutoMorpherException("Target Avatar Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - target Avatar Bone Match Data is null or empty");
}
BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil();
Vector3 comprehensiveScale = bodyPoseMatchSetupUtil.GetComprehensiveScale(transform2, clothHumanBonesMap, profileData);
Debug.Log((object)$"ComprehensiveScale: {comprehensiveScale}");
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform, dictionary, neckTargetHeight);
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform2, clothHumanBonesMap, neckTargetHeight);
List<BakedBodyMesh> list = new List<BakedBodyMesh>();
foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes)
{
list.Add(new BakedBodyMesh(targetBodyMesh));
}
new BodyPoseMatch_Torso().AlignTorsoByNeck(transform, list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale);
BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm();
bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale);
bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary, clothHumanBonesMap, profileData, comprehensiveScale);
BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg();
bodyPoseMatch_Leg.AlignBothUpperLegs(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale);
bodyPoseMatch_Leg.ScalingBothLegsAndFoots(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale);
transform.SetParent(parent, true);
transform2.SetParent(parent2, true);
}
}