This question already has an answer here:
- Cast ray to select block in voxel game 4 answers
I am currently creating a 3D Camera on the Playstation Mobile SDK (which is basically openGL with just a little bit of abstraction).
The game I am trying to make is a 3D Tactical. That means my world is composed of 3D cubes, all of the same size (unit size) and placed at integer position.
I'd like to be able to detect on which block the player clicks. That means, some sort of raytracing from the camera to detect the nearest block. My problem is that I am new to all this maths/physics/3d stuff. How could I implement this easily (and in a efficient enough way) ?
My camera currently have a position, and two modes : Target mode (it uses a LookAt on a point) and direction mode (it uses a lookAt on its position + the direction). That means I have access to the direction of the camera.