Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FBX SDK Animation Curve Interpolation Problem

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
723 Views, 0 Replies

FBX SDK Animation Curve Interpolation Problem

Hello guys,

 

I'm using FBX C++ SDK to convert some animation data to FBX. When i use eInterpolationConstant there is no problem. Then i use eInterpolationLinear or eInterpolationCubic and something goes wrong.

 

Here is my main problem;

 

 

I have another problem;

 

When i'm importing the fbx file i converted, there is 992 keys appear. But i think it is a problem. Because when im importing with checked "Use Default Sample Rate(30 FPS)" option  OR i import blender fbx file then export and import again unreal it shows 25 FPS and there is no change in the animation.

 

Default(992)

tugrulsert_0-1632609184876.png

tugrulsert_1-1632609195173.png

With option(30)

tugrulsert_2-1632609201549.png

 

And there are no changes. Sorry for bad english.

 

Code to check interpolation:

 

for (int k = 0; k < TrackCount; ++k)
{
	....
	....

	FbxNode* skel_node = skel_n_map.find(Track[k]->Name);

	FbxAnimCurve* rot_curve_x = skel_node->LclRotation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_X, true);
	FbxAnimCurve* rot_curve_y = skel_node->LclRotation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Y, true);
	FbxAnimCurve* rot_curve_z = skel_node->LclRotation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Z, true);
	FbxAnimCurve* pos_curve_x = skel_node->LclTranslation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_X, true);
	FbxAnimCurve* pos_curve_y = skel_node->LclTranslation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Y, true);
	FbxAnimCurve* pos_curve_z = skel_node->LclTranslation.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Z, true);
	FbxAnimCurve* scale_curve_x = skel_node->LclScaling.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_X, true);
	FbxAnimCurve* scale_curve_y = skel_node->LclScaling.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Y, true);
	FbxAnimCurve* scale_curve_z = skel_node->LclScaling.GetCurve(anim_layer, FBXSDK_CURVENODE_COMPONENT_Z, true);

	rot_curve_x->KeyModifyBegin();
	rot_curve_y->KeyModifyBegin();
	rot_curve_z->KeyModifyBegin();

	for (int i = 0; i < OrientationKeyCount; ++i)
	{
		...
		...
		// orientation is quaternion data.
		FbxQuaternion rotquat(
			OrientationKey[i]->orientation[0], 
			OrientationKey[i]->orientation[1], 
			OrientationKey[i]->orientation[2], 
			OrientationKey[i]->orientation[3]
		);

		FbxAMatrix rotation_matrix;
		FbxVector4 eul_rotation;
		rotation_matrix.SetQOnly(rotquat);
		eul_rotation = rotation_matrix.GetROnly();

		FbxTime crvtime;
		crvtime.SetSecondDouble(OrientationKey[i]->Time);

		int key_index;

		key_index = rot_curve_x->KeyAdd(crvtime);
		rot_curve_x->KeySet(key_index, crvtime, (float)eul_rotation[0], FbxAnimCurveDef::eInterpolationLinear);

		key_index = rot_curve_y->KeyAdd(crvtime);
		rot_curve_y->KeySet(key_index, crvtime, (float)eul_rotation[1], FbxAnimCurveDef::eInterpolationLinear);

		key_index = rot_curve_z->KeyAdd(crvtime);
		rot_curve_z->KeySet(key_index, crvtime, (float)eul_rotation[2], FbxAnimCurveDef::eInterpolationLinear);
	}

	rot_curve_x->KeyModifyEnd();
	rot_curve_y->KeyModifyEnd();
	rot_curve_z->KeyModifyEnd();

	pos_curve_x->KeyModifyBegin();
	pos_curve_y->KeyModifyBegin();
	pos_curve_z->KeyModifyBegin();

	for (int i = 0; i < PositionKeyCount; ++i)
	{
		....
		....

		FbxTime crvtime;
		crvtime.SetSecondDouble(PositionKey[i]->Time);

		int key_index;

		key_index = pos_curve_x->KeyAdd(crvtime);
		pos_curve_x->KeySet(key_index, crvtime, PositionKey[i]->pos[0]);

		key_index = pos_curve_y->KeyAdd(crvtime);
		pos_curve_y->KeySet(key_index, crvtime, PositionKey[i]->pos[1]);

		key_index = pos_curve_z->KeyAdd(crvtime);
		pos_curve_z->KeySet(key_index, crvtime, PositionKey[i]->pos[2]);
	}

	pos_curve_x->KeyModifyEnd();
	pos_curve_y->KeyModifyEnd();
	pos_curve_z->KeyModifyEnd();

	scale_curve_x->KeyModifyBegin();
	scale_curve_y->KeyModifyBegin();
	scale_curve_z->KeyModifyBegin();

	for (int i = 0; i < ScaleKeyCount; ++i)
	{
		....
		....

		FbxTime crvtime;
		crvtime.SetSecondDouble(ScaleKey[i]->Time);

		int key_index;

		key_index = scale_curve_x->KeyAdd(crvtime);
		scale_curve_x->KeySet(key_index, crvtime, ScaleKey[i]->scal[0]);

		key_index = scale_curve_y->KeyAdd(crvtime);
		scale_curve_y->KeySet(key_index, crvtime, ScaleKey[i]->scal[1]);

		key_index = scale_curve_z->KeyAdd(crvtime);
		scale_curve_z->KeySet(key_index, crvtime, ScaleKey[i]->scal[2]);
	}

	scale_curve_x->KeyModifyEnd();
	scale_curve_y->KeyModifyEnd();
	scale_curve_z->KeyModifyEnd();
}

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report