Jump to content
  • Advertisement


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


problem with coordinates

This topic is 5646 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 all! First of all Congratulations for the site, i''ve found it very useufl! I have a little problem, i''m not very experienced with opengl, so maybe its stupid. I am drawing a cube as descripted in nehe tutorials, i do the easy steps: glLoadIdentity(); glTranslatef(..); glRotatef(..); and its ok. I apply a translation and a rotation to the cube, so that the face that is at right comes to the front. It works, the cube is drawed correctly. Now, having defined the transformation matrix, I draw the cube with glVertex, but i need to know the TARGET coordinates of such points. In other words, i want to know witch face is IN FRONT in the cube, so if right face comes in front after a rotation of 90 degrees, i simply need to check Z coords of the vertexes. Is there a way to obtain target coords of the cube AFTER it has been rotated and translated? I tried to have them manually by multiplying the starting coords of each vertex for the GL_MODELVIEW_MATRIX matrix, but the result isnt what i expected (the Z coords of the right face arent equal, but by the drawing i see the righ face in front!) Can someone help me? WHat am i missing? Thanx! Bye! Andrea

Share this post

Link to post
Share on other sites
hmm i can''t actually said what went wrong or what you could have forgotten. but here is the way i would do it:

first of all do your translations, rotations and so on
then extract the modelview matrix
and then multiply your verts by hand

just take a look at the opengl documentation it''s something with glGetMatrix or so i think (i never had to that and so i am not sure)

hope that helps, otherwise post a piece of code how you do your calculations

Share this post

Link to post
Share on other sites
uhm so I think my calculations are wrong.
Thats what i do:
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
so i have the transformation matrix which moves the face of hte cube from right to front, then i get the starting coords of every vertex of right face (x, y, z)
and i do the following:

|a b c d| |x|
|e f g h| x |y|
|i l m n| |z|
|0 0 0 1| |1|

resulting in my x'', y'', z'' that i obtain with:
x'' = ax + by + cz + d1
y'' = ex + fy + gz + h1
and so on
What do you think? is this correct?
Thanx a lot!!

Share this post

Link to post
Share on other sites
Seems to me if you want to know if the face is facing you, apply the modelview matrix to the normal of the face. Then check which way the Z is. You'd only have to do this once per face instead of once per vertex.

But then again, you might have other uses in mind for those vertices...

No wait.... I think you have to do that with just the rotations, not the translations... hmmmm...

[edited by - 5010 on June 4, 2003 5:08:38 PM]

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!