PDA

View Full Version : How to compute for Object Coordinates?



stargazer
06-23-2005, 09:04 PM
After a series of mouse rotation, translation & scaling then selecting point using GL_FEEDBACKI got the window coordinate and with gluUnProject the computed coordinate.

My problem is how to programmatically compute for selected Object coordinates given the Window coordinate with the following parameters without affecting the current view:

glTranslated(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);

What I intend to do is to verify the selected points INDEX to the original array of vertices in which I lost due to the different ID returned by GL_FEEDBACK.

Please help. Thanks.

06-27-2005, 09:08 PM
?

use glPushMatrix to save current matrix...

i'm confused. could you elucidate?

stargazer
06-30-2005, 04:25 PM
Thanks for your concern.

On my test it seems the return coordinates of gluUnProject were okay only if the view orientation (birds eye view) is:

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);

Here's the coordinates:
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);

Here's the coordinates:
gluUnProject Coords: objx = -0.338066 objy = -0.303501 objz = -0.625457

These two different outputs of gluUnProject were actually the same selected point returned by glRenderMode(GL_FEEDBACK) which keeps on changing when I change the view orientation.

Is there a way to compute for Object coordinates of the selected point/s in a Birds eye view way whatver the orientation of the view is?

I'm new to OpenGL & stuck please help.

Thanks!

06-30-2005, 04:53 PM
Is there a way to compute for Object coordinates of the selected point/s in a Birds eye view way whatver the orientation of the view is?sure, and it's easy too. just push the current modelview and projection matrices, load you bird's eye view matrices, do the feedback, then pop the matrix stack back to the originals.

something like this...

//
// set your bird's eye view...
//
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(...);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

//
// do feedback stuff...
//

//
// when all done, pop your matrices
//
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

stargazer
06-30-2005, 10:17 PM
This is how it goes, I need to perform FEEDBACK right after the the Region of Interest was defined in which the current view is already disoriented meaning not in Birds eyeview. Then I will check for all points returned by FEEDBACK that will fall inside the region and use gluUnProject to get the Object Coordinates.

Based on your advice, is it possible to render selected points only in Birds eyeview then perform FEEDBACK again & then return to current view?

Is there any formula to compute for Obj coords based on the values of glTranslatef, glRotatef, glScalef?

You see I already got the selection right, the only problem is how can I test for its object coordinates based on Birds eyeview orientation.

I'm sorry for asking too many questions...

06-30-2005, 11:52 PM
ok, lets start over.

i'm having trouble seeing what it is you're trying to accomplish. can you explain what you are doing at the highest level possible. i don't mean how you want to do it, but exactly what you are trying to do. in other words, describe the high level task, not the implementation details.

if you're just starting out in graphics/opengl, it's far more important to preface your questions with the objective rather than how you are going about things. chances are that someone more experienced will see an easier or more efficient way of going about it. just some friendly advice from someone who has learned things the hard way :)

stargazer
07-01-2005, 02:12 AM
Thank you for having patience to what I'm trying to achieve.

I'm dealing with points that is color-coded based on Z coordinates. These points are numbering from a million to about 30 millions so I sorted it out for better color visualization.

The main objective is simple just to change the color of the selected points to WHITE in which the user thinks a garbage points.

I prepared two sets of data array for these, one for the XYZ coordinates and one for FLAG values. The purpose of this FLAG is for me to update its value to 1(one WHITE color) if garbage point or remain 0(zero) if normal point.

Upon opening of the data, the default orientation is TOP view or Birds eye-view because I observed it returns the Object coordinates properly thru gluUnProject. Any view orientations however is not a problem as long as the view contains all points.

The problem begins when only part is being displayed in which I lost track of the INDEX because FEEDBACK returns 0(zero) ID of the lowest Z coordinates on the view. For example, if there are only 10 out of 100 points displayed, the returned ID by FEEDBACK of the lowest Z-coords from that 10 points will be zero on which actually incorrect as compared to 100 points.

I hope you get what I mean.

07-01-2005, 09:08 AM
ok, let me make sure i understand this right.

the user is given some rendered points on the screen to select from. you want to detect which points the user has selected, one at a time, and peform an operation on the objects they represent (flip a bit flag in this case). close?

if i'm close, i think all you really need here is GL_SELECT mode, rather than GL_FEEDBACK. the objective seems to be one of selection determination, exactly what select mode was designed for. i've used opengl selection for picking so i can personally vouch for its effectiveness.

feedback can come in handy for certain things like retrieving vertex information of opengl generated nurbs surfaces and such. i don't quite see how it would figure into your scenario as described. perhaps i missed it.

anyways, have a look at selection and see if that's more in tune with your objective. if you have any questions, or if you think i'm totally wrong about everything, feel free to say so :)

there is some info on selection/picking here and there...

http://fly.cc.fer.hr/~unreal/theredbook/chapter12.html
http://www.opengl.org/resources/tutorials/sig99/advanced99/notes/node35.html
http://www.lighthouse3d.com/opengl/picking/index.php3?openglway2

stargazer
07-01-2005, 03:21 PM
thanks for the links...