A downloadable project

DOWNLOAD FILES 

This week we are converting our human-readable mesh files into binary files. Instead of loading mesh data from lua files, we are now initializing our mesh with data loaded from binary files. 

This is how I am extracting the binary file:

When creating a mesh, we are required to store 4 pieces of important data. I have stored them in the following order: Index Count, Index Array, Vertex Count, and Vertex Array. With this structure, it is crucial to read the data out in the same way. Below is the binary file representation of a plane.

  • Green: VertexCount (uint16_t)
  • Pink: VertexData (3 floats per Vertex Position * vertex count)
  • Yellow: Index Count (uint16_t)
  • Red: Index Data (uint16_t * index count)

To test the advantages of binary files I created a helix with 10,000 vertices. These are their stats:

Lua:

File size: 1690 KB

Binary: 

File size: 781 KB

As you can see, the binary file loads data significantly faster than Lua and is 46% the file size. A big contributor to the file size difference is the verbose human-readable characters that are being stored, but we should still keep the Lua files so that they can be easily adjusted and used by developers. We just want the efficiency at runtime and for the executable part of our game. 

For this implementation in D3D and OpenGL there are no differences. They can both read the same file, but you will need to eat the cost of flipping the mesh during runtime load for each mesh. 

Interesting loading binary data bug:

Published 28 days ago
StatusReleased
CategoryOther
AuthorChai

Download

Download
Chai_Assignment8.zip 912 kB

Leave a comment

Log in with itch.io to leave a comment.