View Full Version : Doing transformations manually

08-02-2004, 03:30 PM
I'm trying to write a routine that transforms individual 3D points. What I want to be able to do is call a bunch of OpenGL's transformation routines, retrieve the transformed projection and modelview matrices with a pair of calls to glGetDoublev(), and then use them to turn local points into absolute universal ones. I understand that this is done by taking the dot-product of [x, y, z, w] and each row of the final transformed matrix, interpreting each of these dot-products as a coordinate of the transformed point.

If what I've said so far is wrong, please stop me...

Anyway, what I'm not completely clear on is how to get that "final transformed matrix" from the independent projection and modelview matrices. My guess is that I perform matrix multiplication between them to find it; is that right? And if it is, what order do I multiply them in?


08-02-2004, 03:35 PM
Not sure what you mean by "absolute universal ones." Do you want something you can't get from gluProject()?

08-02-2004, 03:44 PM
Yes; sorry for the lack of clarity.

What I want, in a nutshell, is to take a series of transformations and express the entire process as one single translation. gluProject() gives you a pair of window coordinates, whereas I want a triple of spatial coordinates (just like I had to begin with, but transformed).

08-03-2004, 12:33 AM
OGL uses transposed matrix. So you have to dot with each of the column, and not each of the row.

You're right with the method, this is how it works. The order is straightforward :

local <-> world <-> camera <-> perspective

in OGL : M = P * V * M (stands for projection / view / model), and then Vh = V * M

What you call "absolute" is called homogenous.