Monday, November 28, 2011

FBX Exporter

Hi
after the last post, i had to create a new plan and the first phase was to support different app's to create assets from.

up until now, i use my own maya exporter, which converts models/animations to my own format the engine can read.
this exporter was created entirely for the artist as he worked with maya.

for the record, i don't know to work with maya, but i know to work with 3dsmax, at the time, i didn't want to handle models/animation and prefer to focus on dev but now i will need to do both.

anyway, i decided that an FBX exporter will be good since i know to model/animate with max so i could create few things here and there and in the future i will not bound to a single software, and this is great as finding artist will be much easier if you are not bound to single app.

for these who don't know FBX format: FBX is an autodesk format created so you could share works with different autodesk app's like maya, 3dsmax, softimage, motionbuilder, mudbox etc...
FBX it comes will full SDK & samples and have fairly readable doc that explain how to use and build FBX app. (can be downloaded from autodesk site)

because i already had maya exporter which had all the conversion code to the engine, i just needed to import the fbx and convert everything just like i did with the old exporter, and within few hours i had support for models (no animation).

to support animation i had to dig a little bit as at first i tried to convert the matrices imported from the FBX to engine format at import time (left handed Z up) and that didn't went very well, as the hierarchy of the skeleton needed to work with the stored format, even when i succeeded the animation was screw up.
so what i did i imported the data as is (not changing/converting anything) and only in the exporting phase (just before writing to a file) i convert to my own engine format.
just like i did in the old maya exporter...
i burn a lot of hours just to realize that what i did in the old maya exporter was correct, if i just went and look at the old code i could save a lot of time and thinking...

after i finishing this i notice few animation didn't running correctly, some vertices isn't moving like they supposed to (relative the the skeleton), and after digging a little more i saw that some code i took from the old exporter wasn't fit right for the new one, and the vertices indices wasn't correct.
'vertices indices' means i have for each vertex X indices or more, for vertex position,normal,uv etc.. so these was screw up (the order wasn't correct) and the nasty thing is that for few test models with animation there was no bug at all and for some there was.

NOTE: the skeleton always act and looks fine but vertices wasn't, so it was hard to track down the bug.
the way i eventually track it is that i created a very simple model with animation and compare each of the vertices weights with the vertices weights exported (using weight table in 3dsmax), when i did that i notice that the weights values was fine but the order wasn't, so few vertices that influence by bone1 was influence by bone2 etc...

anyway, one thing to remember from this is that when you take code from some old code of yours make sure to check it fits, and don't assume its good.
it can be good/clean code but it doesn't means it fits like a glove...

so now that the pipeline works you will see some works on the next posts...
cya

3 comments:

Jyggalag said...

Hi Oren, i didn't have time to keep up with your latest updates, sorry to hear you were backstabbed by that jerk, i was really looking forward to see bits of your upcoming project.
If i was more proficient with my 3D works, i would have sent you some free models.
I'm going to be stuck using a program that i really hate for the next few months (LightWave....yack!)
anyway thanks for updating, goodluck!

orenk2k said...

Hi Ido
thanks, my project is still a live, i had to make few changes, scene models etc... but its live and kicking.
right now i'm also model/texture/animate and to tell you the truth its not rocket science, its just takes time.
stay tuned, soon i will post about it...
cya

Yakov said...

as I remember I spent quite amount of time trying to fix import of skeletons from fbx in my engine. Same reason - different axis system. And it still not robust - skeleton now should be aligned with center of world.(0,0,0)