How to tell what part of a 3D cube was touched

Posted by user2539517 on Game Development See other posts from Game Development or by user2539517
Published on 2013-07-02T18:18:19Z Indexed on 2013/07/02 23:19 UTC
Read the original article Hit count: 242

Filed under:
|
|
|
|

I am writing a rather simple android game and I am implementing Open GL to draw a 3D cube that spins upon the X, Y and Z axis and I need to know where the user has clicked on the texture of the cube.

The texture is a simple square bitmap (100x100) that has a smaller square in the center. I need to know if the user touches the inner square. As well was tell which face of the cube the user touches. Does anyone know how this can be accomplished if not can anyone give some pseudo code on how to tell where the ray correlates to the texture? Or at least point me in the right direction.

The textures of each face are like this:

enter image description here

The code I am using is from: http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_3D.html2.9 It is a port to android from Lesson 6 NeHe. Example 6a: Photo-Cube

© Game Development or respective owner

Related posts about opengl

Related posts about android