Some questions about the camera and mouse

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Daggio
Posts: 9
Joined: Mon Oct 20, 2008 7:04 am
Location: Surabaya, Indonesia

Some questions about the camera and mouse

Post by Daggio »

I have a working 3rd person camera (or so at least). The camera is the child of the player's node and it is behind the player's node. I can already move it using the mouse and shooting using mouse click. (the bullet ran from the player's node toward where the player's looking, I don't have any weapon model right now)

what I want to ask is:
1.) When I hold down the mouse click (left mouse button), it only shot once but when I hold down the 'H' key (I wrote it for testing) the player keeps firing the gun without any delay (just like a machine gun).

How can this happen? what is the difference between mouse input and keyboard input? I want the mouse input shooting to behave just like the keyboard input shooting. (I'm using EMIE_BUTTON_DOWN or something like that, I'm not at home and I don't have my code with me)

2.)I wrote my camera using addCameraSceneNode(); and am able to make it looks towards where to mouse pointer is. (just like the addCameraSceneNodeFPS(); mine just more flexible to what I need) but when I looked up, up, and up until I faced the spot right above the player's node, and then looked up again, the camera suddenly 'jumps' to the player's feet (or foot, I don't know the difference).

How can this happen? I realize at addCameraSceneNodeFPS(); you can't look more up than the spot right above you or the spot right below you (the camera node),how does it does this?


I think that's about it, I hope my English is right and you guys can understand me.

thanks in advance, any help is appreciated :D
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Some questions about the camera and mouse

Post by rogerborg »

Daggio wrote:How can this happen? what is the difference between mouse input and keyboard input?
Your OS will generate repeated key down events while you are holding a key down. It won't do that for mouse events.

What you'll want to do is to operate on the input state rather than directly on input events. See the event receiver in example 04.Movement/main.cpp; you'll want something similar, that also stores the state of mouse buttons.

Daggio wrote:I realize at addCameraSceneNodeFPS(); you can't look more up than the spot right above you or the spot right below you (the camera node),how does it does this?
I dunno, let's look at the source. ;)

source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp

Code: Select all

			if (relativeRotation.X > MaxVerticalAngle*2 &&
				relativeRotation.X < 360.0f-MaxVerticalAngle)
			{
				relativeRotation.X = 360.0f-MaxVerticalAngle;
			}
			else
			if (relativeRotation.X > MaxVerticalAngle &&
				relativeRotation.X < 360.0f-MaxVerticalAngle)
			{
				relativeRotation.X = MaxVerticalAngle;
			}
Where MaxVerticalAngle defaults to 88.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Daggio
Posts: 9
Joined: Mon Oct 20, 2008 7:04 am
Location: Surabaya, Indonesia

Post by Daggio »

thanks rogerborg, it works now :D

now the only problem I have is to limit the horizontal rotation of the camera, I've tried the code similiar to the one you gave me but that doesn't worked.


oh well, I'll try something to work that out.....


anyway, thanks :D
Post Reply