|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Animating the Focal Length
|
|
|
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
KFbxCamera* fbx_camera = KFbxCamera::Create(fbx_manager_, mycamera_name);
// Create the camera's node
KFbxNode* camera_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(true, mytake_name);
KFCurve* flength_curve = fbx_camera->FocalLength.GetKFCurve(KFCURVENODE_CAMERA_FOCALLENGTH, mytake_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.
|
|
|
|
I think the problem is just that you need to use “mytake_name” in this line:
fbx_camera->FocalLength.GetKFCurveNode(true, take_name);
|
|
|
|
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)
|
|
|
|
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?
|
|
|
|
Hi Trskel,
Try this to get the FocalLength animation curve:
fbx_camera->SetApertureMode(KFbxCamera::eFOCAL_LENGTH); fbx_camera->FocalLength.GetKFCurveNode(true, pTakeName.Buffer()); KFCurve *lCurve = fbx_camera->FocalLength.GetKFCurve(NULL, pTakeName.Buffer());
Viviane
Viviane Rochon
Maya Data Platform
Autodesk
|
|
|
|
|
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
|
|
|
|
|
Please try this (the codes are valid since FBX SDK 2011 series):
// Create one take of animation
KFbxAnimStack* lAnimStack = KFbxAnimStack::Create(pScene, "Take001");
KFbxSet<KTime>(lAnimStack->LocalStart, KTIME_ONE_SECOND);
// this take contains one base layer. In fact having at least one layer is mandatory.
KFbxAnimLayer* lAnimLayer = KFbxAnimLayer::Create(pScene, "Base Layer");
lAnimStack->AddMember(lAnimLayer);
KFbxAnimCurve* lCurve = fbx_camera->FocalLength.GetCurve<KFbxAnimCurve>(lAnimLayer, true);
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
|
|
|
|
|
|