Jump to content
  • Advertisement


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


Object position

This topic is 6011 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

Hi there people! I have a question but I don''t know how to explain... I would like to get a vertex position (I think). FOr example: glLoadIdentity(); glTranslatef(1.0f, 0.0f, 0.0f); glBegin(xxxx); glVertex3f(0.0f, 1.0f, 0.0f); glEnd(); Specifying this simple commands, we know that glVertex3f (in this case) will draw a point at position 2.0f (in X). We can arrive to this conclusion by adding 1.0f (of glTranslatef) + 1.0f (of glVertex3f) = 2.0f. All that we have to do is add what we passed to glTranslatef and glVertexf, and we get the position of the painted object. But a problem will occur if we inform rotations... We cannot prediscover the vertex position if we rotate the object... I would like to know if there is a command to get this values, or a way to do this by hand... Any help will be appreciated! Fernando.

Share this post

Link to post
Share on other sites
I had the same problem yesterday... I needed to find out where exactly my objects where after I rotated/translated them etc., so that I could do my own manual sorting to make blending look right.

What I ended up doing is just not use the glRotate/glTranslate functions. Instead, I made my own, which wasn''t very hard.

Just rotate/translate the objects yourself and you will get the same results, however (probably) slower than glRotate/glTranslate. If you don''t know the trig required (cosine and sin is all), then just look at some of the tutorials on rotation on gamedev.net

I found out can get the current matrix that GL uses after glRotate/translate, though... Then you can just apply that matrix to all your points, and viola, you have their new positions. glGet(something-matrix) is the function you need to get that...

Right now I''m doing it the first way, though, since I know nothing about how you would apply a matrix to a point...

So I have a question of my own...

How do you apply a 4 by 4 matrix to a point? I know NOTHING about matrix math stuff :-( Cuz like I said before, I can get the matrix that GL uses, but I don''t know what to do with it once I have it.

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!