noodles

12-06-2010, 04:30 AM

Hi there, I'm new in this forum and a newbie in OpenGL. Currently I'm developing an app in OpenGL ES on Android platform.

Now I'm going to explain my problem.... I have a 3d scene that change dynamically with the phone's sensors. The sensors produce a modelview matrix and I set it in OpenGL with glLoadMatrix() at every frame. So the scene moves using the sensors.

Now, I need to detect which obj in the 3D scene has been touched by the user. I know this is "picking". Someone has suggested to me to use this way:

"unproject from the (x,y) screen coordinates to a ray in model

space, and work out which object(s) intersect that ray"

First question: What does "model space" mean?

Second question:

I used unproject with screen coordinates and I get their world coordinates, but I don't understand what they represent or better what they mean. :| Maybe are they just the result of Viewing Transformation (before the Model Transformation)? Is it correct?

Third question:

How should I use these coordinates to hit my aim? I don't know at every time the objects's coordinates if the modelview always change. I only know the vertex in the object's local coordinates and not the final position after i applied all the transformation to put it in the right location in the scene. I hope is clear what I' like to say :)

I hope someone could help me.

Thanks in advance.

p.s. Sorry for my english, it's not quite good :)

Now I'm going to explain my problem.... I have a 3d scene that change dynamically with the phone's sensors. The sensors produce a modelview matrix and I set it in OpenGL with glLoadMatrix() at every frame. So the scene moves using the sensors.

Now, I need to detect which obj in the 3D scene has been touched by the user. I know this is "picking". Someone has suggested to me to use this way:

"unproject from the (x,y) screen coordinates to a ray in model

space, and work out which object(s) intersect that ray"

First question: What does "model space" mean?

Second question:

I used unproject with screen coordinates and I get their world coordinates, but I don't understand what they represent or better what they mean. :| Maybe are they just the result of Viewing Transformation (before the Model Transformation)? Is it correct?

Third question:

How should I use these coordinates to hit my aim? I don't know at every time the objects's coordinates if the modelview always change. I only know the vertex in the object's local coordinates and not the final position after i applied all the transformation to put it in the right location in the scene. I hope is clear what I' like to say :)

I hope someone could help me.

Thanks in advance.

p.s. Sorry for my english, it's not quite good :)