I see to ways to accomplish this:
One way is analogous to
ViewWindow3DT::GetElementsAt()in CaWE: You have to find the clip-to-world matrix, which is the inverse of the
world-to-clipmatrix, which is the result of
view-to-clip * world-to-view(note the order).
It would be possible to get all this from the
MatSys::Renderersomewhere following line http://trac.cafu.de/browser/cafu/trunk/ ... v=490#L321
The big question is how you'd get the resulting matrix to your GUI.
A completely different way of doing this is to implement your "mouse cursor" not in a GUI that has no "attachment" and "relationship" to the currently running game, but to implement it as a spatial object. Like the player's weapon, the mouse cursor would be a 3D element, implemented in the players entity code.
I'm saying this because the players (or 3rd person cameras) code knows exactly where in the world it is and which direction it is looking into. (This is easily seen by the example of the player code where is does fire projectiles through the level already.)
Taken this concept a step further, like being able to aim with the weapon while keeping the head/camera/view fixed, yields the desired starting point and direction somewhere in the process as required for the ray-tracing test.
Well, I utterly don't know your code, and thus neither can I know which method works best for you (I've tried neither), but while the first one seems to promise results sooner with less effort, the second one seems to feel principally cleaner.