• 15
• 15
• 11
• 9
• 10

# FlyPath + up vectors

This topic is 3964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello forum, I'm coding a FlyPath (at least that's what I call it), you know the type where the camera follows a predetermined track. I am currently loading a series of control points from a plain text file. Each control point consists of an eye position, a look-at position and an up vector. To move the camera/eye I use 4 of the control points as input to form a Catmull-Rom Spline and simply interpolate. However, how should I interpolate the up vectors as the camera/eye follows the spline? I want to use the up vector the "roll" the camera/eye.
struct control_point
{
vec3 position, look_at, up;
};

...

void FlyPath::Animate()
{
lerp = lerp + MY_CTIME;

if (lerp > 1.0f)
{
lerp = 0.0f;

if (++index >= count)
{
index = 0;
}
}

vec3 p0 = step[(index - 1 + count) % count].position;
vec3 p1 = step[(index    ) % count].position;
vec3 p2 = step[(index + 1) % count].position;
vec3 p3 = step[(index + 2) % count].position;

current.position = 0.5f * ((2.0f * p1) +
(-p0 + p2) * lerp +
(2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * pow(lerp, 2.0f) +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * pow(lerp, 3.0f));

p0 = step[(index - 1 + count) % count].look_at;
p1 = step[(index    ) % count].look_at;
p2 = step[(index + 1) % count].look_at;
p3 = step[(index + 2) % count].look_at;

current.look_at = 0.5f * ((2.0f * p1) +
(-p0 + p2) * lerp +
(2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * pow(lerp, 2.0f) +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * pow(lerp, 3.0f));

// current.up = ?????????????????????????????????????????????????????????

return;
}

void FlyPath::Render()
{
gluLookAt(current.position[x], current.position[y], current.position[z],
current.look_at[x], current.look_at[y], current.look_at[z],
current.up[x], current.up[y], current.up[z]);

return;
}


As always, thanks in advance [Edited by - x452Alba on May 17, 2007 6:20:16 AM]