Alterscape
Junior Member
Offline
Posts: 64
NY
Re: explain (?) MATRIX STACK.
Reply #3 - Oct 2nd , 2005, 3:56pm
One really useful reference is the OpenGL redbook. If you go to www.opengl.org and look around, you can find an older version available as a PDF. For what you want to do in P5, this is probably more than sufficient, and if you want to do more, the $50 the newed release costs is worth it, from what I've heard. The matrix stack is, well.. if you know linear algebra, you know that geometry can be transformed by matrix multiplication. OpenGL uses this so, for example, you can define a mesh relative to the origin (0,0,0) then transform it to somewhere other than (0,0,0) and draw it. In practice, it works like this: start out with the default matrix, with (0,0,0) being the origin in world-space push the matrix to the stack transform where you want to be (this changes your matrix, so now 0,0,0 is the origin in object-space, but isn't necessarily at the origin in world-space) draw some stuff relative to the new origin pop the matrix off the stack (this puts you back with (0,0,0) as the origin in world-space. The nice thing about the matrix stack is that you don't have to keep track of where you are in the world to get back to the origin, or any other previous level of transform. This is important because, if you look at the 3d functions in P5 (or in opengl itself, for that matter) you can only do relative transforms/rotations. So you can move +5,+3,-1 from your current location, but you can't, say, arbitrarily jump to world-space coord +5,+3,-1. But since the bottom matrix on the stack is always the default world-space matrix, you can just pop matricies until you're back at the lowest level, then start moving again from there. Does that make any sense? IANARGP (I am not a real GL programmer) but that's how I think of it... I hope this is helpful. If you want more help, you should probably ask more specific questions in the 3D/OpenGL forum