mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -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)
|
||||
{
|
||||
//In fact, doesn't need this.
|
||||
if (assetsfileList.TryGetPD(m_Animator.m_Avatar, out var m_Avatar))
|
||||
avatar = new Avatar(m_Avatar);
|
||||
|
||||
@ -306,31 +307,35 @@ namespace AssetStudio
|
||||
{
|
||||
//Bone
|
||||
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 + ")");
|
||||
}*/
|
||||
for (int i = 0; i < sMesh.m_Bones.Length; i++)
|
||||
{
|
||||
var bone = new ImportedBone();
|
||||
var boneHash = mesh.m_BoneNameHashes[i];
|
||||
bone.Name = GetNameFromBonePathHashes(boneHash);
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
if (assetsfileList.TryGetTransform(sMesh.m_Bones[i], out var m_Transform))
|
||||
{
|
||||
bone.Name = avatar?.FindBoneName(boneHash);
|
||||
}
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
{
|
||||
if (assetsfileList.TryGetTransform(sMesh.m_Bones[i], out var m_Transform))
|
||||
if (assetsfileList.TryGetGameObject(m_Transform.m_GameObject, out var m_GameObject))
|
||||
{
|
||||
assetsfileList.TryGetGameObject(m_Transform.m_GameObject, out var m_GameObject);
|
||||
bone.Name = m_GameObject.m_Name;
|
||||
}
|
||||
else
|
||||
}
|
||||
//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))
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
bone.Name = avatar?.FindBoneName(boneHash);
|
||||
}
|
||||
if (string.IsNullOrEmpty(bone.Name))
|
||||
{
|
||||
throw new Exception("A Bone could neither be found by hash in Avatar nor by index in SkinnedMeshRenderer.");
|
||||
}
|
||||
}
|
||||
|
||||
var om = new Matrix();
|
||||
for (int x = 0; x < 4; x++)
|
||||
{
|
||||
@ -577,16 +582,11 @@ namespace AssetStudio
|
||||
}
|
||||
foreach (var m_Curve in m_RotationCurve.curve.m_Curve)
|
||||
{
|
||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
||||
{
|
||||
keyFrames = new ImportedAnimationKeyframe();
|
||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
||||
}
|
||||
keyFrames.Rotation = new ImportedKeyframe<Quaternion>(
|
||||
track.Rotations.Add(new ImportedKeyframe<Quaternion>(
|
||||
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.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)
|
||||
@ -602,16 +602,11 @@ namespace AssetStudio
|
||||
}
|
||||
foreach (var m_Curve in m_PositionCurve.curve.m_Curve)
|
||||
{
|
||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
||||
{
|
||||
keyFrames = new ImportedAnimationKeyframe();
|
||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
||||
}
|
||||
keyFrames.Translation = new ImportedKeyframe<Vector3>(
|
||||
track.Translations.Add(new ImportedKeyframe<Vector3>(
|
||||
m_Curve.time,
|
||||
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.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)
|
||||
@ -627,16 +622,11 @@ namespace AssetStudio
|
||||
}
|
||||
foreach (var m_Curve in m_ScaleCurve.curve.m_Curve)
|
||||
{
|
||||
if (!track.Keyframes.TryGetValue(m_Curve.time, out var keyFrames))
|
||||
{
|
||||
keyFrames = new ImportedAnimationKeyframe();
|
||||
track.Keyframes.Add(m_Curve.time, keyFrames);
|
||||
}
|
||||
keyFrames.Scaling = new ImportedKeyframe<Vector3>(
|
||||
track.Scalings.Add(new ImportedKeyframe<Vector3>(
|
||||
m_Curve.time,
|
||||
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.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::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
@ -9,7 +9,7 @@ using namespace System::Security::Permissions;
|
||||
[assembly:AssemblyConfigurationAttribute(L"")];
|
||||
[assembly:AssemblyCompanyAttribute(L"")];
|
||||
[assembly:AssemblyProductAttribute(L"AssetStudioFBX")];
|
||||
[assembly:AssemblyCopyrightAttribute(L"版权所有(c) 2018")];
|
||||
[assembly:AssemblyCopyrightAttribute(L"Copyright © 2018")];
|
||||
[assembly:AssemblyTrademarkAttribute(L"")];
|
||||
[assembly:AssemblyCultureAttribute(L"")];
|
||||
|
||||
|
Binary file not shown.
@ -683,56 +683,43 @@ namespace AssetStudio
|
||||
|
||||
for (int i = 0; i < importedAnimationList->Count; i++)
|
||||
{
|
||||
bool keyframed = dynamic_cast<ImportedKeyframedAnimation^>(importedAnimationList[i]) != nullptr;
|
||||
auto importedAnimation = importedAnimationList[i];
|
||||
FbxString kTakeName;
|
||||
if (importedAnimation->Name)
|
||||
{
|
||||
WITH_MARSHALLED_STRING
|
||||
(
|
||||
pClipName,
|
||||
importedAnimation->Name,
|
||||
kTakeName = FbxString(pClipName);
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
kTakeName = FbxString("Take") + FbxString(i);
|
||||
}
|
||||
bool keyframed = dynamic_cast<ImportedKeyframedAnimation^>(importedAnimation) != nullptr;
|
||||
if (keyframed)
|
||||
{
|
||||
ImportedKeyframedAnimation^ parser = (ImportedKeyframedAnimation^)importedAnimationList[i];
|
||||
FbxString kTakeName;
|
||||
if (parser->Name)
|
||||
{
|
||||
WITH_MARSHALLED_STRING
|
||||
(
|
||||
pClipName,
|
||||
parser->Name,
|
||||
kTakeName = FbxString(pClipName);
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
kTakeName = FbxString("Take") + FbxString(i);
|
||||
}
|
||||
ImportedKeyframedAnimation^ parser = (ImportedKeyframedAnimation^)importedAnimation;
|
||||
ExportKeyframedAnimation(parser, kTakeName, lFilter, filterPrecision, scale, rotate, translate, pNotFound);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImportedSampledAnimation^ parser = (ImportedSampledAnimation^)importedAnimationList[i];
|
||||
FbxString kTakeName;
|
||||
if (parser->Name)
|
||||
{
|
||||
WITH_MARSHALLED_STRING
|
||||
(
|
||||
pClipName,
|
||||
parser->Name,
|
||||
kTakeName = FbxString(pClipName);
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
kTakeName = FbxString("Take") + FbxString(i);
|
||||
}
|
||||
ImportedSampledAnimation^ parser = (ImportedSampledAnimation^)importedAnimation;
|
||||
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: ");
|
||||
for (int i = 0; i < pNotFound->Count; 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,
|
||||
@ -797,31 +784,32 @@ namespace AssetStudio
|
||||
lCurveTY->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, keyframes.Value->Scaling->value.X);
|
||||
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)
|
||||
{
|
||||
Vector3 rotation = Fbx::QuaternionToEuler(keyframes.Value->Rotation->value);
|
||||
Vector3 inSlope = Fbx::QuaternionToEuler(keyframes.Value->Rotation->inSlope);
|
||||
Vector3 outSlope = Fbx::QuaternionToEuler(keyframes.Value->Rotation->outSlope);
|
||||
lCurveRX->KeySet(lCurveRX->KeyAdd(lTime), lTime, rotation.X);
|
||||
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, rotation.Y);
|
||||
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, rotation.Z);
|
||||
}
|
||||
if (keyframes.Value->Translation != nullptr)
|
||||
{
|
||||
lCurveTX->KeySet(lCurveTX->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.X);
|
||||
lCurveTY->KeySet(lCurveTY->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.Y);
|
||||
lCurveTZ->KeySet(lCurveTZ->KeyAdd(lTime), lTime, keyframes.Value->Translation->value.Z);
|
||||
}
|
||||
lCurveSX->KeySet(lCurveSX->KeyAdd(lTime), lTime, Scaling->value.X);
|
||||
lCurveSY->KeySet(lCurveSY->KeyAdd(lTime), lTime, Scaling->value.Y);
|
||||
lCurveSZ->KeySet(lCurveSZ->KeyAdd(lTime), lTime, Scaling->value.Z);
|
||||
}
|
||||
for each (auto Rotation in keyframeList->Rotations)
|
||||
{
|
||||
lTime.SetSecondDouble(Rotation->time);
|
||||
|
||||
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);
|
||||
lCurveRY->KeySet(lCurveRY->KeyAdd(lTime), lTime, rotation.Y);
|
||||
lCurveRZ->KeySet(lCurveRZ->KeyAdd(lTime), lTime, rotation.Z);
|
||||
}
|
||||
for each (auto Translation in keyframeList->Translations)
|
||||
{
|
||||
lTime.SetSecondDouble(Translation->time);
|
||||
|
||||
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();
|
||||
|
@ -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
|
||||
@ -107,12 +108,11 @@ namespace AssetStudio
|
||||
|
||||
public class ImportedKeyframedAnimation : ImportedAnimationTrackContainer<ImportedAnimationKeyframedTrack>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class ImportedSampledAnimation : ImportedAnimationTrackContainer<ImportedAnimationSampledTrack>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public float SampleRate { get; set; }
|
||||
}
|
||||
|
||||
@ -121,11 +121,6 @@ namespace AssetStudio
|
||||
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 float time { get; set; }
|
||||
@ -142,11 +137,11 @@ namespace AssetStudio
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportedAnimationKeyframe
|
||||
public class ImportedAnimationKeyframedTrack : ImportedAnimationTrack
|
||||
{
|
||||
public ImportedKeyframe<Vector3> Scaling { get; set; }
|
||||
public ImportedKeyframe<Quaternion> Rotation { get; set; }
|
||||
public ImportedKeyframe<Vector3> Translation { get; set; }
|
||||
public List<ImportedKeyframe<Vector3>> Scalings = new List<ImportedKeyframe<Vector3>>();
|
||||
public List<ImportedKeyframe<Quaternion>> Rotations = new List<ImportedKeyframe<Quaternion>>();
|
||||
public List<ImportedKeyframe<Vector3>> Translations = new List<ImportedKeyframe<Vector3>>();
|
||||
}
|
||||
|
||||
public class ImportedAnimationSampledTrack : ImportedAnimationTrack
|
||||
|
Loading…
Reference in New Issue
Block a user