View Full Version : Getting the tranformation of a point

MrPython

12-27-2003, 12:56 AM

This is a ridiculously simple question....

How do I apply the current transformation matrix to a point in model space, and get the resulting point?

If this is impossible to do directly, I suppose I could do it manually, in which case, I need access to the current tranformation matrix. How to I query the current matrix?

I've searched the documentation and can't seem to find an answer to either question.

It's almost inconceivable to me that these functions are not available, since they would be the first two functions I would write if I were designing a 3d graphics system.

Thanks,

Ken

mikael_aronsson

12-27-2003, 02:08 AM

I would guess the reason is that OpenGL is just a rendering engine, nothing more, but multiplying a vertex with a matrix is pretty simple and there are tons of code to do this all over the world.

Also this would mean that you would have to send the vertex to OpenGL have it processed in some way and then get the information back again which might stall the pipeline, this is not a thing that fits the OpenGL pipeline very well.

Mikael

MrPython

12-27-2003, 03:35 AM

Right, I know how to multiply a vector and a matrix. As I mentioned, this would require that I have access to the contents of the current matrix. That is why I asked the second question: how do I get the elements of the current matrix?

Unfortunately, I think you may be right about the pipeline. Still, I think it is quite lame for OpenGL to exclude this functionality. I can think of several reasons why one would want to know the pixel coordinates associated with a vertex, and several reasons to want access to the contents of the matrix. I can't think of any reason not to have this. It would only involve adding a few lines of code to OpenGL.

Yeah, I know, you're gonna say I should submit some code to OpenGL at SourceForge http://www.opengl.org/discussion_boards/ubb/smile.gif but I already have a few community service projects going, and I am not familiar with OpenGL source code.

Thank you

Ken

MrPython

12-27-2003, 05:19 AM

I found the answer:

gluProject() applies a model and projection matrices, and a viewport, to a specified vector.

glGetDouble(GL_MODELVIEW_MATRIX) and glGetDouble(GL_PROJECTION_MATRIX) get

the elements of the current matrices.

Thanks for listening...

Ken

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.