Add option for importing scale tracking to animation asset

This commit is contained in:
Wojtek Figat
2023-02-07 09:39:31 +01:00
parent e02c4b6f98
commit 7a2023ead6
6 changed files with 23 additions and 5 deletions

View File

@@ -819,7 +819,8 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
ImportCurve(aAnim->mPositionKeys, aAnim->mNumPositionKeys, anim.Position);
ImportCurve(aAnim->mRotationKeys, aAnim->mNumRotationKeys, anim.Rotation);
ImportCurve(aAnim->mScalingKeys, aAnim->mNumScalingKeys, anim.Scale);
if (options.ImportScaleTracks)
ImportCurve(aAnim->mScalingKeys, aAnim->mNumScalingKeys, anim.Scale);
}
}
}

View File

@@ -1051,9 +1051,9 @@ bool ImportAnimation(int32 index, ImportedModelData& data, OpenFbxImporterData&
const ofbx::AnimationCurveNode* translationNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Translation");
const ofbx::AnimationCurveNode* rotationNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Rotation");
const ofbx::AnimationCurveNode* scalingNode = nullptr; //layer->getCurveNode(*aNode.FbxObj, "Lcl Scaling");
const ofbx::AnimationCurveNode* scalingNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Scaling");
if (translationNode || rotationNode || scalingNode)
if (translationNode || rotationNode || (scalingNode && importerData.Options.ImportScaleTracks))
animatedNodes.Add(nodeIndex);
}
if (animatedNodes.IsEmpty())
@@ -1069,13 +1069,14 @@ bool ImportAnimation(int32 index, ImportedModelData& data, OpenFbxImporterData&
const ofbx::AnimationCurveNode* translationNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Translation");
const ofbx::AnimationCurveNode* rotationNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Rotation");
//const ofbx::AnimationCurveNode* scalingNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Scaling");
const ofbx::AnimationCurveNode* scalingNode = layer->getCurveNode(*aNode.FbxObj, "Lcl Scaling");
anim.NodeName = aNode.Name;
ImportCurve(translationNode, anim.Position, info, ExtractKeyframePosition);
ImportCurve(rotationNode, anim.Rotation, info, ExtractKeyframeRotation);
//ImportCurve(scalingNode, anim.Scale, info, ExtractKeyframeScale);
if (importerData.Options.ImportScaleTracks)
ImportCurve(scalingNode, anim.Scale, info, ExtractKeyframeScale);
}
if (importerData.ConvertRH)

View File

@@ -53,6 +53,7 @@ void ModelTool::Options::Serialize(SerializeStream& stream, const void* otherObj
SERIALIZE(SamplingRate);
SERIALIZE(SkipEmptyCurves);
SERIALIZE(OptimizeKeyframes);
SERIALIZE(ImportScaleTracks);
SERIALIZE(EnableRootMotion);
SERIALIZE(RootNodeName);
SERIALIZE(GenerateLODs);
@@ -93,6 +94,7 @@ void ModelTool::Options::Deserialize(DeserializeStream& stream, ISerializeModifi
DESERIALIZE(SamplingRate);
DESERIALIZE(SkipEmptyCurves);
DESERIALIZE(OptimizeKeyframes);
DESERIALIZE(ImportScaleTracks);
DESERIALIZE(EnableRootMotion);
DESERIALIZE(RootNodeName);
DESERIALIZE(GenerateLODs);

View File

@@ -235,6 +235,7 @@ public:
float SamplingRate = 0.0f;
bool SkipEmptyCurves = true;
bool OptimizeKeyframes = true;
bool ImportScaleTracks = false;
bool EnableRootMotion = false;
String RootNodeName;