Wednesday 11 November 2009

Intro to 3D Programming - So far...

Over the course of this module we are basically extended one C++ program over and over to eventually get it to display a 3D graphic on stream, complete with lighting and textures. So far I have managed to complete my vector class, allowing it to implement vector addition, subtraction, multiplication, division, dot product and cross product successfully using a header file given to us.
I also have a working Matrix class, using a template of a header file and extending it to work fully. This class can now add and subtract matrices, multiply two matrices or one matrix with a float.

The final bit I have working is a Camera class. This was a lot more complicated as we were given nothing to build off of, and so had to implement it all from scratch. The first step was creating a header file, then starting to add x-rotation, y-rotation and z-rotation to the main .cpp file by creating a series of functions. After getting them working seperately, x and y rotations had to be multiplied together using the matrix-matrix multiplication function previously made. This xy-rotation then had to be multiplied to the z-rotation to create a full XYZ-rotation that can be applied to a finished 3D model when the time comes.
There is also a translation implemented, which multiplies a matrix by a vector to produce a vector resultant which will eventually translate the 3D model.
The view matrix is gained by doing the inverse of the translation matrix by the inverse of the rotation matrix. This resultant matrix is multiplied by a projection matrix which is a fixed matrix to get the final projection matrix.

After all this, the next step is to get a cube to load into a blank canvas. I am currently having errors when compiling this so more work is needed here before and screenshots can be shown.

No comments:

Post a Comment