Burf2000
Burf2000

Reputation: 5203

Iphone OpengGL ES: detecting clicks on a primitive

I have created a 3d environment full of 3D cubes, does anyone have any idea how you would detect a touch on one of these Cubes. I thinking if I could get the cubes screen position (coords start from bottom left) then it would be pretty easy

UPDATE:

I added the function -(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D which seems to give me my items position in the world but the bit I am now stuck on is:

How do I join all this up, its the last thing in my way to archiving greatness!!!!

Upvotes: 0

Views: 1147

Answers (1)

Julio Gorgé
Julio Gorgé

Reputation: 10106

Look up OpenGL picking on Google. There are two main methods to accomplish this, I recommend you use the second one described at OpenGL.org as it does not involve rendering anything offscreen:

[…] involves shooting a pick ray through the mouse location and testing for intersections with the currently displayed objects. OpenGL doesn't test for ray intersections, but you'll need to interact with OpenGL to generate the pick ray.

Also see this question for some discussion on the matter: Screen-to-World coordinate conversion in OpenGLES an easy task?

Upvotes: 2

Related Questions