Game Engineering II Assignment 6
We talked about using human-readable files to replace the static mesh data written in the source files. I have used this method to read the mesh data since I made the cMesh class. Putting changeable mesh data inside the source file is a temporary and bad solution. Whenever we want to change the mesh data, we must compile the whole game, making the development inefficient and impossible to let people besides engineers change the meshes. Putting the changeable mesh data in a file that can be read or parsed by the program is much better because people can use tools to generate the meshes and see the changes quickly without recompiling the game. And it makes compiling much faster because we don't have to compile the meshes every time.
This is one of my mesh files:
{
"vertex": [
0, 0, 0,
0.5, 0.5, 0,
-0.5, 0.5, 0,
-0.5, -0.5, 0,
0.5, -0.5, 0
],
"color": [
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0
],
"index": [
0, 1, 2,
0, 3, 4
]
}
I assume people with basic graphics knowledge generate all the mesh files. Hence, they understand what vertex, color, and index stand for. I added color to the mesh because we may use them one day. Of course, I can turn the vertex into an array of three pairs: x, y, and z, but I double if necessary because a man who doesn't know a vertex list looks like he won't open this.
There is one thing I did that is different from the details part. I made a parser in the MeshBuilder project that turns the JSON files into binary files that can be imported quickly by the game engine. The reason why I did this is simple: JSON files are huge and take a lot of time to parse. We only need them for easier development, and the actual game needs a faster loading speed that can be provided using much smaller binary files and C-style file operations.
How to control:
WASD to move the object1. QE to scale the object1,
Left Right Arrow Key to rotate camera. Up Down Arrow Key to move camera back and forward.
Enter to slow down the time.
Click here to download the game.