O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Intersection Tests

Now that we have the touched area of the screen in normalized device coordinates, we’ll need to determine if that touched area contains the mallet. We’ll need to perform an intersection test, a very important operation when working with 3D games and applications. Here’s what we’ll need to do:

  1. First we’ll need to convert the 2D screen coordinate back into 3D space and see what we’re touching. We’ll do this by casting the touched point into a ray that spans the 3D scene from our point of view.

  2. We’ll then need to check to see if this ray intersects with the mallet. To make things easier, we’ll pretend that the mallet is actually a bounding sphere of around the same size and then we’ll test against that sphere.

Let’s start ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required