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 / ResetPivotSetAndConvertAnimation issue
  RSS 2.0 ATOM  
2 pages: 1.2 first

ResetPivotSetAndConvertAnimation issue
Rate this thread
 
41155
 
Permlink of this thread  
avatar
  • TheSauce
  • Posted: 26 April 2010 08:57 AM

Jiayang Xu 26 April 2010 06:18 AM

2. To call ResetPivotSetAndConvertAnimation(), you actually do not need to SetPivotState(KFbxNode::eSOURCE_SET, KFbxNode::ePIVOT_STATE_ACTIVE) on every node.
Internally the function itself will do so recursively (We will improve document to including this information), so you just need to call it this way:

lRootNode lScene->GetRootNode()
ResetPivotSetAndConvertAnimation(lRootNode)

Hey, I just tried this and it doesn’t work (version 2010.02). I get incorrect results if I only call it on the root node. I get correct results if I manually recursively call it on all nodes in the tree. Is that a new feature in the newer SDK?



Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

No, it is always like this.
2010.02:  ResetPivotSetAndConvertAnimation will reset the pivot (SourceSet and DestinationSet) of all nodes, and convert animation of current take.
2011.2: It will reset the pivot (SourceSet and DestinationSet) of all nodes, and convert animation of the first animstack.

Thanks to your feedback, we realized ResetPivotSetAndConvertAnimation should convert all takes/animstacks other than only work on the current take/first animstack, becasue whenever the pivots are reset, all animation will be affected. I will log a bug for this.

Author: Jiayang Xu

Replied: 26 April 2010 05:42 PM  
avatar

Hi,

This thread was very useful, but I’m still having some troubles. So I took my old code:

scene->SetCurrentTake( takes[ takes.GetCount() 1 ]->Buffer() )
root
->ResetPivotSetAndConvertAnimation( frameratefalsefalse )

And refactored into new code (as described on this thread):

root->ResetPivotSet(KFbxNode::eDESTINATION_SET)
 
for (int i 0takes.GetCount() ++i)
{
 scene
->SetCurrentTake(takes[i]->Buffer())
 SetPivotStateRecursive(root) 
 root
->ConvertPivotAnimationRecursive(KFbxNode::eDESTINATION_SETframeratefalse)
}

root
->ResetPivotSet(KFbxNode::eSOURCE_SET)

where SetPivotStateRecursive looks like this:

void SetPivotStateRecursive(KFbxNodenode)
{
 node
->SetPivotState(KFbxNode::eSOURCE_SETKFbxNode::ePIVOT_STATE_ACTIVE)

 
for (int i 0size node->GetChildCount() i size; ++i)
 {
 KFbxNode
child node->GetChild(i)
 SetPivotStateRecursive(child)
 }
}

It does the trick for animations - all animations are imported correctly, but it messes up these fields:

node->LclTranslation
node
->LclRotation
node
->LclScaling

In old solution these fields used to be similar to animation first frame (I guess it is bind pose or something like that) and we use them for positioning character when animation is not playing. But now after the change these fields are somewhat messed up. Can you tell me what’s the problem?

Many thanks,

Paulius LIEKIS
Unity Technologies



Replies: 2
/userdata/avatar/vx3501hqr_small.jpg

To positioning character when animation is not playing, it would be better to use matrices in bindpose or matrices of clusters.

Call ConvertPivotAnimationRecursive do will convert LclTranslation, LclRotation, LclScaling too, and I need to dig into code to see what exactly happened there and get back to you later. Sorry for the delay.

Author: Jiayang Xu

Replied: 28 April 2010 11:17 PM  
/userdata/avatar/86x4dh6ek.jpg

Hi Jiayang,

I upgraded to FBX SDK 2011.2.

The bad news: ResetPivotSetAndConvertAnimation sets LclScaling to 0,0,0 on bunch of nodes (but that seems to be the case only for that file - I don’t think I have other files with multiple takes).

The good news: the refactored code works as expected.

I’m slightly surprised that ResetPivotSetAndConvertAnimation and “performing it manually using refactored code” returns slightly different results: less by one key and these LclTranslation, LclRotation, LclScaling are different. But that is acceptable, I just though it’s the same code underneath.

Author: Paulius Liekis

Replied: 09 May 2010 11:01 PM  
avatar

Btw.: I noticed that the result is different if I do not loop through first (i.e. take #0), but that doesn’t help me anyway :)



Replies: 0
avatar
  • adario
  • Posted: 03 May 2010 05:32 AM

Paulius,

I do not use the local transformation to compute the initial (should be bind pose) transformation—this way, I’ve never had a file display wrongly when animation is turned off.  However, I’m having some skinning issues (only certain vertices, for specific bones only) on several models that do not contain a correct bind pose.  The issues are limited to skinning since the related bones display correctly at all times.

Since I’m not sure I’ve understood properly the usage (and meaning...?) of ResetPivotSetAndConvertAnimation (and its counterparts), could you please explain me in what cases it is necessary to use these APIs?

Thank you,
Dario



Replies: 1
/userdata/avatar/86x4dh6ek.jpg

Dario,

By default each node has “actual transform” and “offset transform” in 3d tools (like Maya, Max and so on). I think in 3d tool terminology they would be called “origin of a node” and “rotation pivot”. In game engines you usually have just “actual transform”, so the goal of ResetPivotSetAndConvertAnimation is to “bake” “offset transform” into “actual transform”, in order to make “offset transform” to be euqal to identity transform. I believe that that’s what ResetPivotSet does. At the same time once you reset your “offset transform” you animation become broken, because they are based on combination of old transforms, that’s why you have to use ConvertPivotAnimationRecursive.

Does that make sense? :)

