Cursor ingame
Hi @ll,
I am trying to make a custom cursor not only visile in GUIs but in the whole game. Seperating the mouse moves from the camera position was not that comlicated, but:
is there an easy way to display an cursor in the whole game?
The Idea: I am using some abstractions under the BaseEntityT, so there will be a SelectableEntityT and derived from this, ActionEntityT, which will rise a GUI on rmb. Selectable Items will be selected via lmb.
I would appreciate any ideas very much.
Greetings!
I am trying to make a custom cursor not only visile in GUIs but in the whole game. Seperating the mouse moves from the camera position was not that comlicated, but:
is there an easy way to display an cursor in the whole game?
The Idea: I am using some abstractions under the BaseEntityT, so there will be a SelectableEntityT and derived from this, ActionEntityT, which will rise a GUI on rmb. Selectable Items will be selected via lmb.
I would appreciate any ideas very much.
Greetings!
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
Hi Haimi,
This GUI is used both for the display of the health and ammo amounts, as well as the active weapons cross-hair, which is technically really the same as a cursor.
Possibly you can modify or extend this to your purposes.
Not sure what exactly you want to achieve, but did you have a look at the "HUD" (head-up display) GUI?Haimi wrote:is there an easy way to display an cursor in the whole game?
This GUI is used both for the display of the health and ammo amounts, as well as the active weapons cross-hair, which is technically really the same as a cursor.
Possibly you can modify or extend this to your purposes.
Best regards,
Carsten
Carsten
Re: Cursor ingame
Thanks alot, i Understand the theory now, perhaps I will manage to do this on the Weekend
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
Okay, now I have had this Idea:
- the crosshair is my cursor, the graphic is already changed.
What I try to achive now is, not to move the camera when i move the mouse, but to move the "crosshair" around.
Can you give me a hint, I have tried to figure out where the mouse moving event "lands" in an actual method but I did not find anything.
Combined with the 3rd person view this seems to be going rather fast towards my Game Idea
- the crosshair is my cursor, the graphic is already changed.
What I try to achive now is, not to move the camera when i move the mouse, but to move the "crosshair" around.
Can you give me a hint, I have tried to figure out where the mouse moving event "lands" in an actual method but I did not find anything.
Combined with the 3rd person view this seems to be going rather fast towards my Game Idea
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
At this time, we "convert" mouse and keyboard input to
Well, and this is also the problem: We have no direct way to know the mouse input events in the game code.
I've not thought this though, but you might extend the
A completely different (and probably better!) alternative is that instead you create a new GUI with translucent background for the same purpose.
See and try out the "chat" GUI that you can open by pressing
Yes... this is the easier and better and more powerful and recommended method.
PlayerCommandT
's directly at [url=http://trac.cafu.de/browser/cafu/trunk/Ca3DE/Client/ClientStateInGame.cpp?rev=482#L326]ClientStateInGameT::ProcessInputEvent()[/url]
...Well, and this is also the problem: We have no direct way to know the mouse input events in the game code.
I've not thought this though, but you might extend the
PlayerCommandT
with members for mouse position x and y, and update them in the above function before or after the pitch and heading are updated as well. Then re-use them in the game code to display the cursor at the desired position.A completely different (and probably better!) alternative is that instead you create a new GUI with translucent background for the same purpose.
See and try out the "chat" GUI that you can open by pressing
T
while being in-game.Yes... this is the easier and better and more powerful and recommended method.
Best regards,
Carsten
Carsten
Re: Cursor ingame
I think this might be a good idea, but in the game I want to use the Cursor to interact with World Objects. So is the cursor bound to the gui or is there a possibility to get if the cursor touches an entity?
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
Okay, i have now tried it out, but on the one Hand, when I use interactive GUI I cannot use the keys to move around, and on the other hand when I use a non-interactive GUI, The Camera still moves with the mouse. And I want to acieve the camera moving only on LMB down while moving. So I think i might have to rewrite the ClientStateInGameT::ProcessInputEvent()...
Another Idea is to make an interactive GUI where the keyboard events are handled to the game... an "half interactive GUI" would this be possible without rewriting the GUISys?
Another Idea is to make an interactive GUI where the keyboard events are handled to the game... an "half interactive GUI" would this be possible without rewriting the GUISys?
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
A few hours of hacking later i found out that I can use Keyboard events when I change in ClientStateInGame.cpp:847 from
to
and comment out the
Or is there even a better way to lead all events from the interactive gut to the game?
Another important question according the GuiSys-game connection is: How complicated can it possibly be to define a class for selectable Entities, so that they callBack into gui oder game code?
Code: Select all
if (ActiveGui->GetScriptName() == "" && WasLMBOnceUp)
Code: Select all
if (/* ActiveGui->GetScriptName() == "" &&*/ WasLMBOnceUp)
ActiveGui
completely. It's an evil hack, but now I can Use the Keyboard for the Game in an interactive GUI. BUt still the mouse movements are not forwarded to the GUI. Any Ideas?Or is there even a better way to lead all events from the interactive gut to the game?
Another important question according the GuiSys-game connection is: How complicated can it possibly be to define a class for selectable Entities, so that they callBack into gui oder game code?
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
Sorry, I fear you're losing me here...Haimi wrote:But still the mouse movements are not forwarded to the GUI. Any Ideas?
Or is there even a better way to lead all events from the interactive gut to the game?
If I understand you right, you have a "Chat" type GUI active and open which is consuming the mouse events so that the underlying game client GUI doesn't receive the events as well?
I don't think that that is particularly difficult: If I wanted to make the "Chat" GUI be able to click on an entity (e.g. in order to pick whom the message is sent to), I'd add a script method to the GUI scripting implementation that does the job. That is, when a mouse click occurs and our window'sAnother important question according the GuiSys-game connection is: How complicated can it possibly be to define a class for selectable Entities, so that they callBack into gui oder game code?
OnAction()
script method is called, we need another (yet to be written) method like gui:findEntity()
that does the job and digs up the details that you want to learn about the clicked entity.Implementing this script method should not be overly difficult, but please forgive me that I cannot come up with an example at this time in the night.
Best regards,
Carsten
Carsten
Re: Cursor ingame
Yes, exactly. That is the Problem.Carsten wrote:Sorry, I fear you're losing me here...Haimi wrote:But still the mouse movements are not forwarded to the GUI. Any Ideas?
Or is there even a better way to lead all events from the interactive gut to the game?
If I understand you right, you have a "Chat" type GUI active and open which is consuming the mouse events so that the underlying game client GUI doesn't receive the events as well?
I will try to figure out how I can realize the
gui:findeEntitiy()
... No need for you to do it after Midnight Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
In the engine, mouse events are distributed to the GUIs in the GUI Manager starting atHaimi wrote:Yes, exactly. That is the Problem.Carsten wrote:If I understand you right, you have a "Chat" type GUI active and open which is consuming the mouse events so that the underlying game client GUI doesn't receive the events as well?
[url=http://trac.cafu.de/browser/cafu/trunk/Ca3DE/MainCanvas.cpp?rev=483#L669]MainCanvasT::OnMouseMove()[/url]
.(Except for the "Client" GUI with the 3D world, which is handled specially in the
MainCanvasT::OnIdle()
just above MainCanvasT::OnMouseMove()
.)Normally, only the topmost active and interactive GUI receives the event, so that it is processed only a single time. Starting from here, e.g. by giving your GUI a specific name that you treat specially in these methods similar to the "Client" GUI, you should be able to let multiple GUIs have the same mouse event.
Best regards,
Carsten
Carsten
Re: Cursor ingame
Okay, I see i misunderstood something. The Problem by example:
I have an interactive GUI (Like the Chat GUI) all over the Screen. I need that to be able to move the Cursor over the whole screen.
Now I cannot move the player around or anything, I can't even press ESC to reach the main menu...
If I do my little dirty Hack from 2 of my posts above, I can at least move around using the WASD Keys, but no moving the camera around...
So the Idea was to use the mouse using the cursor, but if I hold down the LMB i stop moving the mouse and instead move the camera - as with a non-interactive GUI like the HUD.
But My Events are consumed by the GUI and I cannot get the commands as far as the Command recognition in
I have an interactive GUI (Like the Chat GUI) all over the Screen. I need that to be able to move the Cursor over the whole screen.
Now I cannot move the player around or anything, I can't even press ESC to reach the main menu...
If I do my little dirty Hack from 2 of my posts above, I can at least move around using the WASD Keys, but no moving the camera around...
So the Idea was to use the mouse using the cursor, but if I hold down the LMB i stop moving the mouse and instead move the camera - as with a non-interactive GUI like the HUD.
But My Events are consumed by the GUI and I cannot get the commands as far as the Command recognition in
ClientStateIngame.cpp
would be able to handle them aswell.Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
The main thing I would need to know: how can I prevent the GUI from consuming the events? I tried some code where events are handled to the GUI, but still I cannot change a thing.
And I tried to implement the
And I tried to implement the
gui:findEntity[/id] method, but I cannot figure out how I can check if there is an entity at the mouse position at click time. Can you give me a hint please?
Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Re: Cursor ingame
The main problem is probably inHaimi wrote:The main thing I would need to know: how can I prevent the GUI from consuming the events? I tried some code where events are handled to the GUI, but still I cannot change a thing.
MainCanvas.cpp
: whereever the code has to distribute events, it calls Code: Select all
cf::GuiSys::GuiI* ActiveGui=cf::GuiSys::GuiMan->GetTopmostActiveAndInteractive();
ActiveGui
only.You may wish to alternatively or additionally distribute the same events to another GUI in the GuiMan as well, e.g. you could identify the relevant GUI by giving one of it's windows a "magic" name, as the code does with the "Client" root window.
And I tried to implement thegui:findEntity[/id] method, but I cannot figure out how I can check if there is an entity at the mouse position at click time. Can you give me a hint please?[/quote]
The key idea is to trace a ray through the "eye" into the world: The ray originates from the "eye" of the player, into the direction of and "through" the position of the mouse pointer. The problem is probably to learn the players current eye position, and especially the directional vector of the ray.
Once you have these, it's the same as if the player was firing a gunshot: whatever is hit is the desired entity.
(By the way, the world editor CaWE solves the same problem all the time, and is has very nice and clean code for the related math starting at http://trac.cafu.de/browser/cafu/trunk/CaWE/ChildFrameViewWin3D.cpp?rev=490#L156)
Please let me know if that is enough info. If it isn't, I'll look more deeply into it. :up:
Best regards,
Carsten
Carsten
Re: Cursor ingame
Okay, I understand the theory now, but I am still not in deep enough to figure out by myself where I should get the camera Position (Okay, first Guess:
EyePos(MatSys::Renderer->GetCurrentEyePosition());
) and the Stack of elements to Iterate over...Project Status: Code architecture definition
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
6 Programmers, 1 Photographer, 1 Architect, 1 Game designer
Who is online
Users browsing this forum: No registered users and 5 guests