Controlling skeleton in ofxFbx

I’m just starting to get into importing 3D models into OF and am having some confusion around ofxFbx. I saw this video https://vimeo.com/127721878 but it’s unclear to me how to actually control/move the bones, is there an example of this anywhere? Or if anyone has some tips that would be great too!

Hi Aashish,

The fbx addon used for that video is located here:

The example provided in the addon shows how to load fbx models and animations. The function getBone(“name”) in ofxFBXManager is an easy way to get bones from the fbx model.

Remember that all of the bones in ofxFBXManager are parented according to the skeleton structure and their ‘world’ position is relative to the ofxFBXManager. So to convert a bone position to a position in OF world space would be:

ofxFBXBone* bone = fbxManager.getBone("spine01");
ofMatrix4x4 globalTransform = bone->getWorldTransformMatrix() * fbxManager.getWorldTransformMatrix();

I see, yeah i’ve been using ofxFbx, it seems like a rad library!

2 questions:

  1. bone and fbxManager seem to not have getWorldTransformMatrix, but they have getGlobalTransformMatrix, is that what I should use? or am I on a different version than I should be? Im on OF 0.8.4 and master for ofxFbx

  2. After I get the globalTransform matrix and the bone, do I just want to alter globalTransform and then use bone->setTransformMatrix?

1). getGlobalTransformMatrix should be correct ( bones extend ofNode ).

2). Yes, you can set the matrix using bone->setTransformMatrix. This only applies to the local matrix, so make sure to multiply by the inverse of it’s parent.

I have been working a lot with fbx bones and this addon. I have been re-factoring the code. So if you have any input on what might be useful, that would help. :slight_smile:

Ah I see, thanks for your help! I noticed theres also setPosition and then updateFbxTransform which seems to work alright too, but I’m hoping to get more familiar with transformMatrix as well so I’ll try that out. If I have any thoughts about refactoring I’ll be sure to let you know!

I have been working on making the bone manipulation easier, so that they are parented to the fbxManager. There is an example showing how to control the head to look at a light.
https://github.com/NickHardeman/ofxFBX/tree/develop

1 Like

Hi Nick,
Thanks for the great work on FBX, amazing.

I’m trying to use kinect skeleton data to animate a FBX mesh. I want to use joints rotation information to do so, but openni gives matrix3x3… and i’m stuck with weird orientations as you can see:

Did you try to link a FBX skeleton to a kinect one … ?
Any advice would be really appreciated!

Thanks

hey @NickHardeman, what about to use your addon to load full scene / lights / materials?
The old arturoc/ ofxFBX has this functions.
What format do you think could be better to use for export a scene from Cinema 4D, Maya, Blender…etc?

Right now the add-on attempts to load in texture and basic information from the materials, but can be difficult to extract because of the breadth of possibilities from different 3D programs. For this reason, it can be tricky to set the texture and material property information in a 3D program and get it out in the add-on. (See https://github.com/NickHardeman/ofxFBX/blob/master/src/ofxFBXMeshMaterial.cpp). The class is using older GL calls, so it probably won’t work with the programmable renderer. Sometimes I just extract the texture and bind it outside of the add-on (tex.bind(); fbx.draw(); tex.unbind(); )
The lights and cameras seems more approachable from an implementation perspective based on @arturo’s add-on. I’m not seeing the material functionality in his add-on that you’re referring to. Right now I don’t have the time to implement the light and camera functionality, but am open to pull requests :slight_smile:

Thanks for the explanation @NickHardeman,
so maybe we could use the core ofxAssimpModelLoader. Not sure what benefit has the FBX format and the addon if we are not using bones animations. Maybe obj and others could be nice for static objects.

The ofxFBX addon is definitely focused on bones and animations. I haven’t tried to load a full scene with different materials, cameras, lights, etc., so I can’t provide any helpful tips :slight_smile:

@NickHardeman
How do i control the animations of a 3d humanoid if i have the pose of a 2d person?

Hello,

You will need to calculate the bone orientation from the 2d person and then set them directly on the 3D model. If you need to create the orientation quaternion, it might be easiest to use ofNode. ie. Set the position of the ofNode at the 2D shoulder and call lookAt to point to the elbow. Then you can get the matrix from that node and set the 3D shoulder orientation. You would have to go down all of the bone hierarchy to set all of them.