PDA

View Full Version : Bezier curves in OpenGL



Gobbo
03-01-2002, 01:35 AM
I'm including some bezier basis functions in an idle function callback, but it doesn't draw the curve as it should. It seems to completely ignore my second control point and over extend past the third. If anyone knows any good tutorials or sites on how to program curves, or if there are any suggestions, they are always grtefully recieved. Thanks.

void animation (void)
{
int temp;

anim += 0.5;

s += 0.001;
u += 0.001;

if ( u < 1 )
{
u = pow(3 * s, 2) - pow(2 * s, 3);

for ( temp=0; temp<3; temp++ )
{
points[count][temp] = p1[temp] * (pow((1-u), 3)) +
p2[temp] * ((3*u) * (pow(1-u, 2))) +
p3[temp] * (pow(3*u, 2)) * (1-u) +
p4[temp] * (pow( u, 3));
}

b = ((1-u) * colorIndexa) + (u * (colorIndexb));

count ++;
}

else
{
glutPostRedisplay();
}

glutPostRedisplay();
}