top of page

BINARY FILES

Controls: Esc - To quit game

Arrow Keys to give move direction to the sphere

WASD to change the rotation-axis of the cube

Move the camera

OU(Z-axis)

IK(Y-axis)

JL(X-axis)

Rotate the camera

YR(Z-axis)

TG(Y-axis)

FH(X-axis)

C/V to traverse cameras in the camera vector

 

 

I have five things in my binary file:

  1. Type of the index array (uint32_t) (Marked by Red)

  2. Vertex Count (uint32_t) (Marked by Green)

  3. Index Count (uint32_t) (Marked by Cyan)

  4. Vertex Array (Vertex Struct)

  5. Index Array (uint16_t/uint32_t) depending on the type. (Marked by Magenta)

This order made sense to me because I read all counts and type before reading actual data related to it. I made the type for storing the type of index array bigger to have the file auto aligned.

The binary files have the following advantages:

  1. They are smaller in size than normal text files as we pack in the float data.

  2. They load faster which is more helpful and necessary during run time.

Human readable files are easier to debug than binary files. We can easily spot errors by looking at them.

The binary files can be same or different depending how we configure OpenGL’s and Direct3D ‘s winding order. For the purposes of this class they will always be different as OpenGL takes a right hand winding order whereas Direct3D takes a left hand winding order. Apart from the index array being revered the files will contain the same data for other things.

 

To quantify the advantages of the binary file over the mesh file I used helix with 80,040 vertices and 120,108 indices.

The size of this file in my human readable format is 16,199,602 bytes. The size of this file in my binary format is 1,761,084 bytes.

The time taken to build a human readable helix mesh is 846 milliseconds.

The time taken to build a binary helix mesh is 893 microseconds.

 

The objective of this assignment was to make binary mesh files using the mesh builder for faster loading at run time. I found the optional requirements interesting and it took more time to get them right than the actual assignment which was fun. JP helped me by guiding me how to do different type of indexing optimally. I had done a mess with templating it. For now, I do not see any possible point to aligning the binary file as data is already aligned. (I checked using the alignof and mod operator). I made the type information larger than necessary to preserve the alignment. I also wrote a gameobject builder which for now just copies the text gameobject files(.txtgobj) from AuthoredAssetDir to BuiltAssetDir like we did for the old mesh builder. Then a lua loader loads those files at runtime. I am going to change this as per the effects file loading (making .bingobj files) during next assignment or after the assignment when time permits. So, when I do that I only have game object file paths in my AssetsToBuild.lua and everything else gets called through it.

bottom of page