Results 1 to 3 of 3

Thread: Help detecting when a 3d element is touched on iPhone

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    Help detecting when a 3d element is touched on iPhone

    Hi, I've got some experience doing 3D programming, but it's OLD experience, when I did all the math, transformations and projections manually.

    Now I'm writing some software for the iPhone, using Open GL ES 2.0.. I have learned a lot about managing my objects, rendering, and all that, but now I'm trying to create some interaction.

    I know how to detect the touch events, and can determine where a touch starts/stops on the screen, but I'm having a hard time finding a way of determining if a touch is 'on' a given object in the scene. I assume there is some function to determine if a touch 'collides' with the an element in the space, based on what was rendered there, but I can't seem to find it.

    I guess I could write an algorithm to work it out, but that seems both redundant, and slow.

    Please let me know if there is a function for this, and I can probably figure it out from there, although any examples/further instruction would be appreciated.

    Thanks,
    SilicaGel

  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    12

    Re: Help detecting when a 3d element is touched on iPhone

    You're going to have to write code to do it. Turn your touch point into a ray that casts into the screen and checks for collisions. Search for info on Google about "3D picking."

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    12

    Re: Help detecting when a 3d element is touched on iPhone

    Another easier way is to render each object a special color to a texture, then check the color of the pixel you touch and return the object using the ID. Ideally use a binary search when looking up the ID. Search "picking painter's algorithm."

Similar Threads

  1. Replies: 3
    Last Post: 07-01-2011, 10:20 PM
  2. OpenGL ES for iPhone - get my current 3d element position
    By Neris_DoGg in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 3
    Last Post: 06-16-2010, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •