Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Animating the Focal Length
  RSS 2.0 ATOM  

Animating the Focal Length
Rate this thread
 
13549
 
Permlink of this thread  
avatar
  • Trskel
  • Posted: 20 June 2008 11:15 AM
  • Total Posts: 4
  • Joined: 20 June 2008 06:12 PM

Hi all,

I am trying to animate the focal length in a camera, but I don’t find the way to get the animation curve.

I am doing the following:

(I have my manager fbx_manager_ created beforehand and working well, all other stuff I try to animate works fine)

// Create a camera and set some properties
  
KFbxCamerafbx_camera KFbxCamera::Create(fbx_manager_mycamera_name);

  
// Create the camera's node
  
KFbxNodecamera_node KFbxNode::Create(fbx_manager_,mycamera_name);
  
camera_node->SetNodeAttribute(fbx_camera);

  
camera_node->CreateTakeNode(mytake_name);
  
camera_node->SetCurrentTakeNode(mytake_name);

  
fbx_camera->FocalLength.GetKFCurveNode(truemytake_name);

  
KFCurveflength_curve fbx_camera->FocalLength.GetKFCurve(KFCURVENODE_CAMERA_FOCALLENGTHmytake_name);

But this last call to GetKFCurve returns 0.
What is the right way to get the focal length animation curve or is there other way to animate it?
To animate other parameters like position or so on I get the curve from the property in camera_node, but if the node does not contain the focal length property (I have to get it from the KFbxCamera object fbx_camera instead).

Thanks.



Replies: 0
avatar
  • 2knarf
  • Posted: 20 June 2008 11:22 AM

I think the problem is just that you need to use “mytake_name” in this line:

fbx_camera->FocalLength.GetKFCurveNode(true, take_name);



Replies: 0
avatar
  • Trskel
  • Posted: 20 June 2008 02:29 PM

Oh sorry, I made a mistake when transcribing it. It has actually mytake_name, but still does not work.
(I have edited it in the post now)



Replies: 0
avatar
  • Trskel
  • Posted: 23 June 2008 06:48 AM

It seems that the problem is that I cannot do such thing as
fbx_camera->FocalLength.CreateTakeNode(fbx(take_name));
fbx_camera->FocalLength.SetCurrentTakeNode(fbx(take_name));

because FocalLength is a KFbxTypedProperty and does not have those methods. Usually when animating other stuff that is contained in a node (like translation or rotation) it is easy, but in this case you have to animate a curve in a property, and I don’t know how to do it because you cannot call CreateTakeNode() or SetCurrentTakeNode() and I think that is why it always returns a null curve.

How do you animate a property?



Replies: 0
avatar

Hi Trskel,

Try this to get the FocalLength animation curve:

fbx_camera->SetApertureMode(KFbxCamera::eFOCAL_LENGTH);
fbx_camera->FocalLength.GetKFCurveNode(truepTakeName.Buffer()); 
KFCurve *lCurve fbx_camera->FocalLength.GetKFCurve(NULLpTakeName.Buffer());

Viviane



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 1
/userdata/avatar/65df9nc33.JPG

Is this is most recent way to do this?  I am using sdk 20113.  Shouldn’t code snippets state the sdk version?  I have tried a few now that have been out of date.

Thanks
Simon

Author: SimonWakley

Replied: 07 December 2010 08:45 AM  
avatar

Please try this (the codes are valid since FBX SDK 2011 series):

// Create one take of animation
    
KFbxAnimStacklAnimStack KFbxAnimStack::Create(pScene"Take001");
    
KFbxSet<KTime>(lAnimStack->LocalStartKTIME_ONE_SECOND);

    
// this take contains one base layer. In fact having at least one layer is mandatory.
    
KFbxAnimLayerlAnimLayer KFbxAnimLayer::Create(pScene"Base Layer");
    
lAnimStack->AddMember(lAnimLayer);

    
KFbxAnimCurvelCurve fbx_camera->FocalLength.GetCurve<KFbxAnimCurve>(lAnimLayertrue);

For the version of code snippets, I will suggest the FBX SDK developers to mention it when post sample code on AREA.
Also I am thinking to provide a FBX SDK release history in FBX FAQ, then you may compare the time the code snippets are posted on the forum and the FBX SDK release history to estimate which version these code snipptes might be. But this won’t be very precise.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0