I have a cube and do some transformations. I need to know the coordinates of the vertices so i use the “glGetFloatv (GL_MODELVIEW_MATRIX, matrix1)” where “matrix1” is a matrix with 16 positions of type GLfloat. My problem is that in “matrix1” i only see 5 values changing (those in positions 5,6,9,10,12) while i think there should be more because all the vertices change positions. Here is the code:
Sorry, i am using a cube but in my mind a had a square so i thought that every column of “matrix1” is a vertex. So how can i take a 4x8 matrix whose collums are the vertices that i want? And by the way the modelview matrix can only be 4x4?
Please try reading what he linked you to. Matrices are not positions. You don’t render a matrix; you render an object with a matrix. The matrix and the object to be rendered are separate concepts.
I have read this. Let me explain better what i need. Every shape can take the form of a matrix whose columns are the homogeneous coordinates of the shape’s vertices. Now, we have a transformation matrix and the shape matrix. When we multiply them we take a new matrix whose columns are the homogeneous coordinates of the new shape’s vertices. Correct me if i am wrong. What i need is this new matrix and so i thought it would be a 4x8 matrix.
You can view the transformation process that way, but OpenGL doesn’t. Each vertex position is an independent column vector, i.e. you have 8 distinct 4x1 matrices.
If you want to use the transformed vertex positions in your application, the main options are:
[ol]
[li] Write your own matrix multiplication function.
[/li][li] Use a matrix multiplication function from some other library.
[/li][li] Use the utility function gluProject()
[/li][/ol]
Option 3 should only be considered if the number of vertices is small, as it performs multiple transformations for each vertex (model-view, projection, viewport), whereas combining the transformations into a single matrix is more efficient.