[SOLVED] Questions related to modifying the stock 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
Spinland
Posts: 32
Joined: Fri May 14, 2010 1:06 pm
Location: Upstate NY, USA

[SOLVED] Questions related to modifying the stock FPS camera

Post by Spinland »

Hi again!

I'm working to modify the FPS camera to include vertical movement, and am having mixed results. I figured I'd start a question thread and run through the issues I'm having in the hopes not only of getting things ironed out but of learning something in the process. 8)

First, I needed a couple of extra enumerations for the vertical up and down motion (I suppose I could have just used jump and crouch, but I wanted to learn how to do it right). Here is the original code (from SKeyMap.h):

Code: Select all

	enum EKEY_ACTION
	{
		EKA_MOVE_FORWARD = 0,
		EKA_MOVE_BACKWARD,
		EKA_STRAFE_LEFT,
		EKA_STRAFE_RIGHT,
		EKA_JUMP_UP,
		EKA_CROUCH,
		EKA_COUNT,
		//! This value is not used. It only forces this enumeration to compile in 32 bit.
		EKA_FORCE_32BIT = 0x7fffffff				
	};
Now I'm not sure how the 32 bit force part works in this context. I first tried just adding my new enumerations at the end of the list, like so:

Code: Select all

	enum EKEY_ACTION
	{
		EKA_MOVE_FORWARD = 0,
		EKA_MOVE_BACKWARD,
		EKA_STRAFE_LEFT,
		EKA_STRAFE_RIGHT,
		EKA_JUMP_UP,
		EKA_CROUCH,
		EKA_COUNT,
		//! This value is not used. It only forces this enumeration to compile in 32 bit.
		EKA_FORCE_32BIT = 0x7fffffff,
                EKA_MOVE_UP,
                EKA_MOVE_DOWN
	};
This netted me many overflow errors when compiling. I then tried moving the new items to just above the last one:

Code: Select all

	enum EKEY_ACTION
	{
		EKA_MOVE_FORWARD = 0,
		EKA_MOVE_BACKWARD,
		EKA_STRAFE_LEFT,
		EKA_STRAFE_RIGHT,
		EKA_JUMP_UP,
		EKA_CROUCH,
		EKA_COUNT,
                EKA_MOVE_UP,
                EKA_MOVE_DOWN,
		//! This value is not used. It only forces this enumeration to compile in 32 bit.
		EKA_FORCE_32BIT = 0x7fffffff
	};
This compiles, but some behavior that comes later makes wonder whether this is correct? Do I need to do something the the 0x7fffffff value to reflect that the number of items in the enumeration has changed?

Thanks in advance!
Last edited by Spinland on Mon Jul 12, 2010 6:16 pm, edited 1 time in total.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

= If enumeration has "count" value -- you must add only before it, OR it will not play its role.
= If enumeration has "force 32 bit" value -- this value must be the last any way and you may not add values after it.

In case of EKEY_ACTION, if you want safely add values, you have to do it just before 'EKA_COUNT'.
Spinland
Posts: 32
Joined: Fri May 14, 2010 1:06 pm
Location: Upstate NY, USA

Post by Spinland »

Thanks, that's a big help. I've implemented that change, and most (if not all) of my issues cleared right up. So much for needing a whole thread!
:lol:

There's one more small thing but I might know how to handle it already. If I turn out to run into a brick wall I'll follow up here with any questions.

Thanks again, you guys are great!
Post Reply