Wednesday, October 22, 2008
CONSOLE DEVELOPMENT WEEK 3
This is Exercise 4 of chapter 13 which evaluates the equation 3x-5y using an x value of 6 and a y value of 2.
.text
.globl main
main: ori $8, $0, 6 #x value
ori $9, $0, 2 #y value
addu $10, $8, $0 #copy x value to register 10
addu $8, $10, $8 #addition method of 3x
addu $8, $10, $8 ori $10, $0, 0 #clear register 10
addu $10, $9, $0 #copy y value to register 10
addu $9, $10, $9 #addition method of 5y
addu $9, $10, $9
addu $9, $10, $9
addu $9, $10, $9
subu $10, $8, $9 #subtract 5y(stored in $9) from 3x(stored in $8)
Chapter 15 caused afew problems as the tutorial is taught using a program called SPIM where I have been using MARS, which has a better graphical interface and some additional extras. But the memory allocation is slightly different and only in the last few minutes has been explained to me so the exercises for chapter 15 have not been completed this is a job for today..... part 2 coming later today.
Tuesday, October 21, 2008
INTRO TO 3D GRAPHICS PROGRAMMING so far
Week One
This week we concentrated on using GDI in C++ on Visual Studio 2008. We had a tutorial to work through off MSDN that was actually written for, I believe, VS 2005. There were a few things different naming conventions and placement of some sections of code but nothing to difficult. This tutorial was to basically draw a line in a window application. The code is very similar to that of C#, which I spent a lot of time working with last year on the course and so things like the update and draw methods were there but not as obvious as they are in C#.
Here is the final piece the final product at the end of the tutorial:

I have not delved much further into this at the moment as there is really no need at this stage and we will only be using GDI to draw each pixel using the data from our objects later on.
Week 2
This week was all about vectors. After doing the Computational Maths module from last year this was all fairly easy stuff, actually implement a class in C++ was another matter. This was our task for this week; implement a vector class and test that it works using a console window to display the values of the vector. We were given the help of a header file that included all the methods and variables needed to get this class running.
There were a few things that confused me with actually setting up a copy constructor. All the books I looked in just said it would come in handy but not exactly what it was doing. After talking to Adam he explained that it is just there to create a copy of the vector being created. Also if you do not add a copy constructor yourself C++ adds one in for you anyway.
The rest of the code was really nice and easy but I think was my downfall as made me a bit too cocky for week three's work.....
Week 3
This week was all about Matrices including the transforms of a matrix. The task this week was to implement a Matrix class alongside the Vector class from last week. I underestimated this work thinking that it was very simple, I soon learnt it was not going to be when I had my brain melted a little by the inclusion of a 4-D matrix for the transforms in a 3-D environment. Writing the code also melted my brain a bit more. Still need to put the finishing touches to this class and so will get back to you on how this went along with Week 4's tasks. The inclusion of the 4-D matrix meant that the Vector class had to be updated to include a fourth value, w, to make the calculations possible for transforming the values. This can be seen in the image above for the constructors of the Vector class and also some of the calculations on vectors below:
Notice on the cross product method the w value is 1.0f rather than doing a calculation. This is because the cross product only makes sense in 3-D and so the default value is entered for the w value.