Camera tracking

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
cyze
Posts: 10
Joined: Thu Jul 06, 2006 12:00 pm

Camera tracking

Post by cyze »

Im trying to get my camera to follow my player around as he moves.

Im doing this with cam->setPosition( players pos + camera offset )
and cam->setTarget(players pos)

but i get this glitch in som frames (quite many actually) that flicker the scene.

My guess is that it has something to do with the camera trying to rotate its
view towards the target (i dont get flickering if i remove the setTarget part)

has anyone got an ide of how to do better camera tracking or why it flickers
(and how to avoid it of course ;) )

thanks //christoffer
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

A search on the forum would help... :roll:

try to update the absolut position of the cam

Code: Select all

cam->updateAbsolutePosition();
or something like this (have a look at the docu)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
cyze
Posts: 10
Joined: Thu Jul 06, 2006 12:00 pm

Post by cyze »

hmm, after a quite comprehensive search i still can't find a solution to my problem ;).

The problem is not with the camera not following its parent, and therefor the updateAbsolutePosition() does nothing to help me.

The problem goes away if i create another window for rendering (so that i have two active windows at the same time) but that starts a whole lot of other problems of course ;). It could be that its my graphic card thats a little out of style (old 1ghz toshiba laptop).
cyze
Posts: 10
Joined: Thu Jul 06, 2006 12:00 pm

Post by cyze »

Maybe I have to take direction vector of model's movement and to subtract some defined 'distance' from it? if it's right, then how i can get this 'direction vector'?
Thats how i do it, but thats when i get the choppy camera behavior. I use an array of 3 floats that hold the offset for the camera relative to the player (a note here is that i do not need to rotate the camera, the offset is fixed. If you need to rotate the camera around the player, use setRotation( <player movement vector>.getHorizontalAngle() ); to get the camera to look in the direction of your player).

I also use the addCameraFPS() with disabled inputkeys, wich gives me a camera without a target (since the offset is always the same, i dont need to update the target).
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

try my class

Post by juliusctw »

i created a working 3rd person camera, you can check out the source, its done in linux


freewebs.com/juliusctw
Post Reply