Loading fbx structures manually (extracting vertices and indices)

I wrote a simple 3D wireframe renderer in openGL. I made most of the things manually, like calculating pixel coordinates and the model, view and pixel matrices needed for that and so on. The only openGL feature I used is the simple draw-command to render individual triangles.

The way this program works is that it takes a number of triangle meshes, transforms them and then renders them. A triangle mesh is nothing more than a vector of vertices and a vector of indices. Those can easily be transformed in-place their storage structure and passed on to openGL pretty easily.

I manually define simple meshes (like a cube for example) inside the source code. But I’d like to import some larger models as well.

fbx is a common file format, which stores 3D objects. I have searched a few forums for a little while but didn’t find anything that seemed relevant to my case.

Is there any way to manually extract the vertices and indices from an fbx file? I know an fbx file contains more stuff, but those two things are the only things I’m interested in.

If fbx doesn’t work, any other 3D format that allows me to extract vertices and indices would also be appreciated.

I’m not particularly familiar with FBX. The file format lacks official documentation (the Blender project has produced some unofficial documentation), although a SDK is available from Adobe. If you want to write your own importer, the Wavefront OBJ format is simple and well documented.

As mentioned above, the Wavefront OBJ format is simple to parse, but it doesn’t support a few features, like vertex colors (if you support them).

Another format you can use is the PLY format, which was made flexible enough to hold pretty much most vertex attributes (normals, texture coordinates, vertex colors), but it also supports custom ones as well. It might be a bit tricker to parse, but it’s design is pretty much documented online.

glTF (https://www.khronos.org/gltf/) is a Khronos format that is designed to store mesh data (and more) in a format appropriate for realtime APIs like OpenGL, i.e. without string parsing of vertex data as in OBJ or PLY. It contains a short JSON header describing the layout of one or more binary buffers.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.