Game Engineering II Assignment 3

Last week, Tony talked about how to make the data structure of the mesh class a more efficient way, which is using indices. Though I have already implemented indices in assignment 2, I generated the old vertex arrays using indices array to meet the requirements.

I spent most of the time moving platform-specific codes to a class called cRender and a namespace called Buffer. The cRender class has everything about platform-specific rendering codes and variables like m_renderTargetView. The Buffer contains functions that take care of buffers. Initially, I made the Buffer a class and discovered that the class doesn't contain any member variable. As a result, the best way to deal with this situation is to make it a function collection.

After that, I replaced the Initializing, RenderFrame, and Cleaning with indices-based codes. There is nothing to discuss because nobody will make a mistake when following instructions.

The effects initialization requires the paths to vertex shader and fragment shader. That's because the cEffect class is in charge of shaders, so the only thing necessary to specify is where to find its shaders.

The mesh initialization requires nothing in the initialization function because it reads the mesh vertex and indices from the file when declaring it. I believe it makes more sense because we may need to transform the mesh. We can import the mesh when declaring and then modify the mesh when initializing if we want.

The cEffect class takes 16 bytes in OpenGL and 48 bytes in Direct3D. The size of cEffect in OpenGL differs from Direct3D because it has a cRenderState member variable and a GLuint that only exits in OpenGL. The cRenderState class contains three state pointers in Direct3D. The different variables declared in other platforms make the sizes identical. I can't think of any smart way to make it smaller. Surely, you can move some member variables out of the class and pass them into the required functions. But that is stupid, and I won't even think about it.

The cMesh class takes 32 bytes in OpenGL and 48 bytes in Direct3D. The reason why it has different sizes is similar to the cEffect class. In OpenGL, cEffect has four GLuint member variables. Still, it has three pointers pointing to one vertex format and two buffers in Direct3D. Again, there is nothing smart I can think of to decrease its size.

Controls:

Press Enter to slow the time by 66% and release it to return to the normal rate. Press ESC to exit the game.


Download the game here.

Oscar Zuo

U1418006

You should also read:

Game Engineering II Engine System Wirte-Up

I made a physics system using the GJK(Gilbert–Johnson–Keerthi distance algorithm) and EPA(Expanding Polytope Algorithm) algorithms. The system is capable of detecting collisions between…