I'm currently working on a Voxel game in 3D and need a tad bit of help to figure out what Voxel the player is looking at. This is the data I currently have:
GRRLIB_Camera3dSettings(Player.x, Player.y, Player.z + 4, 0,0,1, Player.x + Camera.lookx,Player.y + Camera.looky,Player.z + Camera.lookz); And the two 3d arrays that contains the player cords and block cords:
struct Player{ int X; int Y; int Z; } int World[X_MAX][Y_MAX][Z_MAX]; //The cords are ALWAYS positive. ( and the array data: 0 Means air, anything higher is solid), The player (GRRLIB camera is described here: http://grrlib.santo.fr/doc/group___all_func.html#ga7300940a38526ab5aa9be0f4abe4a32a)
So what I basically need to understand is how I would implement ray tracing using this data. The whole project can be found here: https://github.com/filfat/WiiCraft
For clarification I am asking for a simple way in C or C++ to create a Ray tracing algorithm that would be used in a Minecraft like game for selecting the block the player is looking at, all data that is needed is above. So in short I need help to understand the math in a Ray Tracing algorithm and need a simple example so I could implement it myself.
Thanks! :)