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 / KFbxScene::GetNodeGlobalTransform() vs KFbxNode::GetGlobalFromDefaultTake()
  RSS 2.0 ATOM  

KFbxScene::GetNodeGlobalTransform() vs KFbxNode::GetGlobalFromDefaultTake()
Rate this thread
 
43111
 
Permlink of this thread  
avatar
  • EJulien
  • Posted: 11 May 2010 11:16 PM
  • Total Posts: 3
  • Joined: 12 May 2010 06:07 AM

I just migrated our FBX importer to the new FBX SDK (from 2010.2 to 2011.2) and mainly had to port the animation baking code to do so.

It was fairly straightforward but switching from the deprecated KFbxNode::GetGlobalFromDefaultTake() to KFbxScene::GetNodeGlobalTransform() breaks all transformations. As I have no clue looking through the documentation as to what might have changed I am posting here for insight.

I would expect both functions to return the same Matrix for a given node and a given take (or the corresponding animstack) but no.

By the way, KFbxNode::GetGlobalFromDefaultTake() still works but cannot be used to bake animations so I need a workaround for this.

Thanks,
Emmanuel



Replies: 0
avatar

Hi Emmanuel,

I don’t know if this can help you, but try building your node tree before using the evaluator.

For instance, we had to update example ExportScene01 so that the poses and animations are now computed or stored after the node tree is built. In previous versions of the FBX SDK, the order of these operations was not important, but now the evaluator needs the scene to be built to evaluate properly.

Viviane, FBX Team



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 0
avatar
  • EJulien
  • Posted: 12 May 2010 09:13 AM

Hi and thank you for your answer Viviane,

I am however not sure I understand your suggestion. I am using the FBX SDK to load a .fbx file via a KFbxImporter (pretty much like examples/ImportScene) then parse the KFbxScene content to our native structures.

I am walking the node tree as the exporter goes (in a rather chaotic way, eg. grabbing bones as they come into play on a mesh, etc...) but I fail to see how I could “setup the node tree” myself. I expect it to be in a complete state and ready for parsing after the importer is done loading the file.

Is there an additional step I am missing? In order to bake the motion for a node I basically do:

...
fbx_scene->GetEvaluator()->SetContext(anim_stack)
...
for 
(KTime t tStart(tEnd tStep) t += tStep)
...
fbx_scene->GetEvaluator()->GetNodeGlobalTransform(pNodet)

Yes, in case of multiple animstack the evaluator context will be swapped with each node several times but this surely isn’t a problem?

I am skipping a lot of details but I believe the problem boils down to this group of lines.
The export was fine when using

pNode->GetGlobalFromCurrentTake(t)

instead of

fbx_scene->GetEvaluator()->GetNodeGlobalTransform(pNodet)

Ps: Sorry for the odd formatting the post would appear truncated on the board without it.

Emmanuel



Replies: 0
avatar

Hi Emmanuel,

Ok, my previous comments do not apply since, as you mention, the node tree is already built and the scene properly loaded when you evaluate it.

After verification in the code, deprecated function

pNode->GetGlobalFromCurrentTake(t)

actually calls

GetNodeGlobalTransform(pNodet)

( as long as

pNode->GetScene()

returns a non-NULL pointer).

So that would leave the context as the culprit. Did you try not calling GetContext() at all? Do you have more than one animation stack in your scene?

Viviane



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 0
avatar

Did you set the evaluator context for the take?

void FBXLoader::AddAnimation(KFbxScenepScene)
{

  HRESULT hr
;
  
KFbxNoderootNode pScene->GetRootNode()

  
for (int i 0pScene->GetSrcObjectCount(FBX_TYPE(KFbxAnimStack)) i++)
  {
    KFbxAnimStack
lAnimStack KFbxCast<KFbxAnimStack>(pScene->GetSrcObject(FBX_TYPE(KFbxAnimStack)i))
  
    pScene
->GetEvaluator()->SetContext(lAnimStack) // <------------------HERE 

    
const char name lAnimStack->GetName()
    AddAnimationRecursive(lAnimStack
rootNodem_pRootFrame)
  }
}


Replies: 0
avatar
  • EJulien
  • Posted: 14 May 2010 09:49 AM

Hi Viviane, hi Doug,

I had no time to look into this issue until today.
As it turns out I owe you an apology for making you loose some time.
The bug was on my side, I somehow managed to screw up a parenthesis while converting the code.

Everything is working as expected so this is great.
Thanks for the help.

Emmanuel



Replies: 0
avatar

Ok, no problem, thanks for the report!

Viviane



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 0