Fixed crash when importing FBX files that don't have any animations
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40212
This commit is contained in:
@@ -593,91 +593,93 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
// FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(pFbxScene->GetSrcObject(FBX_TYPE(FbxAnimStack), i));
|
||||
FbxAnimStack* pAnimStack = pFbxScene->GetSrcObject<FbxAnimStack>(i);
|
||||
KRAnimation *pAnimation = parent_node->getContext().getAnimationManager()->getAnimation(pAnimStack->GetName());
|
||||
int cLayers = pAnimStack->GetMemberCount<FbxAnimLayer>();
|
||||
for(int iLayer=0; iLayer < cLayers; iLayer++) {
|
||||
FbxAnimLayer *pFbxAnimLayer = pAnimStack->GetMember<FbxAnimLayer>(iLayer);
|
||||
float weight = pFbxAnimLayer->Weight.Get();
|
||||
KRAnimationLayer *pAnimationLayer = pAnimation->getLayer(pFbxAnimLayer->GetName());
|
||||
|
||||
FbxAnimCurve *pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
if(pAnimation) {
|
||||
int cLayers = pAnimStack->GetMemberCount<FbxAnimLayer>();
|
||||
for(int iLayer=0; iLayer < cLayers; iLayer++) {
|
||||
FbxAnimLayer *pFbxAnimLayer = pAnimStack->GetMember<FbxAnimLayer>(iLayer);
|
||||
// float weight = pFbxAnimLayer->Weight.Get();
|
||||
KRAnimationLayer *pAnimationLayer = pAnimation->getLayer(pFbxAnimLayer->GetName());
|
||||
|
||||
FbxAnimCurve *pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user