Changing controls for FPS Camera?

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
starphoenix
Posts: 13
Joined: Thu Mar 27, 2008 2:59 am

Changing controls for FPS Camera?

Post by starphoenix »

I'm looking at the parameters for the addCameraSceneNodeFPS function and theres two dealing with the key map or something along those lines. Can I use that parameter to change what controls the camera? I'd rather be using WASD rather than the arrows.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Blynx
Posts: 16
Joined: Sat Apr 12, 2008 8:41 am

Post by Blynx »

I use this:

Code: Select all

	SKeyMap keyMap[4];
 keyMap[0].Action=EKA_MOVE_FORWARD;   keyMap[0].KeyCode=KEY_KEY_W;
 keyMap[1].Action=EKA_MOVE_BACKWARD;  keyMap[1].KeyCode=KEY_KEY_S;
 keyMap[2].Action=EKA_STRAFE_LEFT;    keyMap[2].KeyCode=KEY_KEY_A;
 keyMap[3].Action=EKA_STRAFE_RIGHT;   keyMap[3].KeyCode=KEY_KEY_D;
scene::ICameraSceneNode* camera=smgr->addCameraSceneNodeFPS(0,100,500,-1,keyMap,4,false,0);

starphoenix
Posts: 13
Joined: Thu Mar 27, 2008 2:59 am

Post by starphoenix »

Awsome! Thanks Blynx!
Jgoldnight
Posts: 31
Joined: Thu Jun 07, 2007 6:23 pm
Location: New York
Contact:

Post by Jgoldnight »

On a similar note, I'm looking in the documentation but I can't seem to find a way to dynamically change the keyboard mapping for a FPS camera. Do I really have to recreate the camera to change the mapping?

Thanks
Computer scientist by day...
http://www.mrjoelkemp.com
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

According to the docs, the camera uses a pointer to the keymap, so in theory you could just alter the keymap, ie call:

Code: Select all

keyMap[0].KeyCode=KEY_KEY_J;
somewhere after the camera is made. I have not, however, tested this, so it might not work. If it doesn't, I suspect the only way would be to make your own FPS camera from scratch.

EDIT: I just tested it and it appears that it doesn't work, so I guess it cannot be done the way I said. Sorry.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Not currently possible, however, if you're using SVN trunk the FPS camera is just a normal camera with a special animator.
You can get access to this animator by calling cam->getAnimators() and casting the one with getType() == ESNAT_CAMERA_FPS to an ISceneNodeAnimatorCameraFPS. You can then set the keys, move speed etc through the animator's interface.

If you're not using SVN then I guess you'll have to wait for Irrlicht 1.5
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Jgoldnight
Posts: 31
Joined: Thu Jun 07, 2007 6:23 pm
Location: New York
Contact:

Post by Jgoldnight »

Thanks guys.

@Ion

That's a solution that came to my mind after further analyzing the documentation. Thanks for testing it though.

@bitplane

I'm not currently accessing the Irrlicht SVN, but thanks for the information. The quick fixes that I know of will suffice for now.

Looking forward to 1.5!!

Thanks again.
Computer scientist by day...
http://www.mrjoelkemp.com
Post Reply