Why gluUnProject returns inconsistent Obj Coord?
This is what I noticed everytime I change the orientation of the view then issue gluUnProject.
For example:
If:
glTranslatef(0.0, 0.0, 0.0);
glScalef(1.0, 1.0, 1.0);
glRotatef(720, 1.0, 0.0, 0.0);
glRotatef(360, 0.0, 0.0, 1.0);
gluUnProject Coords: objx = -0.488667 objy = 0.025000 objz = -0.499775
When I do rotation, scaling & tranlation for ex:
glTranslatef(0.105000, -0.370000, 0.000000)
glScalef(1.100000, 1.100000, 1.100000)
glRotatef(697.000000, 1.0, 0.0, 0.0);
glRotatef(328.333344, 0.0, 0.0, 1.0);
gluUnProject Coords: objx = -0.338066 objy = -0.303501 objz = -0.625457
Does gluUnProject really behaves this way?
I just followed this article:
http://nehe.gamedev.net/data/articles/article.asp?article=13#2
What's wrong, really? If you change the matrices then of course you get different coordinates out from gluUnProject, what did you expect?
Well I'm expecting that it will return constant value whatever the orientation is. I noticed one thing though, the Birds eye-view orientation is the correct values returned by gluUnProject.
Is there any other way or other OpenGL command that can do this?
Is there any other way or other OpenGL command that can do this?
You better explain exactly what you're trying to achieve.
And if you're expecting gluUnProject to return constant values, you must keep the matrices constant aswell. You cannot expect the values not to change when changing the matrices, cause the output values depends directly on the input matrices.
And if you're expecting gluUnProject to return constant values, you must keep the matrices constant aswell. You cannot expect the values not to change when changing the matrices, cause the output values depends directly on the input matrices.
I'm dealing with GL_POINTS, a million at least and I wanted to create unique ID to every point so that during selection(FEEDBACK), I know which point/s are selected. My 1st idea is to use the Obj coords but unfortunately, gluUnProject returns different value depending on the matrices as you mentioned.
If the current matrices displays all points during selection, I have no problem but if only part of the whole picture is being shown, I cannot keep which point/s are selected.
If the current matrices displays all points during selection, I have no problem but if only part of the whole picture is being shown, I cannot keep which point/s are selected.
I'm still very confused what you're trying to do. You talk about both feedback and selection as if they were the same thing (or so it seems to me), while they are different things in OpenGL. Are you trying to select points, or get back the transformed coordinates from the points, or something else?
gluUnporject maps a screen coordinate into object space coordinates. So sending the same coordinates (in 2d due to screen space) into a dynamic scene will give you different value each time. y? because the actual 3d data is changing. when screen orientation changes in ANY way, the transformation matrix is affected. since unprojecting works on the basis of this matrix, there's no way you can guarantee that you'll get the same values UNLESS the scene never changed.
remember, clicking at the center of the screen when u're facing the front of a 3d building and clicking the same spot on screen when facing the roof of the same building will defienitely give you different coordinates. logical?
remember, clicking at the center of the screen when u're facing the front of a 3d building and clicking the same spot on screen when facing the roof of the same building will defienitely give you different coordinates. logical?
@Brother Bob
Yes I'm using FEEDBACK in order to get the selection and gluUnProject to get the Obj coords.
@CraZeE
Thanks for clearing that out.
Yes I'm using FEEDBACK in order to get the selection and gluUnProject to get the Obj coords.
@CraZeE
Thanks for clearing that out.
Sorry, but still not understanding what you're trying to achieve. Are you drawing the object, and using feedback to get the window coordinates of the points being drawn, and then using gluUnProject to get back the original coordinates, the coordinates you just passed to OpenGL in the first place?
Describe, with as much details as possible, what EXACTLY you want to do with all your points.
Describe, with as much details as possible, what EXACTLY you want to do with all your points.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement