title: iPhone opengl es: Touch detection
body: <p>I have been messing around with opengl es on the iphone and right now I have some cubes on the screen. Currently I am trying to detect touches on these cubes. After a lot of searching on google this is what I have so far </p>
  
  <ol>
  <li>Use gluUnProject to find the x,y cordinates on the near plane in the world cordinate system</li>
  <li>Use gluUnProject to find the x,y cordinates on the far plane in the world cordinate system</li>
  <li>Subtract the vector obtained in 2 from the vector obtained in 1 to obtain the direction vector</li>
  <li>Normalize the direction vector to obtain the unit vector</li>
  <li>Iterate through all the trianlges and use the ray-triangle intersection to check if the ray intersects this triangle</li>
  </ol>
  
  <p>I think my mistake is in step 5. I have a feeling I am supposed to transform my triangles by the modelview matrix? Is my assumption correct? If yes any clues how to transform a triangle (an array of 3 floats) by the modelview matrix (an array of 16 floats)</p>