So recently I was asked by a friend to convert a few FBX files to C3X/CoCos format for a game he’s developing. Seemed simple enough but kept resulting in 1KB files!
Quickly researching the task seemed simple enough, someone had already written and compiled a windows binary for it: https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/tree/v3/fbx-conv
So downloaded binary, downloaded FBX file, ran with the -a switch and done!
D:\Data\Downloads\FBX\fbx>fbx-conv.exe -a "Dragon 2.5_fbx.fbx" INFO: FBX to c3x converter, version 0.7 x32 (release version, cocos2d-x-3.4-beta0 or later version can use) STATUS: Loading source file WARNING: Mesh contains more indices (113958) than the specified maximum (32767) STATUS: Converting source file STATUS: Closing source file STATUS: Exporting to c3t file: Dragon 2.5_fbx.c3t STATUS: Exporting to c3b file: Dragon 2.5_fbx.c3b STATUS: Closing exported file
This was only a test file so I could safely ignore the mesh indices being too large. So off I went, downloaded all the FBX assets he’d purchased and converted them all. Sent them across to him, only to get a message an hour later saying the dev says they’re all empty! Checking the files I’d sent him indeed shows they’re 1KB!
They were small files to convert so I expected the output to be tiny but 1KB is definitely too small. Running it with verbose enabled shows a bit more of the story: Check out the below output and see if you can spot it:
D:\Data\Downloads\FBX\drive-download-20190328T192009Z-001\Hex_Crystal>fbx-conv.exe -v -a Base_low.fbx INFO: FBX to c3x converter, version 0.7 x32 (release version, cocos2d-x-3.4-beta0 or later version can use) STATUS: Loading source file PROGRESS: Import FBX 100.00% STATUS: Converting source file STATUS: Closing source file VERBOSE: Listing model information: VERBOSE: ID : VERBOSE: Version : Hi=0, Lo=7 VERBOSE: Meshes : 0 (0 vertices, 0 parts, 0 indices) VERBOSE: Nodes : 0 root, 0 total, 0 parts VERBOSE: Materials : 0 (0 textures) STATUS: Exporting to c3t file: Base_low.c3t STATUS: Exporting to c3b file: Base_low.c3b STATUS: Closing exported file
Yep, that’s right. 0 meshes, 0 nodes and no mention of polygons or indices!
Obviously needing to dig further I downloaded and installed Autodesk FBX Review to see them (https://apps.autodesk.com/MAYA/en/Detail/Index?id=6979630331069053932&appLang=en&os=Win64) and opened the files.
Both loading and rendering fine. Sure the scale is way off but the crystal towers certainly have more than 0 nodes. So logically it must be the tool used.
Onto the next step – can I convert it into anything? Lets try the official Autodesk FBX Converter (https://www.autodesk.com/developer-network/platform-technologies/fbx-converter-archives). Sure it can’t do C3X but the objective now is just to see if it works.
Typical. Dragon works and Crystal doesn’t! However this seems to give a bit more information – “Not enough parameters” and no creator! Back to google it is!
Eventually after a fair bit of digging, downloading random FBX assets and trying to convert them I eventually found the issue – any assets made after 2016 don’t work.
Bit more digging and found the AutoDesk Changelog document – https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_2ADB9BCE_15EA_485F_87C2_32D43F2D219D_htm
Specifically note the 2016 second point: “Updated the FBX file format to 7.5. This new file format is only compatible with the 2016 or later product versions that use 64-bit integers in the binary block headers for large file support (> 2GB).“
There we go! New files are completely different, which explains why the old Autodesk tool converter didn’t work either. As a test I then downloaded a trial of Autodesk Maya, opened the original FBX file, saved as 2014-2015 version and then ran the FBX to C3X.
D:\Data\Downloads\FBX\drive-download-20190328T192009Z-001\Hex_Crystal>fbx-conv.exe -v -a Base_low_1.fbx INFO: FBX to c3x converter, version 0.7 x32 (release version, cocos2d-x-3.4-beta0 or later version can use) STATUS: Loading source file PROGRESS: Import FBX 100.00% STATUS: [shape(Base_low)] Triangulating FbxMesh geometry VERBOSE: [shape(Crystal_low)] polygons: 32 (96 indices), control points: 20 VERBOSE: [shape(Base_low)] polygons: 48 (144 indices), control points: 30 STATUS: Converting source file STATUS: Closing source file VERBOSE: Listing model information: VERBOSE: ID : VERBOSE: Version : Hi=0, Lo=7 VERBOSE: Meshes : 1 (496 vertices, 2 parts, 240 indices) VERBOSE: Nodes : 2 root, 2 total, 2 parts VERBOSE: Materials : 1 (0 textures) STATUS: Exporting to c3t file: Base_low_1.c3t STATUS: Exporting to c3b file: Base_low_1.c3b STATUS: Closing exported file
Finally got there; we have meshes, nodes, indices and more importantly a 4KB C3B file and a 9KB C3T! The artist has now been requested to save them in this format and my friend is happily converting them as and when he needs.
TLDR: New FBX + old C3X = bad. If you want to convert FBX to C3X using the CLI tool then save your FBX as versions prior to 2016!