#### Archived

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.

## 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 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 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!!
bye!
Andrea

##### Share on other sites
uoops solved the problem! I just was wrong in handling arrays!
Thanx 4 all!
AndreaG

##### 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]

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633363
• Total Posts
3011514
• ### Who's Online (See full list)

There are no registered users currently online

×