View Full Version : transforming fron (x, y, z) to (x, y)
02-21-2000, 09:52 AM
I've done my own code and also used gluUnProject() to get the windows coordinates, but seems as if both my code and gluUnProject() have problems (I'm not getting the right numbers)
I also did some tests with GL_FEEDBACK with GL_2D but this gives even different numbers????
I'm plotting a single point on the screen (window under Windows 9x/NT) and trouble is, I don't know where it's going to be placed.
Has anyone figured out how to do this calculation, preferably without the use of any GL functions?
02-21-2000, 10:44 PM
Hmm dont know exactly what you want to do but this is how I convert xyz to screen xy:
ScreenX = X / Z + ScreenCenterX
ScreenY = Y / Z + ScreenCenterY
Or you could replace those two divides with one by doing:
OneZ = 1/Z
ScreenX = X * OneZ + ScreenCenterX
ScreenY = Y * OneZ + ScreenCenterY
The only problen with what you are saying AndersO, is that the viewpoint have to be located at (0,0,0) and looking along the z-axis. When your viewpoint is placed elsewhere, or looking at another direction, you wont get the right coordinates.
02-22-2000, 02:36 AM
Originally posted by V-man:
[...] but seems as if both my code and gluUnProject() have problems (I'm not getting the right numbers)
So why should I trust your reply to my question on gluUnProject, in the topic I posted???
AT LEAST YOU SHOULD HAVE TOLD ME!! HOPE YOU DO NEXT TIME
02-22-2000, 03:27 AM
Yea.. Forgot about that. And fov must also be accounted for somehow..
No its probably easier (or more accurate) to ask OpenGL where a certain xyz coord will "land on screen".
But that I haven't done. So I'll shut up now!.. http://www.opengl.org/discussion_boards/ubb/smile.gif
02-22-2000, 04:13 AM
You only have to multiply the desired vertex by the eye matrix. You will obtain the screen coordinates in the x,y of the new vertex.
Also, you can multiply the first vertex by the modelview matrix before, if you have changed it.
Hi get a load of my answer, it's going to be where you put it. make a card board model of
3D space, use 3 pieces put together as left-hand 3d space. study it try my figure make your own
glVertex(x,y,z); <--2.0,-4.0,3.3 (-4.0=-Y value of 4.0 on negative real based on local 0.0.0)
Reference 'local origin' best way there is other ways end up with floopy animations or poor ploting accuracy
/ | -4.0 belongs to this real(-y)
[This message has been edited by o9i8 (edited 01-25-2002).]
are u supplying the correct Z value to gluunproject, (ive never had problems with it)
Hey, this thread is almost two years old! http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.