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?
Ray picking fails with glTranslatef? Why
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!
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!
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.
[color=#1C2837][size=2]Nobody ever used ray picking and nobody knows anything about it.
Amazing.[/quote]
[color=#1C2837][size=2]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.
[color=#1C2837][size=2]
[color=#1C2837][size=2]There are other ways to do raycast collision as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement