I have a collection of coordinates for my camera to move. I want it to move in straight or curve.

How to do it mathematically? What math is involved here?

I have a collection of coordinates for my camera to move. I want it to move in straight or curve.

How to do it mathematically? What math is involved here?

If you grab two consecutive points from your list, subtract them and normalize it, you have a direction vector.

Then, just move the camera in that direction:

cam_position += cam_position + (cam_direction * cam_speed);

And if you maintain a position, direction, and up vector, you can create a camera lookat matrix from these 3 vectors.

If you’re using GLU, you can use the gluLookAt() function.

To get a smoother movement, you could probably maintain a quaternion rotation vector and Slerp between

the current and next one on the list.

Now I remember that using on my MD2 loader. It works perfectly in straight movement but I want it to move in circular. How do I do that?

Does using quaternions makes everything pretty hard? I’m not yet done on my linear algebra class though and do you have any tutorials for it?

You can Google for “quaternion camera”.

Here’s a tutorial on using a quaternion camera class:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=Quaternion_Camera_Class

You don’t have to know much about quaternions other than how to convert it to a matrix.

If you convert it to a matrix, then you can grab its orientation. Just extract the 3 vectors (row or column)

from the matrix for your right,up,direction (x,y,z) axes.