Jerky (ortho)camera movement

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
cinek
Posts: 13
Joined: Sat Aug 07, 2004 3:00 pm
Location: Poland

Jerky (ortho)camera movement

Post by cinek »

I'm making a simple xpilot-like game and I need a top-down orthogonal view that would scale to contain all player objects on the screen.

Everything's fine but the camera is "jumping" and when there are more more than one objects on the screen and they get a bit far away they sometimes star disappearing and reappearing (flashing) very fast.
Even with only one object in the game, when the camera should be at the same (x, z) position as the object, it is jerky.

Here's the code I use every frame to position the camera:

Code: Select all

projection.buildProjectionMatrixOrthoLH(w, h, 20, -5);
g_camera->setProjectionMatrix(projection);
g_camera->setPosition(vector3df(x, 1, z));
g_camera->setTarget(vector3df(x, 0, z));
g_camera->setUpVector(vector3df(0, 0, 1));
where w, h, x and z are the dimesions of the viewport and position of the center (between all the objects).

Immediately following this code is a beginScene(), drawAll(), endScene() sequence.

I'm putting it on my FTP server (less than 600KB): ftp://studio4plus.com/pub/test2.zip (it doesn't work too well with MSIE I'm afraid). See the README.txt file.

And, well, the question is, what can I make to eliminate this jerkyness? :)
I'm planning to be moving the camera with inertia in the long run, maybe that'll be enough to smooth it out?

I haven't completely figured out the zNear, zFar parameters yet (I think I know what they're for, but my understanding of them isn't correct I'm afraid) but I don't think it has much to do with them.
Cinek
Post Reply