Sign in to follow this  

Why gluUnProject returns inconsistent Obj Coord?

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

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
My objective is really simple, just change the color of the selected point/s to WHITE. Initially I assigned all points to RED color. I'am maintaining two arrays for this, one for the XYZ coords and the other for the color(RGB).

Share this post


Link to post
Share on other sites
Why do you need the objects coordinates for that? Use selection, and as names, you load the index where you find the point in the array. That way you can directly use the name in the hit record as index into both the vertex and color array to identify the selected point.

For example, for the 42:nd point, push the name 41 (0-based indices, you know), and when you get the hit record back, change the entry with offset 41 in the color array to white.

Share this post


Link to post
Share on other sites

This topic is 4543 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this