Sign in to follow this  

FlyPath + up vectors

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

If you intended to correct an error in the post then please contact us.

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]

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this