Page 1 of 1

Using Buttons To Control FPS Camera

Posted: Tue Jun 02, 2009 9:07 am
by kkrizka
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:

Code: Select all

  camera->setInputReceiverEnabled(true);
  anim->animateNode(camera,timeMs);
  camera->setInputReceiverEnabled(false);
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?

Posted: Tue Jun 02, 2009 10:25 am
by Brainsaw
I think the cleanes (and easiest) way is to write your own animator that doesn't respond to mouse movement. At least that's the way I would do it.

Posted: Tue Jun 02, 2009 8:15 pm
by arras
Definitely use standard camera node and create your own animator. Thats what I recommend also.