Jump to content

  • Log In with Google      Sign In   
  • Create Account


Ray picking fails with glTranslatef? Why


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 16 September 2011 - 01:23 PM

Let's take simple ray picking with OpenGL.

http://www.alsprogra...n_tutorial.html

Draw some stuff with glTanslatef and glVertex3f and try to detect click.

For first object the picking works for the rest of the objects ("made by glTranslatef") the picking fails.
I tried so many functions (lineTriangleIntersect, RayTriangleIntersect etc etc) and all of them have same problem.
If glTranslatef comes into scene the picking fails on all objects, except first..


Why the hell it fails?
What's the point of ray picking then if i can only detect click on "ONE item at the time"?

I am so disappointed.Is it even possible to do ray picking if i draw stuff with glTranslatef?

Sponsor:

#2 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 17 September 2011 - 08:24 AM

Nobody ever used ray picking and nobody knows anything about it.


Amazing.

#3 kauna   Crossbones+   -  Reputation: 2166

Like
1Likes
Like

Posted 17 September 2011 - 08:37 AM

Hi,

The symptoms you describe give me an idea that when you use translation / rotation, the ray and the object aren't any more in the same space which results the polygon hit test not working as intended.

On the other hand, object drawn with identity matrix makes the objects local space same as the world space which is why the code works.

In order to pick translated / rotated objects, you'll need to transform the polygons to the world space (transform all vertices by the objects transform matrix) or transform the view ray from world space to the objects local space (transform view ray by inverted objects model matrix).

I use the "transform view ray method" since it has smaller memory foot print.

Cheers!

#4 FLeBlanc   Crossbones+   -  Reputation: 3081

Like
1Likes
Like

Posted 17 September 2011 - 09:06 AM

Instead of pissing and moaning about nobody knowing about picking, why don't you try posting some code so we can see what you are screwing up.

#5 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 18 September 2011 - 10:08 AM

Thank you Kauna
I will try it.

#6 dpadam450   Members   -  Reputation: 842

Like
1Likes
Like

Posted 19 September 2011 - 10:23 AM

Nobody ever used ray picking and nobody knows anything about it.


Amazing.


Nobody here gets paid to help you. Considering this is doing per triangle collision with objects in the world, its pretty obvious it you call glTranslatef() the graphics card draws it to translated, but you still just have the original data.


There are other ways to do raycast collision as well.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS