View Full Version : detecting touches when 3D is being used

Oct 20, 2009, 03:57 PM
using openGLES and detecting touches in 2D space is pretty simple because the coordinates map onto the coordinates of quartz easy

but, when you want to know when someone has touched an object in 3D space, how would you do it?
the coordinates aren't the same as they would be in 2D space

Oct 20, 2009, 05:06 PM
well your current viewpoint when you the screen is touched will be showing technically a 2D picture, so from using your viewpoint and where the user pressed on the screen, you can work out what he may have touched (or atleast where in a 3D world)

Oct 20, 2009, 10:38 PM
due to a nice and welcome plot twist someone changed my code to make this easier by having the camera move to a position where a unit in 3D equals a pixel on the phone

Oct 21, 2009, 02:01 PM
You can this as a ray-casting problem - imagine shooting a ray from the 2D point in window space into the scene and you want the coordinates of the intersection with the first object it hits. Take a look here for some additional references:



Oct 21, 2009, 03:16 PM
yeah i thought of a concept similar to ray tracing, i just didn't know how to do that

well... ray casting sounds slightly different so i'll give that a search too