Monday, 3 November 2008
The problem, the overhaul, and the camera...
I did not understand how any of this had anything to do with what i see.
I mean, i have the screen in front of me. i understand that what is being presented to me doesnt really "exist" that its just a representation of numbers displayed so that we puny humans can understand what we're doing, but the leap in logic that leads me from ones and zero's to matrices and verts to...well ones and zero's (as words) i suppose, was completely beyond me.
which leads to my first problem.
My matrix transformations are doing the wrong thing. This whole time i had thaught that our matrix transformations (rotation etc) should be giving out a vertice, after taking one and moving it, in actuality, i now realise, our transformations are there to store a specific transformation for general use.
This of course is a somewhat...devestating realisation, one that came about due to the input of my study partner (who i suspect at this moment is writing a blog post very similar to this) and our friend, who saw us working on it, and then pointed out, quite happily that we had made something that really wasn't useful in any way whatsoever.
This of course, leads me inevitably to the following. over the last week i have rewritten, hacked apart, and (hopefully) fixed all my issues, my solution should now do what it was supposed to do in the first place, my camera class has now, also hopefully, been finished, and (as far as i am aware) i can now load objects correctly.
i also managed to get namespaces to work correctly, which was a small issue that was suddenly swamped by the larger "it fails at doing stuff" issue.
however, due to the recreation of, essentially, my whole programme, my rendering pipeline work isn't complete (as of time of writing), hopefully more work on this may be finished by the next tutorial, however i find it unlikely at this juncture.
Monday, 27 October 2008
Struggling with the Camera...

