Its possible with q3d, but the math/linear algebra involved (unrelated to q3d) is a bit complex if youve never done it. Q3d viewport casts rays too, just based on x / y coordinates, the intersection gives you info about the point of intersection in X,Y,Z , normal of intersections, etc. through the expressions (they have useful descriptions).
You'd make the grid one big Q3D Model, and test for intersections with it. then you'd take the intersection point and do something like x= round(.x/cellsizex)*cellsizex to get it aligned to the grid. Just check out the source for the page to get an idea of how they did it! obviously it'll be simpler with Q3D since it has lots of functions and objects to do it, but not vastly different.