Wednesday, January 23, 2013

Game Graphics Assignment 2

This assignment i completely reworked the structure of the code. renderer.cpp has about 50 lines of code now. i made a class for the camera, scene and geometry. I hope later assignments have us using multiple pieces of geometry because my code can handle any number of geometry.

I had to change cMainWindow.cpp and .h to make the WaitForShutdown function not const. I needed to do this for handling input, which changes the position of the camera and box, therefore they cannot be called from const functions. So now the Update function is not const, and there is a const Draw function that is called at the end of the Update. I could change it so the window calls the update then the draw, but eh.

I spent a lot of time reworking the code, but it was broken for a fair amount of time. I finally realized i was multiplying the matrix and the position in the wrong order in the vertex shader. so i was doing
mul(matrix, position) instead of mul(position, matrix).
once i fixed that the whole thing worked. Although i had a memory leek because i forget to release the vertex declaration, but found and fixed that too.

Everything should be working
Link to Code

To move the box you use the numpad
Move Left: numpad 4
Move Right: numpad 6
Move Up: numpad 8
Move Down: numpad 2
Move Rotate Clockwise: numpad 7
Move Rotate Counter-clockwise:  numpad 9

to move the camera use wasd

Move Left: a
Move Right: d
Move Up: w
Move Down: s

pictures:





No comments:

Post a Comment