A downloadable project

DOWNLOAD FILES 

This week we are using Lua to load mesh data into our game. Instead of hard coding it within our game object to be passed into graphics. We are now just passing the file mesh location to be parsed through and stored within our cMesh class. The goal of that file is to be “human readable.” Basically structured in a way where a human can easily understand the structure and add new data to it. 

Controls: 

  • Camera: WASD
  • Cube: Arrow Keys
  • Space: replace shader
  • Enter: hide mesh

Lua File Format:

Human readable data files are very beneficial in game development. Debugging is made easier since the user theoretically knows what the expected output would be. You wouldn’t even need to be a programmer to use these files, an artist or designer could change some values within the file without ever touching the code of the program. Below is the mesh file format I designed to be human readable:

I am using 4 tables:

  • 1 key value, storing the amount of vertices that will be loaded.
  • 1 multi dimensional array, storing position data of each vertex.
  • Another key value, storing the amount of indices.
  • 1 basic array, storing index data 

The order does matter in this case. I am using the value before the array to initialize a new array. Once I have that empty array size verticesCount or indexCount, I can then loop through and fill the array. 

An issue I ran into when trying to read the lua data was, “error: malformed number near '0.0f”. I ended up realizing that lua since lua is dynamically typed it just get confused by the float specification at the end. Removing all the ‘f’s allowed me to properly open the file. I probably shouldn’t have copied my data over without thinking about that. 

Mesh Builder:

We added a new project into our solution that “builds” the mesh file. Right now, it just copies over our lua file into our solutions build folder. Later, it will be converting our file into binary. For this work, we had to set up dependencies properly, which I did not and struggled to figure out what was happening, but eventually I figures out I had to set up an explicit dependency in our Asset Builder project (BuildMyGameAssets). 

Debugging Mesh Builder:

Small Note:

To test my systems and see how easy it was to make load new meshes, I made a 3D model of a cube instead of the normal squares. I also implemented the shader swap and hiding from previous weeks. 

Download

Download
Chai_Assignment6.zip 443 kB

Leave a comment

Log in with itch.io to leave a comment.