Writing custom 3d importer

This past spring I had a class where we used UE4 to build simple games, and I had a lot of fun.

Years ago while in high school I wrote my own simple 3d editing software akin to Milkshape but simpler to handle editing a very old proprietary 3d format. In so doing, I realized that parsing and dealing with the 3d data is entirely humanly possible even for a high school kid.

This 3d editing software was written in Java and included classes for parsing, holding the whole 3d model in Java objects in RAM, and saving this ancient proprietary format back to disk. The fact that they’re Java isn’t important; I could probably rewrite them in C++.

What is important is that I was interested in creating a pipeline that would let me bring these ancient proprietary 3d models into UE4. We can assume that nobody has code to convert them into any modern format, so I have to write the code myself (whether an ancient format -> FBX pipeline, or ancient format -> UE4 importer). However, I do not have any experience writing code to interact with the FBX format, nor writing plugins for UE4 (which I previously just downloaded and used as an application).

We can assume that this proprietary format has:

  • Model geometry (vertices, triangles, texture coordinates for each material on the surface, one normal vector per vertex)
  • Image data for a texture to put onto a model, including both the actual image in binary as well as blend mode information, billboarding and other metadata, and which part of the model which texture maps to
  • Model animations, always with a skeleton of at least one single bone node even for static models, baked into the same binary file, where each vertex maps to one or more element(s) in the tree of bone nodes, and each node can have scale/rotation/translation data for each time in each animation (which are also named and baked into this binary file)

So, if I wanted to suck in hundreds or thousands of these fully functional rigged and animated models in this ancient arcane format from 15 years ago into UE4 for some fun, my question really is this: where do I start coding? Is it better to make a UE4 plugin, or something to convert to FBX?

The models were made about 15 years ago with a custom 3dx max exporter from before Autodesk owned max. I’m playing with them educationally and I do not have original .3ds files or anything (would anyone? haha), as I do not own the source code to game they came from. But since high school me was able to code an editor for them, how hard can FBX/UE4 be to deal with, right? So I’m interested in trying to write an importer to UE4 this summer for some fun, to jumpstart even more fun playing with UE4. But where do I start?

Thanks guys!

I can’t help you with your first question I’m afraid since I have very little knowledge of 3D modelling - my workflow usually consists of importing someone else’s FBX file and then cursing at the screen and checking random boxes until it works. So maybe someone else can tell you which approach would be your best option here. My gut instinct says it would be easier to write a straight importer rather than an FBX convertor, since you have access to the full UE source code, and FBX is a rather closed format from what I understand, which would make debugging the conversion tool an unpleasant experience.

As for writing plugins for UE4, you’re in luck! Epic have made an excellent video that covers all of the ways you can modify the editor to suit your needs and how to do it: https://www.youtube.com/watch?v=zg_VstBxDi8. I highly recommend watching it if you are planning to write an editor plugin. There’s also the Plugin Documentation which covers the basics and will get you started with a Hello World type plugin. Having written a custom asset importer plugin myself, I would also say that it pays off to simply look at existing engine plugins to see how it’s done. For importing assets specifically, you may want to take a look at SoundMod (defines a custom asset type and a very basic importer for it) and SpeedTreeImporter (similar but more advanced, has a UI with import options). There are probably others but those are good ones off the top of my head. Finally there’s the FBX importer which will obviously be of interest to you, but beware it is quite hairy and spans many different source files. It’s also part of the editor (not a plugin), so keep that in mind.