Discuss Orientation Matrices
Proper Camera and Object Orientation
Although I implemented the spring system with a poorly made camera system, it later became necessary to have a more intuitive way of moving around and watching my work in action from different angles. A lot of trial-and-error has showed me how the MODELVIEW matrix works (It's very easy to assume one knows a bit about matrix transforms and so forth and then to start using OpenGL and find things behave very strangely when first attempted).
To summarize, there's the MODELVIEW matrix which is 4x4. It's really an array of 16 floats, oriented so indices 0-3 are the first column, 4-7 the next column, etc.:
rightX upX outX locationX
rightY upY outY locationY
rightZ upZ outZ locationZ
0 0 0 1
rightX,Y,Z is the vector that points to the right, up is up, and out is forward(other orientations are probably possible that end up looking different, but as long as the operations performed on the matrix are consistent with the layout this'll work). If you're familiar with gluLookAt(), the above matrix can be used with it like so:
And glMultMatrixf() (while in MODELVIEW mode) can take that matrix as an argument to transform an object to the stored coordinates and orientation. So with the proper functions for rotation and movement the matrix above can be used as the basis for a camera system (with gluLookAt()) and storage for object positions and orientations. OpenGL has functions for rotations and translation that presumably would take advantage of 3d cards for carrying out the operations, but I think it may be more costly to push a matrix onto the stack, rotate it, take it out with glGetFloat() (since the stack would not be large enough to accomodate thousands of objects if the task needed it) and repeat than to just do similar things with custom functions on the cpu's time. Also, those custom functions may be made to work as needed when the OpenGL functions are more general and not always useful.
Copyright © 2002-2003 Lucas W