Skip navigation

File Link(.exe)


Click Me

Objective


The assignment 07 wants me to custom my own mesh format as a lua file and to make the project to generate binary version of mesh data in the building process. Then, we should be able to read the binary mesh file in run-time and display it as before.

The assignment 08 basically asked me to add texture to the mesh in run-time. We need to build the images to the target file format(“.dds”) with texture builder, load them in game and add the textures to the mesh according to the texcoords of vertices of the mesh.

My Mesh File Format  


I have customed my personal mesh file format, which looks like this:

dataformat

The comments explain the details about this format. the format has three main parts: First one is the metadata, which can tell some basic information about this file such as name and numbers of vertex and triangle. The second parts is vertices, which contains the list of all vertices of this mesh. The last part is triangles, which has the triangle list of this mesh.

Add Texture to the game world!


 

In order to add texture on the mesh, there are several steps I did. First of all, I make the engine convert all of the image files to dds file during the building process with TextureBuilder, then I add lines in the material to indicate the texture file path and the name of the sampler. The next step is to add texture coordinates for each vertex of the mesh, which will tell the shader how the texture “pin” on the mesh. At last I ask DirectX to pass the texcoords and textures to the GPU and add  codes to fragment shader to render the texture on the mesh.

This is what the game looks like now and the screenshot in PIX.

 

screen game

scrren pix

Time estimation


Reading and searching — 3 h
Coding / Debugging — 6 h
Writing blog — 0.5 h
Total — 9.5 h

Leave a Reply