How To Detect Which 3d Object Has Been Touched?
Assume I have 3 cubes in random location/rotation that are visible in the viewport. I want to be able to detect if which of the cube has been touched if I touch ( or click on emula
Solution 1:
THere could be several objects (or none) that are on that x / y coordinate. You should find them all, and then if there are any, check the z-coordinate to see which one is the closest to the viewport (and so the one that was touched).
Solution 2:
Often wondered about best way to do this without glSelect()... this answer looks good: iPhone OpenGL ES - How to Pick
(You can ignore the fact it's an iOS question... the OpenGL ES API is the same on both platforms AFAIK).
Post a Comment for "How To Detect Which 3d Object Has Been Touched?"