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
Nox587
Posts: 12
Joined: Mon Jul 10, 2006 6:42 pm

FPS Camera

Post by Nox587 »

First of all, great engine, just started using it and its very easy to understand! So thanks :-)

Now, I'm pretty new to 3d game programming, and I'm just trying to educate myself...found this engine is a good place for me to start.

i'm attempting to make an FPS camera system, I know the engine already has one, but I want to create my own (learning exp). I want to "attach" this camera to a character, and make the controls behaive like an FPS.

I managed to get the character to move forward/backwards, and strafe left and right, but now I'm stuck with camera movement. I read somewhere there is a "special" way to create scene nodes for an FPS camera, I think one is supposed to be for horiz movement, the other for vertical....not sure about that though. My biggest problem is that I don't know how to translate mouse movement to a 3-dimensional rotation. Furthermore I'm not sure how to perform the slerp operation from the mouse movement data.

I know I need to create 2 quaternions, and plug them in (with a time var) to the slerp method...but where do I get the quaternions, and how do I get them from mouse movement?

Thanks for any help!
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

just parent the camera to the node....

the mouse movement isn´t that a big problem... just have an rect mouseOldPos, and a mouseNewPos, and one called mouseSpeed, then in your main loop (or anywhere else)

you write something like

mouseNewPos=getMousePos;
mouseSpeed=mouseOldPos-mouseNewPos;
mouseOldPos=mouseNewPos

node->setRotation(vector3df(mouseSpeed.X,mouseSpeed.Y,0)+node->getPosition());

TGM
Last edited by TheGameMaker on Mon Jul 10, 2006 7:36 pm, edited 1 time in total.
Nox587
Posts: 12
Joined: Mon Jul 10, 2006 6:42 pm

Post by Nox587 »

Perhaps I was not clear enough...I have already parented the camera to the node. I have basic walking, but I don't have rotation working. I don't know how to take the amount the mouse moved and translate that into how much a character/camera should rotate, I actually want it to slerp...
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

update^^ i wasn´t able to reab sry :oops:
Nox587
Posts: 12
Joined: Mon Jul 10, 2006 6:42 pm

Post by Nox587 »

That makes sence, I'll try it when I'm in front of a compiler. I'm assuming performing that every time the mouse moves will give me a smooth rotation? I'll try it out when I am at home, thanks much!
Nox587
Posts: 12
Joined: Mon Jul 10, 2006 6:42 pm

Post by Nox587 »

Just wanted to say this worked out great for me, thanks for the info! :-)
stodge
Posts: 216
Joined: Fri Dec 05, 2003 5:57 pm

Post by stodge »

Post some code! :D
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

everytime nice, to hear, that I was able to help someone :D
Post Reply