This is a script i found the internet. It works fine and returnd the coordinates in 3D of where my mouse is pointing at 1024 units away.
But what if there is a wall in front of me a few units away how can i get coordinates of the 3d mouse clipping in the wall? I couldn't find an example specifically showing this.
Here is the code i am using right now for tier 2:
// mouse x and y
int mX = agk::GetPointerX();
int mY = agk::GetPointerY();
// mouse to vector
float X3D = agk::Get3DVectorXFromScreen(mX, mY);
float Y3D = agk::Get3DVectorYFromScreen(mX, mY);
float Z3D = agk::Get3DVectorZFromScreen(mX, mY);
// get camxyz
float camX = agk::GetCameraX(1);
float camY = agk::GetCameraY(1);
float camZ = agk::GetCameraZ(1);
// Raytracer startpos
float rStartX = X3D + camX;
float rStartY = Y3D + camY;
float rStartZ = Z3D + camZ;
// Raytracer endpos
float rEndX = 1024 * X3D + camX;
float rEndY = 1024 * Y3D + camY;
float rEndZ = 1024 * Z3D + camZ;
return agk::CreateVector3(rEndX, rEndY, rEndZ);