(My apologies about the small size of the text in this image, i will edit this at a later date)
The View function calls the transform function from the matrix class to compress the 4d matrix into a 4d vector, sending the vector back to the main class (a testing class) to display whatever the vector ends up as as numbers in a console window.
the function itself uses a formula, found at http://gregs-blog.com/, adapted for use in a C++ class. the adaptation is simple enough, the following is an image containing the formula found on gregs blog:
The following is a version of the first part of the above code, that can be used in c++:
cameraM._m[0][0]=(1-cos(thetaX))*v1._x*v1._x+cos(thetaX);
as you can see the modification is only slight, changing the variable theta (i am unsure of how to correctly display the theta symbol in blogger) with thetaX (the angle with which to rotate along the x axis). changing the variable vx to the vector's (v1) X axis variable. and adding the result to the matrix cameraM
Monday, 20 October 2008
the wonderful world of matrice's...
thats right, the fourth dimension is W. yep. thats right. W.
as a matrix is (essentially) a multidimensional array, of X, Y, and Z usually, the fourth dimension should follow on from those, and seeings as theres no more alphabet after Z, we'll start working our way backwards, to W. With this Knowledge firmly in my somewhat bemused hand (mind), i set forth into this strange new dimension, a place where objects are transformed, translated, and translucent...wait...forget that last bit.
i chose to base my Matrix class directly on the framework of my Vectors class, this however did cause some problems, including but not limited to:
- How am i relating static voids to my main. (turns out in the matrix class the "static" part is dropped, and they become voids, which are called in the usual manner of Matrix::add(variables)
- multiplication seeming far more complex (something that i will comparing shortly)
- the Matrix Header issue.
Lets start with the last point shall we, there is a peculiar effect, when adding a file to a solution from outside of the solutions containing folder (ie from my documents rather than my document/visualstudio2008/projects/Vector etc), as when you do add that file, a file of that name is created within the containing folder, but all changes and saves are written to the original file. This causes 2 major problems.
The first is that, while you are updating the original file, the solution is attempting to read from the copy within its containing folder, the one that hasn't changed, thus preventing it from compiling correctly.
the second is that when you've finished your programming session, deep into the long hours of the night, you save, and you backup that solution, the updated file is lost from the backup, causing you to lose what could be hours of work.
however, a lesson learned is the first part of winning the programming war, and from now on i'll make sure i put my new external files into the containing folder before trying to add them.
now then, multiplication. Multiplication with a scalar is, as is typical, very simple, however multiplication of vectors becomes a long and drawn out process. Within this process a simple formula exists, row A X collumn B(as it was explained to me by a peer).
in reality that turned out as the heaving monstrocity shown below
result._m[0][0] = matrix1._m[0][0] * matrix2._m[0][0] + matrix1._m[0][1] * matrix2._m[1][0] + matrix1._m[0][2] * matrix2._m[2][0] + matrix1._m[0][3] * matrix2._m[3][0] ;
result._m[0][1] = matrix1._m[0][0] * matrix2._m[0][1] + matrix1._m[0][1] * matrix2._m[1][1] + matrix1._m[0][2] * matrix2._m[2][1] + matrix1._m[0][3] * matrix2._m[3][1] ;
result._m[0][2] = matrix1._m[0][0] * matrix2._m[0][2] + matrix1._m[0][1] * matrix2._m[1][2] + matrix1._m[0][2] * matrix2._m[2][2] + matrix1._m[0][3] * matrix2._m[3][2] ;
result._m[0][3] = matrix1._m[0][0] * matrix2._m[0][3] + matrix1._m[0][1] * matrix2._m[1][3] + matrix1._m[0][2] * matrix2._m[2][3] + matrix1._m[0][3] * matrix2._m[3][3] ;
result._m[1][0] = matrix1._m[1][0] * matrix2._m[0][0] + matrix1._m[1][1] * matrix2._m[1][0] + matrix1._m[1][2] * matrix2._m[2][0] + matrix1._m[1][3] * matrix2._m[3][0] ;
result._m[1][1] = matrix1._m[1][0] * matrix2._m[0][1] + matrix1._m[1][1] * matrix2._m[1][1] + matrix1._m[1][2] * matrix2._m[2][1] + matrix1._m[1][3] * matrix2._m[3][1] ;
result._m[1][2] = matrix1._m[1][0] * matrix2._m[0][2] + matrix1._m[1][1] * matrix2._m[1][2] + matrix1._m[1][2] * matrix2._m[2][2] + matrix1._m[1][3] * matrix2._m[3][2] ;
result._m[1][3] = matrix1._m[1][0] * matrix2._m[0][3] + matrix1._m[1][1] * matrix2._m[1][3] + matrix1._m[1][2] * matrix2._m[2][3] + matrix1._m[1][3] * matrix2._m[3][3] ;
result._m[2][0] = matrix1._m[2][0] * matrix2._m[0][0] + matrix1._m[2][1] * matrix2._m[2][0] + matrix1._m[2][2] * matrix2._m[2][0] + matrix1._m[2][3] * matrix2._m[3][0] ;
result._m[2][1] = matrix1._m[2][0] * matrix2._m[0][1] + matrix1._m[2][1] * matrix2._m[2][1] + matrix1._m[2][2] * matrix2._m[2][1] + matrix1._m[2][3] * matrix2._m[3][1] ;
result._m[2][2] = matrix1._m[2][0] * matrix2._m[0][2] + matrix1._m[2][1] * matrix2._m[2][2] + matrix1._m[2][2] * matrix2._m[2][2] + matrix1._m[2][3] * matrix2._m[3][2] ;
result._m[2][3] = matrix1._m[2][0] * matrix2._m[0][3] + matrix1._m[2][1] * matrix2._m[2][3] + matrix1._m[2][2] * matrix2._m[2][3] + matrix1._m[2][3] * matrix2._m[3][3] ;
result._m[3][0] = matrix1._m[3][0] * matrix2._m[0][0] + matrix1._m[3][1] * matrix2._m[1][0] + matrix1._m[3][2] * matrix2._m[2][0] + matrix1._m[3][3] * matrix2._m[3][0] ;
result._m[3][1] = matrix1._m[3][0] * matrix2._m[0][1] + matrix1._m[3][1] * matrix2._m[1][1] + matrix1._m[3][2] * matrix2._m[2][1] + matrix1._m[3][3] * matrix2._m[3][1] ;
result._m[3][2] = matrix1._m[3][0] * matrix2._m[0][2] + matrix1._m[3][1] * matrix2._m[1][2] + matrix1._m[3][2] * matrix2._m[2][2] + matrix1._m[3][3] * matrix2._m[3][2] ;
result._m[3][3] = matrix1._m[3][0] * matrix2._m[0][3] + matrix1._m[3][1] * matrix2._m[1][3] + matrix1._m[3][2] * matrix2._m[2][3] + matrix1._m[3][3] * matrix2._m[3][3] ;
yeah, isn't that grand. though to be fair, it follows a simple logic, and parts are easily copied and pasted into the right places.
for more on transformations, check back next time, when my brain has resolidified enough to make a coherent and informative post (the above is due some editing)
Wednesday, 15 October 2008
Friday, 10 October 2008
Technical Difficulties
void OnPaint(HDC hdc)
{
Graphics graphics (hdc);
Pen pen
(Color(255,0,0,255), 5);
SolidBrush
brush(Color(255,0,0,0));
FontFamily
fontFamily(L"Times New Roman");Font
font (&fontFamily,24,FontStyleRegular,
UnitPixel);
PointF
pointF(10.0f,20.0f);
graphics.DrawLine(&pen, 10,
50, 230,
50);
graphics.DrawString(L"Welcome to my blog!", -1, &font,
pointF,
&brush);
}
The resulting screen should resemble the one below
the window that is opened with the effects of the code snippet above inside, is mostly generated by windows visual studio. the only modifications made to the original code were to allow for the use of GDI+ and vector drawing code to work in the window.
One more note, on the use of time, i realise that i did not put as much time into learning about vectors as i should have, and i will put more time into understanding matrice's.
Tuesday, 30 September 2008
The Start of a Wonderful Journey
i am a Computer Games Programming Student at the University of Derby. I am in my Second year, and will be using this blog to showcase my achievements, and my work. I suppose this could be considered an online portfolio.