View Full Version : Arc interpolated cameras

I'm trying to arc interpolate between 2 cameras that are both defined by an eye and a target vector.

I convert the vector pair to transform matrices and then to quarterions. I slerp the quat and convert back to a matrix. I then transform a unit vector by the new matrix and scale it and offset it to get the new camera eye / target pair.

But it doesn't work ( doh !!! ). Does any one have a useful solution?

thanks

Leo

harsman

08-15-2002, 06:51 AM

To interpolate between to vectors:

Take the cross product of the two vectors and normalize if needed. This is your rotation axis. The angle for a full interpolation you get from vector1 dot vector2, since the dot product equals the cos of the angle between the vectors. Create a rotation matrix from this axis angle pair (lerp the angle) and you're done. Or just use glRotate since it takes an axis angle pair as parameters.

thanks. thats a much simpler and more apropriate approach.

Leo

vshader

08-16-2002, 06:30 PM

you can use your original approach, but you must use the view-vector/up-vector pair for each camera position. make sure to make the up vector truly orthogonal first, too.

if you just interpolate the view vectors the camera can roll and flip.

Jambolo

08-16-2002, 09:07 PM

Originally posted by Leo:

thanks. thats a much simpler and more apropriate approach.

...if you restrict the camera's movement or you don't care what happens to the camera's up vector.

harsman

08-17-2002, 12:23 AM

It seemed like the goal was to interpolate the position of the camera and it's view vector. The easiest way to do this is probably to handle position and orientation separatly. Use a spline for the position and interpolate the view vector separately per my suggestion. If you want to have a stable up vector why don't use a fixed one pointing up? Quaternions are nice and all, but for interoplating vectors they're a little overkill IMHO. I'm a little reluctant to go through all that conversion just to get slerping. It might be a better idea to use quats as your representation if you need to interpolate a lot. Anyway that's just my opinion, there are several older threads on the subject of interpolating orientations, e.g. this one (http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/003999.html) .

V-man

08-17-2002, 05:57 AM

If your gone use a spline. It will be a problem since you need to decide on a control points. Since an arc is needed for the movement, you need to compute the dot product between vectors to figure out the angle, then compute the center of the circle, and apply a rotation to the position.

That's for the position and the view vector will of course point to the center or point away from center.

Of course, this can lead to problems. (Example: vectors are at 180 degress from each other). Something like hermite spline might help.

V-man

The method is required in order to bring a chase camera back to the static position behind the player's shoulder. There is no up vector, a CamRoll variable is interpolated, splines can't be used and movement most definately must be restricted.

The method by harsman does work but I must be reconstructing the eye / target pair incorrectly as the axis flips its sign each frame which is either causing or is the result of the reconstructed eye / target pair to have negative magnitude. I can work round this and force it to work but it is causing smaller problems.

If I can't solve it by the end of today I'll post a pseudo code example (broken), otherwise I'll post the solution.

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