Using Buttons To Control FPS Camera
Posted: Tue Jun 02, 2009 9:07 am
Hi there,
I'm writing an application using Irrlicht that will be used on a touch screen computer without any keyboard (in addition to a desktop computer with a keyboard). In it, I'm using the FPS camera which is controlled through the keyboard.
My idea is to add a set of IGUIButton elements in the corner of the Irrlicht screen with up, down ... arrows and allow the user to press them to control the camera. Kind of like Google Earth lets you do.
The problem is that the FPS animator always resets the position of the mouse cursor to the center of the screen. Is there a way around this?
I'm currently thinking about grabbing the position of the cursor before the animator is called and manually resetting it after. This works, because I have to call animateNode() manually, because the animator only works if the camera is receiving input. So I trick it like this:
This is called from within the OnPostRender(u32 timeMs) function of a custom GUI element that holds all of my controls.
But is there a cleaner way, without having to write my own (or modifying the Irrlicht one) FPS animator, to accomplish this?
I'm writing an application using Irrlicht that will be used on a touch screen computer without any keyboard (in addition to a desktop computer with a keyboard). In it, I'm using the FPS camera which is controlled through the keyboard.
My idea is to add a set of IGUIButton elements in the corner of the Irrlicht screen with up, down ... arrows and allow the user to press them to control the camera. Kind of like Google Earth lets you do.
The problem is that the FPS animator always resets the position of the mouse cursor to the center of the screen. Is there a way around this?
I'm currently thinking about grabbing the position of the cursor before the animator is called and manually resetting it after. This works, because I have to call animateNode() manually, because the animator only works if the camera is receiving input. So I trick it like this:
Code: Select all
camera->setInputReceiverEnabled(true);
anim->animateNode(camera,timeMs);
camera->setInputReceiverEnabled(false);
But is there a cleaner way, without having to write my own (or modifying the Irrlicht one) FPS animator, to accomplish this?