I have written a code for drawing a bezier curve in OpenGL 2.
for example this is my bezier curve that i have drawn:
i can setup my bezier by glMap1f() using my controlPoints and number of controlPoints (which is uOrder)
void MyBezierLine::setup(const GLfloat* controlPoints,
GLint uOrder)
{
controlpoints = controlPoints;
uorder = uOrder;
//setup the bezier
glMap1f(GL_MAP1_VERTEX_3, //to be generated data
0.0f, //lower u range
1.0f, //higher u range
3, //u control point stride in array
uorder, //order of u or number of u control point
controlpoints); //the control points array
//enabling bezier evaluator
glEnable(GL_MAP1_VERTEX_3);
}
and i can simply draw them by glMapGrid1f() and glEvalMesh1().
void MyBezierLine::draw(GLenum draw_mode, //GL_LINE or GL_POINT
GLint ures)
{
//setting the 1D grid map containing ures points
//map to u range 0.0 - 1.0
glMapGrid1f(ures, 0.0f, 1.0f);
//evaluate the bezier surface
glEvalMesh1(draw_mode, 0, ures);
}
what i want to do is try to move an object along this bezier curve which has drawn by purple color.
based on what i have searched over internet, it looks like i have to write the function and calculate the bezier curve by myself to get the position of each point on the line. despite of that, i have to evaluate the rotation of the object based on the position of each point.
do you have any proper way or idea about how can i do this ?