mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
Fixed #272
This commit is contained in:
parent
2c58fae804
commit
22b2d472bc
@ -382,23 +382,13 @@ namespace AssetStudio
|
||||
iMesh.SubmeshList.Add(iSubmesh);
|
||||
}
|
||||
|
||||
if (meshR is SkinnedMeshRenderer sMesh)
|
||||
{
|
||||
//Bone
|
||||
iMesh.BoneList = new List<ImportedBone>(sMesh.m_Bones.Length);
|
||||
for (int i = 0; i < sMesh.m_Bones.Length; i++)
|
||||
iMesh.BoneList = new List<ImportedBone>();
|
||||
if (mesh.m_BindPose?.Length > 0 && mesh.m_BoneNameHashes?.Length > 0 && mesh.m_BindPose.Length == mesh.m_BoneNameHashes.Length)
|
||||
{
|
||||
for (int i = 0; i < mesh.m_BindPose.Length; i++)
|
||||
{
|
||||
var bone = new ImportedBone();
|
||||
if (sMesh.m_Bones[i].TryGetTransform(out var m_Transform))
|
||||
{
|
||||
if (m_Transform.m_GameObject.TryGetGameObject(out var m_GameObject))
|
||||
{
|
||||
bone.Name = m_GameObject.m_Name;
|
||||
}
|
||||
}
|
||||
//No first use m_BoneNameHashes, because it may be wrong
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
{
|
||||
var boneHash = mesh.m_BoneNameHashes[i];
|
||||
bone.Name = GetNameFromBonePathHashes(boneHash);
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
@ -410,7 +400,6 @@ namespace AssetStudio
|
||||
//throw new Exception("A Bone could neither be found by hash in Avatar nor by index in SkinnedMeshRenderer.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var om = new float[4, 4];
|
||||
var m = mesh.m_BindPose[i];
|
||||
om[0, 0] = m[0, 0];
|
||||
@ -432,14 +421,25 @@ namespace AssetStudio
|
||||
bone.Matrix = om;
|
||||
iMesh.BoneList.Add(bone);
|
||||
}
|
||||
}
|
||||
|
||||
//hierarchy has been optimized
|
||||
if (sMesh.m_Bones.Length == 0 && mesh.m_BindPose?.Length > 0 && mesh.m_BoneNameHashes?.Length > 0)
|
||||
if (meshR is SkinnedMeshRenderer sMesh)
|
||||
{
|
||||
//TODO Repeat code with above
|
||||
for (int i = 0; i < mesh.m_BindPose.Length; i++)
|
||||
//Bone for 4.3 down and other
|
||||
if (iMesh.BoneList.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < sMesh.m_Bones.Length; i++)
|
||||
{
|
||||
var bone = new ImportedBone();
|
||||
if (sMesh.m_Bones[i].TryGetTransform(out var m_Transform))
|
||||
{
|
||||
if (m_Transform.m_GameObject.TryGetGameObject(out var m_GameObject))
|
||||
{
|
||||
bone.Name = m_GameObject.m_Name;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
{
|
||||
var boneHash = mesh.m_BoneNameHashes[i];
|
||||
bone.Name = GetNameFromBonePathHashes(boneHash);
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
@ -451,6 +451,7 @@ namespace AssetStudio
|
||||
//throw new Exception("A Bone could neither be found by hash in Avatar nor by index in SkinnedMeshRenderer.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var om = new float[4, 4];
|
||||
var m = mesh.m_BindPose[i];
|
||||
om[0, 0] = m[0, 0];
|
||||
|
@ -659,6 +659,7 @@ namespace AssetStudio
|
||||
StatusStripUpdate($"Finished exporting {filename}.fbx");
|
||||
}
|
||||
}
|
||||
StatusStripUpdate("Finished");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -574,6 +574,7 @@ namespace AssetStudio
|
||||
if (hasBones)
|
||||
{
|
||||
FbxSkin* pSkin = FbxSkin::Create(pScene, "");
|
||||
FbxAMatrix lMeshMatrix = pMeshNode->EvaluateGlobalTransform();
|
||||
for (int j = 0; j < boneList->Count; j++)
|
||||
{
|
||||
FbxCluster* pCluster = pClusterArray->GetAt(j);
|
||||
@ -589,8 +590,6 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
FbxAMatrix lMeshMatrix = pMeshNode->EvaluateGlobalTransform();
|
||||
|
||||
pCluster->SetTransformMatrix(lMeshMatrix);
|
||||
pCluster->SetTransformLinkMatrix(lMeshMatrix * lBoneMatrix.Inverse());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user