In the last assignment I created a lua based asset file that would be loaded at runtime. I made sure the file was “human readable” even though the application would take a performance hit when loading and parsing it because the objective was not make it performant. But if we change the format to make it easy to load at runtime, we might lose readability. In this assignment I aim to fix this problem by having the best of both worlds.
As part of MeshBuilder project, I take my human readable asset file and “build” it into a binary file which the project can easily load at runtime with almost no lua parsing involved. The idea is to be able to read and edit the file and not having to worry about the parsing and loading overhead during runtime.
Once the asset file is built, it contains all the data required to render a mesh, in binary format. Opening the file in a hex editor, it will look like this.
The data is written in a specific order and I’ve highlighted the different sets of data in different colors.
Because I know how the data is arranged, I can easily extract and assign the data during runtime from a single block of memory. All I need is an offset which tells me where I am in the memory block to know what data I am pointing to.
If you, the reader, are still not convinced of the merits of binary files, let me throw some numbers at you.
I added some new controls to the move the camera around in the scene. You can move the camera using the following controls: