Jump to content
  • Advertisement


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


Matrix Stack Coords -> World Coords

This topic is 5942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m rendering some points on top of a few matrix transformations, how do i get the world coordinates for these points? duckbob

Share this post

Link to post
Share on other sites
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
A quick test shows this works fine, IF you undo your camera transformation.

(Since it''s giving you coordinates already transformed by for camera, if you want world space you have to undo that.)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!