Cursor ingame

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: Cursor ingame

Postby Carsten » 2012-03-07, 23:59

Wow, this is not simple.

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-clip matrix, which is the result of world-to-view followed by view-to-clip, or view-to-clip * world-to-view (note the order).

It would be possible to get all this from the MatSys::Renderer somewhere 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.
Best regards,
Carsten

Return to “Coding and Scripting”

Who is online

Users browsing this forum: No registered users and 3 guests