Sarah22

01-14-2010, 06:40 AM

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?

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

View Full Version : How to move the camera to a certain coordinates?

Sarah22

01-14-2010, 06:40 AM

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?

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

sammie381

01-14-2010, 12:33 PM

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.

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.

Sarah22

01-15-2010, 08:48 AM

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?

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?

sammie381

01-15-2010, 11:39 AM

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.

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.