This topic is now archived and is closed to further replies.


Matrix Stack Coords -> World Coords

Recommended Posts

If you are trying to do what I think you are (I'm a newcomer to OpenGL, and indeed 3d graphics programming) then you need glGetFloatv(GL_MODELVIEW, yourArray[16]); which stores the current modelview matrix in the second parameter array. There may well be other ways of doing this more efficiently (and i'll keep reading in case someone tells us) because someone on IRC #openGL mentioned glGetMatrix() which I couldn't fathom out, and isn't in any of my literature. Red herring?

[edited by - sdrhod on July 15, 2002 5:09:28 PM]

Share this post

Link to post
Share on other sites
I''m not trying to return the actual matrix...Say I apply 5 sets of matrix transformations rendering a section of a limb type object, rotate, draw, translate, rotate, draw, translate, rotate, ect... I need to find the actual posistion of the end of that "limb" object...if someone knows how to dirive that from just the matrix returned with glGetFloatv(GL_MODELVIEW, yourArray[16]); that would work, (can anyone tell me?), but i''d prefer if openGL would simply return a point for me, say at the end of the transformations, such as

<--Command would go here, given 0,0,0 coords, would return 0,2,0

that would be the most useful...what i''m trying to do is adjust the trajectory of an object from the end of the limb being fired acording to where the end limb segment currently is.
(someone shooting while falling/getting shot, ect...)

Share this post

Link to post
Share on other sites
I think this should work.

float matrix[16];
float x,y,z;


12,13,14 corespond to these positions on the 4x4 matrix:


Although maybe I should be multiplying the 4x4 matrix by a 1x4 matrix?
(Someone who knows matrices better would know.

Share this post

Link to post
Share on other sites