Can anybody here explain matrices to a 15 year old? I have done kramer’s rule in math but thats about it. The way my computer graphics teacher explained glPushMatrix() and glPopMatrix() to me was that any rotations or translations done between them only affect whats drawn between them. However, now I’m running into lots of problems when drawing my terrain in my game. Like when I scroll the mouse wheel and it changes the camera’s y position, it also changes the terrain’s position. Does anybody have any ideas on what might be causing this? I push and pop the matrix before I draw the terrain.
What exactly is this “rotation matrix”? Can anybody put it into terms I can understand? Thanks
Matrices represent a linear mapping of a system of equations. In other words any system of equations returning distinct results can produce a matrix of the same rank.
Of course when you change the camera position the land scape will change to reflect it.
Remember OpenGL does not move the camera, you move the world around it to look like camera is moving.
You must keep this in mind this when drawing your world.
Originally posted by 31337:
[b]Can anybody here explain matrices to a 15 year old? I have done kramer’s rule in math but thats about it. The way my computer graphics teacher explained glPushMatrix() and glPopMatrix() to me was that any rotations or translations done between them only affect whats drawn between them. However, now I’m running into lots of problems when drawing my terrain in my game. Like when I scroll the mouse wheel and it changes the camera’s y position, it also changes the terrain’s position. Does anybody have any ideas on what might be causing this? I push and pop the matrix before I draw the terrain.
What exactly is this “rotation matrix”? Can anybody put it into terms I can understand? Thanks[/b]
Arnt the matrix setting up OpenGl? And OpenGl uses them. You don’t need to know a lot about them. I know that when you want to rotate something a “rotation matix is mulitpled with the transformation matrix” or the modal matix. Like glRotatef(). The rendering is created though those matrixs. But yer how that happen I have know idear.
I do not know the insights of opengl as I didn’t develop it. But my bet is that every vertex (being in Eucledian space) is multiplied by a transformation matrix that is generated by glRotatef, Translatef etc.
When you reset the matrix it simply makes an identity matrix.
Same thing is done for camera (perspective, orthographic, paraperspective) projections in projective and affine spaces. Basically everything in geometry (hence OpenGL) is driven by matrices.
All Opengl basically does is rasterize(draw) primitives(like tris etc.) which are defined by points.In order to define a point of course you need a coordinate system.Say our initial coord. system(with the identity modelview matrix) where we have defined a quad looks like this:
^

 x–x
  
 x–x

–±>

Now say we load a rotation matrix instead of an identity and then draw the same quad.The quad vertices’ coords. will be the same but they’ll be multiplied by the modelview(rotation) matrix (among others,more on that later) which will cause a rotation of the coord. system.Something like that:
^ x
\ /
\ x/ x /
\ \ / /
\ x/ /
\ /
\ /
/
/\
(I know it sucks but it’s the best I can do with ascii art)
Now when viewed relatively to the new coordinate systm the quad is exactly the same as in the first figuer but when viewed relatively to the initial coord. system the quad has been rotated.It’s in 2D here due to technical limitiation but the same goes for 3d.
The modelviewm matrix maps vertices from world space to object space.As they go down the rendering pipeline vertices are mapped to clip space and device space by the projection and viewport matrices.
Read the initial chapters of the Red book(the online old version will do fine) and so a google search (www.google.com).There’s nothing hard about matrices.
[This message has been edited by zen (edited 11232002).]