Friday, February 22, 2013

Graphics Programming 5(Second Half)&6

For assignment5, I didn't do the sorting, instead I added a effectmanager and material manager to manage those things. I linked all the materials to the effect that it cares about. And did the same with the entities and materials. It adds a few overhead on load, but reduces the performance hit in every loop. Anyway, I thought it was the right thing to do.

Here is the screenshot of the PIX:

As for assignment 6, I changed the Maya exporter to export the file format exactly the same as I did before. So that I can use the parser that I wrote before. Here is the screen shot of the mesh.

File parsing in the mesh builder did took me sometime (not the parsing part, since it's exactly the same as before), I spent a few hours trying to figure out how to debug in the MeshBuilder. Turns out I was doing it the right way all the time, except there is a space in the file directory that i passed to the command, which the console doesn't recognize of course. Once i was able to debug, it took me a few minutes to solve the issue (again, some stupid mistakes).

The binary files is the easy part, in order to get every mesh info in three load, I create a new struct for the extra information I need (vertex number and index number), something like this:


//load binary file
//load vertex and index number
myFile.read((char*)&m_info, sizeof(VertexFormat::info));
m_vertexData = new VertexFormat::data[m_info.vertexNumber];
m_indexData = new unsigned int[m_info.indexNumber];
myFile.read((char*)m_vertexData, sizeof(VertexFormat::data) * m_info.vertexNumber);
myFile.read((char*)m_indexData, sizeof(unsigned int) * m_info.indexNumber);

Anyway, i'm able to load any shape from Maya into my renderer with my own file format, which is kind of exciting.

Here is the screen shot of scene:



Control:
To control the point light:
use "I" - up, "K" - down, "J" - left, "L" - right, "U" - backward, "O" - forward;
To control the camera: Arrow Keys
To control the box: WASD.

Link to the code:
Graphic 06








No comments:

Post a Comment