Hello,
I constructed my Object/Model in a DisplayList. Now i want to move this object along a bezier curve.
Here is my code for the curve:
void drawCurve(void) {
float pointsforcurve[4][3];
int i = 0;
glColor3f(1.0, 0.0, 0.0);
glLineWidth(2.0);
/* Converting 2i point array to 3f point array */
for (i = 0; i < 4; i++) {
pointsforcurve[i][0] = (float)points[i][0];
pointsforcurve[i][1] = (float)points[i][1];
pointsforcurve[i][2] = 0.0f;
}
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &pointsforcurve[0][0]);
glEnable(GL_MAP1_VERTEX_3);
glBegin(GL_LINE_STRIP);
for(i = 0; i < 100; i++) {
glEvalCoord1f((float)i/100.0f);
}
glEnd();
}
This code works fine for me, but I do not know, how to move my object alonge the curve, because the gl EvalCoord function do not return the point of the curve.
In order to move it along, i need the coords of the curvepoints, to make something like this:
glTranslatef(xofcurvepoint, yofcurvepoint, zofcurvepoint);
glCallList(listForkLifter);
Can someone help me? Or is there a better way to do it?
thx Alexander