Does anyone have any suggestions to create an interpolating spline curve. I'm trying to develop a game in opengl and I can't get the objects to follow a curve. The function should go something like.....
void interpolatePath(Vec3d startPos, Vec3d targetPos, float u, Vec3d &interpPos)
The object starts at a position and the user clicks and the object moves to that point. I have it now so that the object goes in a straight line, but I want it to follow a curve.
Straight line code in above funciton:
//interpPos.x = (u)*targetPos.x+(1-u)*startPos.x;
//interpPos.y = (u)*targetPos.y+(1-u)*startPos.y;
//interpPos.z = (u)*targetPos.z+(1-u)*startPos.z;
Would a bezier curve work? How would I implement it?
[x,y]=(1–t)^3P0+3(1–t)^2tP1+3(1–t)t^2P2+t^3P3
Thank you