Вы находитесь на странице: 1из 5

Assignment 10

This assignment deals with building our meshes into binary files. This is done because we want our mesh
to load as fast as possible at runtime.
1. Game ControlsThe arrow keys to set the direction of the game.
W,A,S,D is used to move the camera.
Q,E is used to zoom the camera in and out.
2. Below is the screenshot of the game when it is initially loaded

The green head here represents the head of the snake, and the red spheres represent its body.
The snake is moving towards the right hence it has advanced over to the right of the screen.
3. Binary mesh file built by my MeshBuilder- Below is the screenshot of the binary mesh file for
the snake head-

4. Order of the four things in the binary filea. Vertex Count


b. Vertex Array
c. Index Count
d. Index Array
I chose this order because I wanted to process all the vertices first and then head on to the
indices. Now Vertex Count has to appear before Vertex Array. This is because we need the
number of vertices to advance the pointer by that amount . Similarly Index count has to come
before Index Array.

5. Below is the hex editor screenshot of floor.mesh

This object is not rendered in the game right now but it is being built as one of my assets. (This
will be added in the game later). Now, the red circle represents the vertex count. The yellow
highlight represents the vertex array . The blue circle marks the index count and the green oval
has the index array.
6. Two advantages of binary filesa. Faster load times.
b. Less memory consumption than a traditional text file.
We use human readable files for storing the data. This is because this helps us debug and during
debug time we need to make our job as simple as possible. This will mean lesser performance
than using a binary file, but the debugging can be done much more easily this way.
Now at runtime we need to load and run the game as fast as possible. Hence loading the
precompiled binary file will ensure that the system can interpret the data as fast as possible.

7. The binary mesh files will be the same for different platforms. This is because logically, the same
mesh needs to be drawn for both the platforms. Now since we are storing the 4 components for
the mesh as discussed above, it makes sense to write the same binary mesh for both the
platforms. Now the data once read from these files can be used by different APIs. However the
binary data needs to remain same and this helps us also compare the files generated if incase
there is an error. Now things such as winding order can be adjusted, once the data is read for
that particular platform.

8. Below is the screenshot of my Binary mesh reader method.

As we can see I am extracting the data in the same order as when I entered the data into the
file. All_data is a pointer for uint8_t which helps in easy pointer arithmetic. Now the simplest
way to add pointers was to add the offset of the previous item to the length of the previous
item. Hence this way we dont have to worry about skipping any data items.
9. The really complex mesh which I used in this project was the head of a snake. I imported this
mesh as a free asset.
a. Size of the human readable mesh- 672 KB
b. Size of the same mesh in binary 170 KB
c. The time needed to process the human readable file 0.5762 seconds
d. The time needed to process the same binary file 0.08 seconds
e. Hence there is a huge difference in performance of the two.

10. Below is the code which binds my effect in a platform independent way-

The code is same for both platforms.

Вам также может понравиться