This blog series is a part of the write-up assignments of our Game Engineering II class in the Master of Entertainment Arts & Engineering program at University of Utah.

In this assignment, we are moving our meshes definition out from our source code into separate files and read them at run-time. We are using Lua library here since it’s pretty powerful and flexible, and also relieves us from writing our own parser. However, this is not necessarily the best or most efficient approach and format.

Human-Readable Asset

Our main goal for this new asset file is human-readability instead efficiency or easy to parse. We want this to be as easy to debug, understand, and maintain as possible. One important aspect is that this does not necessarily mean that it’s easy to “create” since we are going to let other software in the asset pipeline take care of creation.

I decided to have a format like what is shown below. I thought about having x = , y = , z = inside position, but then I thought that would just make the file messier, but I have some comments above showing the order of both position and color.

As for index array, I simply use an array that group every three numbers together with line switching and have comments explaining a bit more.



To “build” (right now it’s just copying to the destination folder) our new mesh files, we need to create a new project called MeshBuilder. One thing that can get easily messed up every time we create a new project is project dependency. To hook up our new MeshBuilder project to our asset pipeline, we need to add “explicit dependency” (instead of using reference) to MeshBuilder in BuildMyGameAssets since it requires MeshBuilder project to build first before itself.

Optional Challenges

Now we have separated the meshes data from our source code, we can go crazy with our meshes without having to worry about recompile! For a starter, I made a simple plane and a cube, which is shown below.


Now, going a little bit crazier, I downloaded a low poly deer .obj file (776 vertices, 1508 tris) and wrote a python script that converts it into the format that my engine uses. Because the original scale was too big and the far clipping distance of my camera is too close, I also had to scale the deer down. The result is shown below.



Hold down “Z” to change the plane object into a cube. Use “WASD” to move the camera, “J” and “L” to rotate the camera horizontally. “Arrow keys” to move the white plane object. “E” and “R” to rotate the colorized cube object.

If you go into the data folder, you’ll see the mesh files that are being used. You can swap one of them out with the deer mesh file and see it change in the game.

Windows x86 (OpenGL)
Windows x64 (Direct 3D)