Page 1 of 1

questions about the camera

Posted: Sat Jan 27, 2007 3:48 pm
by Janx
Hey all! :)

I found out about Irrlicht a few days ago and I really love it
so far, however being a beginner in C++, game programming,
and 3D programming as well (and trying to learn all three things
at the same time), I have some problems (btw:
the nice structure of Irrlicht makes it awesome for learning about OOP).

The most important one at the moment is the normal camera.
The FPS camera works of course, but I want to build a 3rd person
camera that flies behind my player model.

I know there are a few threads where people posted solutions, but
to be honest I want to try it alone and just need some basic
information.

What is the normal camera actually doing?
When I used the same code that I had used for movement with the
FPS camera, the normal camera moved very different, and not at all
the way I would have expected.

Basically I just changed the x, y, z coordinates of the camera
when the w a s d keys where pressed, which like I said worked
for the FPS camera.

After putting all coordinates on the screen (camera position,
player position) I was hoping to find out why the camera behaved
the way it did.
By chance I saw the .setTarget function of the normal camera and
figuered maybe the problem is that the camera always points at
a target, which would explain the weird movement of the camera
when I just changed it's coords.

So I put the playernode as the cameras target, and changed the
position of the playernode and camera simultaniously when
a w s d keys are pressed (both every time a key is pressed).

The camera now behaves the way a normal 3rd person cam does,
however there is huge lag/graphic artifacts (whatever it is called)
when I move to the side.

Would be great if anyone could clarify for me how the camera
actually works, thanks alot :)

Posted: Sat Jan 27, 2007 8:09 pm
by xtheagonyscenex
i dont understand what your asking? :?: :oops:

Posted: Sat Jan 27, 2007 8:15 pm
by Janx
I was asking why, when I change the coordinates of the normal camera, it does strange things like fly in a half circle and stuff instead of just going to the new coordinates.

But it's not so important anymore :P

Posted: Sat Jan 27, 2007 8:22 pm
by xtheagonyscenex
maybe you have coordinate mixed the x,y,z and what camera you using you can the FPS cam and if you dont want to use the mouse just turn it off

Posted: Sat Jan 27, 2007 8:58 pm
by Janx
The thing is I want the player to be able to switch between a FPS kind of camera, and a free camera where he can use the mouse freely.

About mixing up the coordinates: if I press the 'a' key for example, the X coord gets reduced. But in the game, the camera flies in a kind of half circle instead of moving along one axis, and I dont really understand why/how that happens.

But I'm suspecting it to have something to do with the target of the camera...

Posted: Sat Jan 27, 2007 10:02 pm
by Acki
No, the camera is not flying in a courve...
But it still looks at a specific point (lookat / target) !!!
If you move to the left the camera looks to the right to it's target...
So you also have to change the target (look at) of the camera...

Also use cam->updateAbsolutePosition() after changing the position of the camera !!!

Posted: Sat Jan 27, 2007 11:18 pm
by Janx
updateAbsolutePosition() helped, thanks alot :)