Couple of Camera Questions

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
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Couple of Camera Questions

Post by Ion Dune »

EDIT: I just need the solution for the second problem now. First problem fixed.

First of all, is there any easy way to make jumping ability with the FPS camera? I checked the API and I noticed the the thing about upward movement but I wanted to make jumping activated my something like the spacebar and not by looking up. I saw that other topic in this forum about making an actor instead of a camera, but I have no idea how to do that and would like to avoid it if all possible.

EDIT:
I tried adding the lines

EDIT: Doof. I just saw and corrected my array size variable and it works fine now.

Code: Select all

   keyMap[8].Action = EKA_JUMP_UP;
   keyMap[8].KeyCode = KEY_SPACE;
to my camera's keyset, but I saw no effect when compiled. This is what I currently have for the camera:

Code: Select all

	             SKeyMap keyMap[8];
                 keyMap[0].Action = EKA_MOVE_FORWARD;
                 keyMap[0].KeyCode = KEY_UP;
                 keyMap[1].Action = EKA_MOVE_FORWARD;
                 keyMap[1].KeyCode = KEY_KEY_W;

                 keyMap[2].Action = EKA_MOVE_BACKWARD;
                 keyMap[2].KeyCode = KEY_DOWN;
                 keyMap[3].Action = EKA_MOVE_BACKWARD;
                 keyMap[3].KeyCode = KEY_KEY_S;

                 keyMap[4].Action = EKA_STRAFE_LEFT;
                 keyMap[4].KeyCode = KEY_LEFT;
                 keyMap[5].Action = EKA_STRAFE_LEFT;
                 keyMap[5].KeyCode = KEY_KEY_A;

                 keyMap[6].Action = EKA_STRAFE_RIGHT;
                 keyMap[6].KeyCode = KEY_RIGHT;
                 keyMap[7].Action = EKA_STRAFE_RIGHT;
                 keyMap[7].KeyCode = KEY_KEY_D;

			     keyMap[8].Action = EKA_JUMP_UP;
				 keyMap[8].KeyCode = KEY_SPACE;

	scene::ICameraSceneNode* camera = 
		smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, keyMap, 9, true, .5f);
	camera->setPosition(core::vector3df(0,150,0));

	scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(30,50,30),
		core::vector3df(0,-3.f,0), 
		core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();
Second, is there any way to change a FPS Camera's height? My goal is to make a crouching mechanism by checking for a key input and switching between two cameras, one of which is half the size of the other to emulate crouching.

Thanks for your time.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

not sure about the jumping thing, but the simplest way to do crouching would be to remove the fps camera (camera->remove()) and replace it with a slower one, and a different ellipsoid shape in the collision response animator. the shape of the ellipsoid and the offset define the size of the camera
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Yeah, I got the jumping thing pretty much worked out.

Ok, thanks a lot.

EDIT: I just have one last problem, concerning the jumping.

I read this post: http://irrlicht.sourceforge.net/phpBB2/ ... light=jump

I and see that I have to make it so that you can only jump when you're on the ground, but how could I do that? I honestly have no idea where to start.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

there are so many methods. one of them is...

when your model is colliding with the ground,
bool canJump=true;
when a button, let's say [SPACE] is pressed, your character jumps,
canJump=false;
when character pulled by the gravity and felt on the ground again,
canJump=true;

so you just make it... only when canJump=true, your [SPACE] will be enabled.

this is my own method though.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

I'm pretty sure I get the logistics. What I don't understand is the actual coding, what functions to use, etc.
MrSnowflake
Posts: 4
Joined: Sat Dec 22, 2007 5:42 pm

Post by MrSnowflake »

If you are using a CollisionResponseAnimator then you can use its member isFalling() to know if you're on the ground.
Post Reply