Don’t take verything for granted - this is just my understanding :)

Author: Paulius Liekis

Replied: 09 May 2010 10:48 PM  
avatar
  • samcake
  • Posted: 12 October 2010 12:15 PM

Hi All,

Very useful indeed!
One thing that I m seeing and don’t understand
After doing the conversion to a Real Time type of transformation stack (reset everything and just keep T R S) like you indicated, i still get non 0 values when Getting the Post or Pre ROtation Properties ?
Is that a normal behavior ?
Shouldn’t these properties return 0 after doing the conversion making these extra matrices useless ?

Thanks

S



Replies: 4
/userdata/avatar/vx3501hqr_small.jpg

Hi, samcake, ResetPivotSetAndConvertAnimation, as the function name said, will only reset pivot, that is the “offset transform” Paulius mentioned above, and pre/post rotations are not part of that “offset transfom”.

Author: Jiayang Xu

Replied: 12 October 2010 03:57 PM  
/img/forum/dark/default_avatar.png

Does that mean that I MUST integrate pre and post rotations in my matrix transformation stack to get the same result as FBX or is there another conversion possible ?

This wont work well for a standard Real time transformation stack where you usally only have T, R and S per node and that’s it ?

IS there a way i can do a conversion of the transformation stacks and the animations from what ever the state is in the FBX file to a state where i only have TRS per node and not any of the extra other ( pivot, offset pre post, and scaling) ?

I see that the doc propose a source and destination value for the Pre and Post rotations so I assumed they would also be reset by the call.
SHould i do the equivalent of the “ResetPivotSetAndConvertAnimation” call myself + forcing the destination for pre and post rotations to 0 ?
If so can you detail me exactly how to do that ?

THanks

As a side note, do you know how other game engines deal with that ?
DO they add a pre and post rotation matrix in their stack ?

Thanks again

Author: samcake

Replied: 13 October 2010 01:52 PM  
/img/forum/dark/default_avatar.png

Actually, I checked the documentation for ResetPivotSet an it says:
Reset a pivot set to the default pivot context.

Parameters:
pPivotSet Pivot set to reset.

Remarks:
The default pivot context is a context with all the vector attributes set to (0,0,0) except the GeometricScaling attribute that is reset to (1,1,1).

Can you be ultra precise here and document which “vector attributes” ?

Thanks

Author: samcake

Replied: 13 October 2010 02:36 PM  
/img/forum/dark/default_avatar.png

Actually, I checked the documentation for ResetPivotSet an it says:
Reset a pivot set to the default pivot context.

Parameters:
pPivotSet Pivot set to reset.

Remarks:
The default pivot context is a context with all the vector attributes set to (0,0,0) except the GeometricScaling attribute that is reset to (1,1,1).

Can you be ultra precise here and document which “vector attributes” ?

Thanks

Author: samcake

Replied: 13 October 2010 03:11 PM  
avatar
  • samcake
  • Posted: 15 October 2010 01:21 PM

Asking again:

Hi, samcake, ResetPivotSetAndConvertAnimation, as the function name said, will only reset pivot, that is the “offset transform” Paulius mentioned above, and pre/post rotations are not part of that “offset transfom”.

Author: Jiayang Xu

Does that mean that I MUST integrate pre and post rotations in my matrix transformation stack to get the same result as FBX or is there another conversion possible ?

This wont work well for a standard Real time transformation stack where you usally only have T, R and S per node and that’s it ?

IS there a way i can do a conversion of the transformation stacks and the animations from what ever the state is in the FBX file to a state where i only have TRS per node and not any of the extra other ( pivot, offset pre post, and scaling) ?

I see that the doc propose a source and destination value for the Pre and Post rotations so I assumed they would also be reset by the call.
SHould i do the equivalent of the “ResetPivotSetAndConvertAnimation” call myself + forcing the destination for pre and post rotations to 0 ?
If so can you detail me exactly how to do that ?

I checked the documentation for ResetPivotSet an it says:

Reset a pivot set to the default pivot context.

Parameters:
pPivotSet Pivot set to reset.

Remarks:
The default pivot context is a context with all the vector attributes set to (0,0,0) except the GeometricScaling attribute that is reset to (1,1,1).

Can you be ultra precise here and document which “vector attributes” ?

THanks

As a side note, do you know how other game engines deal with that ?
DO they add a pre and post rotation matrix in their stack ?

Thanks again



Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

Dear samcake, sorry, I realized what I said above is not correct after I re-checked the code.
ResetPivot will set all vector attribute to (0,0,0), including pre/post rotation.

If you still get non-zero pre/post rotation after the call to ResetPivotSetAndConvertAnimation, please try this to update/sync properties and limits from the newly reset pivot:
lNode->ResetPivotSetAndConvertAnimation();
lNode->UpdatePropertiesFromPivotsAndLimits();

Author: Jiayang Xu

Replied: 17 October 2010 03:32 PM  
2 pages: 1.2 first