Using Buttons To Control FPS Camera

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kkrizka
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Using Buttons To Control FPS Camera

Post 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?
Cheers,
Karol Krizka

http://www.krizka.net
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post 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.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Definitely use standard camera node and create your own animator. Thats what I recommend also.
Post Reply