AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Animation of scale not working
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Animation of scale not working
Rate this thread
 
48066
 
Permlink of this thread  
avatar
  • Total Posts: 15
  • Joined: 29 September 2010 03:25 PM

Hi everyone!

I would be very very grateful to you if you could look at the code snippet bellow and tell me what am I doing wrong? I am basically just trying to create an animation of my 3d model by changing its scale..

LoadScene(mAnimShapeFamily.getSDKManager(), mAnimSceneFBX"data/tmp/tmpAnim.fbx");
 
 
KFbxAnimStackmyAnimStack KFbxAnimStack::Create(mAnimSceneFBX"My stack");
 
KFbxAnimLayermyAnimBaseLayer KFbxAnimLayer::Create(mAnimSceneFBX"Layer0");
 
myAnimStack->AddMember(myAnimBaseLayer);
 
 
{
 KFbxNode 
*node mAnimSceneFBX->FindNodeByName("Body");
 
 
KFbxAnimCurveNode *myAnimCurvenode node->LclScaling.GetCurveNode(myAnimBaseLayertrue);

 
KFbxAnimCurvemyTranXCurve NULL;
 
KTime myTime;
 
 
myTranXCurve node->LclScaling.GetCurve<KFbxAnimCurve>(myAnimBaseLayerKFCURVENODE_S_Xtrue);
 
myTranXCurve->KeyModifyBegin();
 
 
myTime.SetSecondDouble(0.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(00.0);
 
myTranXCurve->KeySetInterpolation(0KFbxAnimCurveDef::eINTERPOLATION_LINEAR);

 
myTime.SetSecondDouble(5.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(1010.0);
 
myTranXCurve->KeySetInterpolation(0KFbxAnimCurveDef::eINTERPOLATION_LINEAR);

 
myTime.SetSecondDouble(10.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(20100.0);
 
myTranXCurve->KeySetInterpolation(0KFbxAnimCurveDef::eINTERPOLATION_LINEAR);
 
 
 
myTranXCurve->KeyModifyEnd(); 
 

 
 SaveScene
(mAnimShapeFamily.getSDKManager(), mAnimSceneFBX"data/tmp/tmppp.fbx");

Thanks in advance!



Replies: 0
avatar

Hi arjunjain,

The first argument to KeySetValue() is the index of the key in the curve. So the second and third time you call it, you should call KeySetValue(1, 10.0) and KeySetValue(2, 100.0). There is no key at indexes 10 and 20 that were specified.

Viviane
Autodesk Data Platform



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 1
/userdata/avatar/r70k1g9fx.jpeg

Dear Viviane!

Thanks a ton for your reply! :)

So the changed code is bellow, and you want, you can find the fbx files (the one that is loaded in the beginning, and the one that is generated) here: http://www.mpi-inf.mpg.de/~ajain/fbx/

I would really appreciate if you look into it.

Thanks a lot in advance!
Kind regards,
Arjun

mAnimModel.saveModel("data/tmp/tmpAnim.fbx");
 
LoadScene(mAnimShapeFamily.getSDKManager(), mAnimSceneFBX"data/tmp/tmpAnim.fbx");

 
 
KFbxAnimStackmyAnimStack KFbxAnimStack::Create(mAnimSceneFBX"My stack");
 
KFbxAnimLayermyAnimBaseLayer KFbxAnimLayer::Create(mAnimSceneFBX"Layer0");
 
myAnimStack->AddMember(myAnimBaseLayer);


 
 
tree <treeNode> const & currTree mAnimModel.getTree();
 
tree <treeNode>::iterator it currTree.begin();

 
//for(; it != currTree.end(); it++)
 
{
 KFbxNode 
*node mAnimSceneFBX->FindNodeByName(it->mPartName.c_str());
 
printf("\n%s[%s]"it->mPartName.c_str(), it->mTreeKey.c_str()); //Prints body
 
 
KFbxAnimCurveNode *myAnimCurvenode node->LclScaling.GetCurveNode(myAnimBaseLayertrue);

 
KFbxAnimCurvemyTranXCurve NULL;
 
KTime myTime;
 
 
myTranXCurve node->LclScaling.GetCurve<KFbxAnimCurve>(myAnimBaseLayerKFCURVENODE_S_Xtrue);
 
myTranXCurve->KeyModifyBegin();
 
 
myTime.SetSecondDouble(0.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(00.0);
 
myTranXCurve->KeySetInterpolation(0KFbxAnimCurveDef::eINTERPOLATION_LINEAR);

 
myTime.SetSecondDouble(10.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(110.0);
 
myTranXCurve->KeySetInterpolation(1KFbxAnimCurveDef::eINTERPOLATION_LINEAR);

 
myTime.SetSecondDouble(20.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(2100.0);
 
myTranXCurve->KeySetInterpolation(2KFbxAnimCurveDef::eINTERPOLATION_LINEAR); 

 
myTime.SetSecondDouble(30.0);
 
myTranXCurve->KeyAdd(myTime);
 
myTranXCurve->KeySetValue(310.0);
 
myTranXCurve->KeySetInterpolation(3KFbxAnimCurveDef::eINTERPOLATION_LINEAR); 
 
 
myTranXCurve->KeyModifyEnd(); 
 

 
 SaveScene
(mAnimShapeFamily.getSDKManager(), mAnimSceneFBX"data/tmp/tmppp.fbx");

If you

Author: arjunjain

Replied: 06 October 2010 05:30 AM  
avatar

Hi Arjun,

It seems to work now. The saved file has its scale animated. You can verify it using the ViewScene example.

Viviane
Autodesk Data Platform



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 1
/userdata/avatar/r70k1g9fx.jpeg

Dear Viviane!

You are my savior! :) Yes, you are right, I can verify it using the ViewScene example.

But, I have one last question- so, I was troubled because when I import the same file into my 3ds Max 2010, the animation doesn’t seem to work. I also tried to import some of the other files generated by the examples into my 3ds Max 2010, and parts of it seem to be broken. Why is it so? How can I successfully import these into Max? Is it because the fbx sdk is 2011 and I use Max 2010?

Thanks a lot once again for your kind replies Viviane :)

Warm regards,
Arjun

Author: arjunjain

Replied: 07 October 2010 07:19 AM  
avatar

Hi Arjun,

Possibly your 3ds Max FBX plug-in is not up to date. For example if you are using FBX SDK 2011.3.1, you can also download 3ds Max FBX plug-in 2011.3.1 for Max 2010. It should help.

Viviane
Maya Data Platform
Autodesk



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 0
avatar

Dear Viviane,

I just downloaded the 2011 fbx plugin for 3ds max, and - it works! :) Thanks so much. I am slowly starting to like this sdk :D

Thanks a lot once again,
Arjun



Replies: 0