View Full Version : Anyone who has decomposited the MODELVIEW matrix? how?
08-29-2006, 12:48 AM
i want to isolate the from the MODELVIEW matrix, first the MODEL and the VIEW matrix and then, from the MODEL matrix, isolate the ROTATION, the TRASLATION and the SCALING matrices.
Maybe you want to see also this thread:
Any clue will be appreciated.
08-29-2006, 07:38 AM
You can determine rotation, translation and scaling from a matrix. Read some matrix FAQ, basically the translation will be the fourth-row vector, rotations are stored in first three rows (as axis) and the scaling factor can be isolated by computing the length of each axis. This what I guess, as my algebra classes lay a year ago :-/
Hovewer, this is not possible to decompose the MODELVIEW in MODEL and VIEW. This is a similar task of solving the equation of a + b = 100: there are unlimited solutions
08-29-2006, 08:21 AM
In OpenGL, a vertex in object coords is transformed to the eye coords by multiplying GL_MODELVIEW_MATRIX:
Ve = Mv * Mm * Vo
Vo: Vertex in object coords
Mm: Model matrix, to transform object coords to world coords
Mv: View matrix, to transform world coords to eye coords
Ve: Vertex in eye coords
Note that GL_MODELVIEW_MATRIX is combined Model matrix and View matrix because there is no camera(view) in OpenGL. More precisely, the view is always at (0,0,0) and is looking along -Z axis. Therefore, to move a camera, move all objects reverse direction instead.
You may seperate Model and View matrix something like this:
// initialize ModelView matrx
// transform your camera here, glTranslate, glRotate, glScale
// This will transform a vertex from world coords to eye coords
// store view matrix only
glLoadIdentity(); // reset the matrix before any model tramsformations
// transform your vertices here, glTranslate, glRotate, glScale
// This transforms a vertex from object coords to world coords
// store Model matrix only
// reconstruct GL_MODELVIEW matrix before defining any vertex
// Mmv = Mv * Mm
// define any vertex in object coords
glVertex3f(x, y, z);
}You can split each translation, rotation, and scaling matrix in similar way; init matrix -> transform -> get matrix. But, glGetFloatv() may slower than your own matrix computation routine.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.