mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
Some improvements
This commit is contained in:
parent
7410511c40
commit
9e4be3e082
@ -46,6 +46,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private void InitWithAnimator(Animator m_Animator)
|
private void InitWithAnimator(Animator m_Animator)
|
||||||
{
|
{
|
||||||
|
//In fact, doesn't need this.
|
||||||
if (assetsfileList.TryGetPD(m_Animator.m_Avatar, out var m_Avatar))
|
if (assetsfileList.TryGetPD(m_Animator.m_Avatar, out var m_Avatar))
|
||||||
avatar = new Avatar(m_Avatar);
|
avatar = new Avatar(m_Avatar);
|
||||||
|
|
||||||
@ -306,13 +307,23 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
//Bone
|
//Bone
|
||||||
iMesh.BoneList = new List<ImportedBone>(sMesh.m_Bones.Length);
|
iMesh.BoneList = new List<ImportedBone>(sMesh.m_Bones.Length);
|
||||||
/*if (meshR.m_Bones.Length >= 256)
|
/*if (sMesh.m_Bones.Length >= 256)
|
||||||
{
|
{
|
||||||
throw new Exception("Too many bones (" + mesh.m_BindPose.Length + ")");
|
throw new Exception("Too many bones (" + mesh.m_BindPose.Length + ")");
|
||||||
}*/
|
}*/
|
||||||
for (int i = 0; i < sMesh.m_Bones.Length; i++)
|
for (int i = 0; i < sMesh.m_Bones.Length; i++)
|
||||||
{
|
{
|
||||||
var bone = new ImportedBone();
|
var bone = new ImportedBone();
|
||||||
|
if (assetsfileList.TryGetTransform(sMesh.m_Bones[i], out var m_Transform))
|
||||||
|
{
|
||||||
|
if (assetsfileList.TryGetGameObject(m_Transform.m_GameObject, 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];
|
var boneHash = mesh.m_BoneNameHashes[i];
|
||||||
bone.Name = GetNameFromBonePathHashes(boneHash);
|
bone.Name = GetNameFromBonePathHashes(boneHash);
|
||||||
if (string.IsNullOrEmpty(bone.Name))
|
if (string.IsNullOrEmpty(bone.Name))
|
||||||
@ -321,16 +332,10 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(bone.Name))
|
if (string.IsNullOrEmpty(bone.Name))
|
||||||
{
|
{
|
||||||
if (assetsfileList.TryGetTransform(sMesh.m_Bones[i], out var m_Transform))
|
throw new Exception("A Bone could neither be found by hash in Avatar nor by index in SkinnedMeshRenderer.");
|
||||||
{
|
|
||||||
assetsfileList.TryGetGameObject(m_Transform.m_GameObject, out var m_GameObject);
|
|
||||||
bone.Name = m_GameObject.m_Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var om = new Matrix();
|
var om = new Matrix();
|
||||||
for (int x = 0; x < 4; x++)
|
for (int x = 0; x < 4; x++)
|
||||||
{
|
{
|
||||||
@ -577,16 +582,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
foreach (var m_Curve in m_RotationCurve.curve.m_Curve)
|
foreach (var m_Curve in m_RotationCurve.curve.m_Curve)
|
||||||
{
|
{
|
||||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
track.Rotations.Add(new ImportedKeyframe<Quaternion>(
|
||||||
{
|
|
||||||
keyFrames = new ImportedAnimationKeyframe();
|
|
||||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
|
||||||
}
|
|
||||||
keyFrames.Rotation = new ImportedKeyframe<Quaternion>(
|
|
||||||
m_Curve.time,
|
m_Curve.time,
|
||||||
new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W),
|
new Quaternion(m_Curve.value.X, -m_Curve.value.Y, -m_Curve.value.Z, m_Curve.value.W),
|
||||||
new Quaternion(m_Curve.inSlope.X, -m_Curve.inSlope.Y, -m_Curve.inSlope.Z, m_Curve.inSlope.W),
|
new Quaternion(m_Curve.inSlope.X, -m_Curve.inSlope.Y, -m_Curve.inSlope.Z, m_Curve.inSlope.W),
|
||||||
new Quaternion(m_Curve.outSlope.X, -m_Curve.outSlope.Y, -m_Curve.outSlope.Z, m_Curve.outSlope.W));
|
new Quaternion(m_Curve.outSlope.X, -m_Curve.outSlope.Y, -m_Curve.outSlope.Z, m_Curve.outSlope.W)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var m_PositionCurve in clip.m_PositionCurves)
|
foreach (var m_PositionCurve in clip.m_PositionCurves)
|
||||||
@ -602,16 +602,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
foreach (var m_Curve in m_PositionCurve.curve.m_Curve)
|
foreach (var m_Curve in m_PositionCurve.curve.m_Curve)
|
||||||
{
|
{
|
||||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
track.Translations.Add(new ImportedKeyframe<Vector3>(
|
||||||
{
|
|
||||||
keyFrames = new ImportedAnimationKeyframe();
|
|
||||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
|
||||||
}
|
|
||||||
keyFrames.Translation = new ImportedKeyframe<Vector3>(
|
|
||||||
m_Curve.time,
|
m_Curve.time,
|
||||||
new Vector3(-m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z),
|
new Vector3(-m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z),
|
||||||
new Vector3(-m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z),
|
new Vector3(-m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z),
|
||||||
new Vector3(-m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z));
|
new Vector3(-m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var m_ScaleCurve in clip.m_ScaleCurves)
|
foreach (var m_ScaleCurve in clip.m_ScaleCurves)
|
||||||
@ -627,16 +622,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
foreach (var m_Curve in m_ScaleCurve.curve.m_Curve)
|
foreach (var m_Curve in m_ScaleCurve.curve.m_Curve)
|
||||||
{
|
{
|
||||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
track.Scalings.Add(new ImportedKeyframe<Vector3>(
|
||||||
{
|
|
||||||
keyFrames = new ImportedAnimationKeyframe();
|
|
||||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
|
||||||
}
|
|
||||||
keyFrames.Scaling = new ImportedKeyframe<Vector3>(
|
|
||||||
m_Curve.time,
|
m_Curve.time,
|
||||||
new Vector3(m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z),
|
new Vector3(m_Curve.value.X, m_Curve.value.Y, m_Curve.value.Z),
|
||||||
new Vector3(m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z),
|
new Vector3(m_Curve.inSlope.X, m_Curve.inSlope.Y, m_Curve.inSlope.Z),
|
||||||
new Vector3(m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z));
|
new Vector3(m_Curve.outSlope.X, m_Curve.outSlope.Y, m_Curve.outSlope.Z)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using namespace System;
|
using namespace System;
|
||||||
using namespace System::Reflection;
|
using namespace System::Reflection;
|
||||||
using namespace System::Runtime::CompilerServices;
|
using namespace System::Runtime::CompilerServices;
|
||||||
using namespace System::Runtime::InteropServices;
|
using namespace System::Runtime::InteropServices;
|
||||||
@ -9,7 +9,7 @@ using namespace System::Security::Permissions;
|
|||||||
[assembly:AssemblyConfigurationAttribute(L"")];
|
[assembly:AssemblyConfigurationAttribute(L"")];
|
||||||
[assembly:AssemblyCompanyAttribute(L"")];
|
[assembly:AssemblyCompanyAttribute(L"")];
|
||||||
[assembly:AssemblyProductAttribute(L"AssetStudioFBX")];
|
[assembly:AssemblyProductAttribute(L"AssetStudioFBX")];
|
||||||
[assembly:AssemblyCopyrightAttribute(L"版权所有(c) 2018")];
|
[assembly:AssemblyCopyrightAttribute(L"Copyright © 2018")];
|
||||||
[assembly:AssemblyTrademarkAttribute(L"")];
|
[assembly:AssemblyTrademarkAttribute(L"")];
|
||||||
[assembly:AssemblyCultureAttribute(L"")];
|
[assembly:AssemblyCultureAttribute(L"")];
|
||||||
|
|
||||||
|
Binary file not shown.
@ -683,17 +683,14 @@ namespace AssetStudio
|
|||||||
|
|
||||||
for (int i = 0; i < importedAnimationList->Count; i++)
|
for (int i = 0; i < importedAnimationList->Count; i++)
|
||||||
{
|
{
|
||||||
bool keyframed = dynamic_cast<ImportedKeyframedAnimation^>(importedAnimationList[i]) != nullptr;
|
auto importedAnimation = importedAnimationList[i];
|
||||||
if (keyframed)
|
|
||||||
{
|
|
||||||
ImportedKeyframedAnimation^ parser = (ImportedKeyframedAnimation^)importedAnimationList[i];
|
|
||||||
FbxString kTakeName;
|
FbxString kTakeName;
|
||||||
if (parser->Name)
|
if (importedAnimation->Name)
|
||||||
{
|
{
|
||||||
WITH_MARSHALLED_STRING
|
WITH_MARSHALLED_STRING
|
||||||
(
|
(
|
||||||
pClipName,
|
pClipName,
|
||||||
parser->Name,
|
importedAnimation->Name,
|
||||||
kTakeName = FbxString(pClipName);
|
kTakeName = FbxString(pClipName);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -701,38 +698,28 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
kTakeName = FbxString("Take") + FbxString(i);
|
kTakeName = FbxString("Take") + FbxString(i);
|
||||||
}
|
}
|
||||||
|
bool keyframed = dynamic_cast<ImportedKeyframedAnimation^>(importedAnimation) != nullptr;
|
||||||
|
if (keyframed)
|
||||||
|
{
|
||||||
|
ImportedKeyframedAnimation^ parser = (ImportedKeyframedAnimation^)importedAnimation;
|
||||||
ExportKeyframedAnimation(parser, kTakeName, lFilter, filterPrecision, scale, rotate, translate, pNotFound);
|
ExportKeyframedAnimation(parser, kTakeName, lFilter, filterPrecision, scale, rotate, translate, pNotFound);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportedSampledAnimation^ parser = (ImportedSampledAnimation^)importedAnimationList[i];
|
ImportedSampledAnimation^ parser = (ImportedSampledAnimation^)importedAnimation;
|
||||||
FbxString kTakeName;
|
|
||||||
if (parser->Name)
|
|
||||||
{
|
|
||||||
WITH_MARSHALLED_STRING
|
|
||||||
(
|
|
||||||
pClipName,
|
|
||||||
parser->Name,
|
|
||||||
kTakeName = FbxString(pClipName);
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kTakeName = FbxString("Take") + FbxString(i);
|
|
||||||
}
|
|
||||||
ExportSampledAnimation(parser, kTakeName, lFilter, filterPrecision, flatInbetween, scale, rotate, translate, pNotFound);
|
ExportSampledAnimation(parser, kTakeName, lFilter, filterPrecision, flatInbetween, scale, rotate, translate, pNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pNotFound->Count > 0)
|
/*if (pNotFound->Count > 0)
|
||||||
{
|
{
|
||||||
String^ pNotFoundString = gcnew String("Warning: Animations weren't exported for the following missing frames or morphs: ");
|
String^ pNotFoundString = gcnew String("Warning: Animations weren't exported for the following missing frames or morphs: ");
|
||||||
for (int i = 0; i < pNotFound->Count; i++)
|
for (int i = 0; i < pNotFound->Count; i++)
|
||||||
{
|
{
|
||||||
pNotFoundString += pNotFound[i] + ", ";
|
pNotFoundString += pNotFound[i] + ", ";
|
||||||
}
|
}
|
||||||
//Report::ReportLog(pNotFoundString->Substring(0, pNotFoundString->Length - 2));
|
Report::ReportLog(pNotFoundString->Substring(0, pNotFoundString->Length - 2));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fbx::Exporter::ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision,
|
void Fbx::Exporter::ExportKeyframedAnimation(ImportedKeyframedAnimation^ parser, FbxString& kTakeName, FbxAnimCurveFilterUnroll* EulerFilter, float filterPrecision,
|
||||||
@ -797,31 +784,32 @@ namespace AssetStudio
|
|||||||
lCurveTY->KeyModifyBegin();
|
lCurveTY->KeyModifyBegin();
|
||||||
lCurveTZ->KeyModifyBegin();
|
lCurveTZ->KeyModifyBegin();
|
||||||
|
|
||||||
for each (auto keyframes in keyframeList->Keyframes)
|
for each (auto Scaling in keyframeList->Scalings)
|
||||||
{
|
{
|
||||||
lTime.SetSecondDouble(keyframes.Key);
|
lTime.SetSecondDouble(Scaling->time);
|
||||||
|
|
||||||
if (keyframes.Value->Scaling != nullptr)
|
lCurveSX->KeySet(lCurveSX->KeyAdd(lTime), lTime, Scaling->value.X);
|
||||||
{
|
lCurveSY->KeySet(lCurveSY->KeyAdd(lTime), lTime, Scaling->value.Y);
|
||||||
lCurveSX->KeySet(lCurveSX->KeyAdd(lTime), lTime, keyframes.Value->Scaling->value.X);
|
lCurveSZ->KeySet(lCurveSZ->KeyAdd(lTime), lTime, Scaling->value.Z);
|
||||||
lCurveSY->KeySet(lCurveSY->KeyAdd(lTime), lTime, keyframes.Value->Scaling->value.Y);
|
|
||||||
lCurveSZ->KeySet(lCurveSZ->KeyAdd(lTime), lTime, keyframes.Value->Scaling->value.Z);
|
|
||||||
}
|
}
|
||||||
if (keyframes.Value->Rotation != nullptr)
|
for each (auto Rotation in keyframeList->Rotations)
|
||||||
{
|
{
|
||||||
Vector3 rotation = Fbx::QuaternionToEuler(keyframes.Value->Rotation->value);
|
lTime.SetSecondDouble(Rotation->time);
|
||||||
Vector3 inSlope = Fbx::QuaternionToEuler(keyframes.Value->Rotation->inSlope);
|
|
||||||
Vector3 outSlope = Fbx::QuaternionToEuler(keyframes.Value->Rotation->outSlope);
|
Vector3 rotation = Fbx::QuaternionToEuler(Rotation->value);
|
||||||
|
Vector3 inSlope = Fbx::QuaternionToEuler(Rotation->inSlope);
|
||||||
|
Vector3 outSlope = Fbx::QuaternionToEuler(Rotation->outSlope);
|
||||||
lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, rotation.X);
|
lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, rotation.X);
|
||||||
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, rotation.Y);
|
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, rotation.Y);
|
||||||
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, rotation.Z);
|
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, rotation.Z);
|
||||||
}
|
}
|
||||||
if (keyframes.Value->Translation != nullptr)
|
for each (auto Translation in keyframeList->Translations)
|
||||||
{
|
{
|
||||||
lCurveTX->KeySet(lCurveTX->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.X);
|
lTime.SetSecondDouble(Translation->time);
|
||||||
lCurveTY->KeySet(lCurveTY->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.Y);
|
|
||||||
lCurveTZ->KeySet(lCurveTZ->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.Z);
|
lCurveTX->KeySet(lCurveTX->KeyAdd(lTime), lTime, Translation->value.X);
|
||||||
}
|
lCurveTY->KeySet(lCurveTY->KeyAdd(lTime), lTime, Translation->value.Y);
|
||||||
|
lCurveTZ->KeySet(lCurveTZ->KeyAdd(lTime), lTime, Translation->value.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
lCurveSX->KeyModifyEnd();
|
lCurveSX->KeyModifyEnd();
|
||||||
|
@ -91,8 +91,9 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ImportedAnimation
|
public abstract class ImportedAnimation
|
||||||
{
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ImportedAnimationTrackContainer<TrackType> : ImportedAnimation where TrackType : ImportedAnimationTrack
|
public abstract class ImportedAnimationTrackContainer<TrackType> : ImportedAnimation where TrackType : ImportedAnimationTrack
|
||||||
@ -107,12 +108,11 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public class ImportedKeyframedAnimation : ImportedAnimationTrackContainer<ImportedAnimationKeyframedTrack>
|
public class ImportedKeyframedAnimation : ImportedAnimationTrackContainer<ImportedAnimationKeyframedTrack>
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportedSampledAnimation : ImportedAnimationTrackContainer<ImportedAnimationSampledTrack>
|
public class ImportedSampledAnimation : ImportedAnimationTrackContainer<ImportedAnimationSampledTrack>
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
|
||||||
public float SampleRate { get; set; }
|
public float SampleRate { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +121,6 @@ namespace AssetStudio
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportedAnimationKeyframedTrack : ImportedAnimationTrack
|
|
||||||
{
|
|
||||||
public Dictionary<float, ImportedAnimationKeyframe> Keyframes { get; set; } = new Dictionary<float, ImportedAnimationKeyframe>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ImportedKeyframe<T>
|
public class ImportedKeyframe<T>
|
||||||
{
|
{
|
||||||
public float time { get; set; }
|
public float time { get; set; }
|
||||||
@ -142,11 +137,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportedAnimationKeyframe
|
public class ImportedAnimationKeyframedTrack : ImportedAnimationTrack
|
||||||
{
|
{
|
||||||
public ImportedKeyframe<Vector3> Scaling { get; set; }
|
public List<ImportedKeyframe<Vector3>> Scalings = new List<ImportedKeyframe<Vector3>>();
|
||||||
public ImportedKeyframe<Quaternion> Rotation { get; set; }
|
public List<ImportedKeyframe<Quaternion>> Rotations = new List<ImportedKeyframe<Quaternion>>();
|
||||||
public ImportedKeyframe<Vector3> Translation { get; set; }
|
public List<ImportedKeyframe<Vector3>> Translations = new List<ImportedKeyframe<Vector3>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImportedAnimationSampledTrack : ImportedAnimationTrack
|
public class ImportedAnimationSampledTrack : ImportedAnimationTrack
|
||||||
|
Loading…
Reference in New Issue
Block a user