newsb

12-24-2011, 07:25 PM

Hi,

Noob question: I have a function that makes approx. 2400 (X,Y)-coordinates for a single tooth on a gear. In order for me to draw the whole gear, I rotate these 2400 points by 14 teeth = more than 30.000 points!

I connect them like this:

int skipPoints = 50;

for (int i=0; i<numRotations; i++)

{

glBegin(GL_LINE_STRIP);

for (int j=0; j< N_kontur; j=j+skipPoints)

glVertex2f( -allX[i][j], allY[i][j] ); // negative X-values

glEnd();

glBegin(GL_LINE_STRIP);

for (int j=0; j< N_kontur; j=j+skipPoints)

glVertex2f( allX[i][j], allY[i][j] ); // positive X-values

glEnd();

}

Finally, I tried to make the gear rotate using gluttimerfunc - BAD idea... The animation is "flashing", due to the high number of points. I then introduced "skipPoints" in the code above, and this kind of solves the flashing problem. My new problem is lack of detail:

Question: How do I interpolate my gear profile, maybe using splines/bezier curves/manipulators (?? whatever they're called) to draw the whole gear using only a fragment of the current (large) number of points?

I read a bit about it - I think I need to figure out the control points - or is there a better option?

Noob question: I have a function that makes approx. 2400 (X,Y)-coordinates for a single tooth on a gear. In order for me to draw the whole gear, I rotate these 2400 points by 14 teeth = more than 30.000 points!

I connect them like this:

int skipPoints = 50;

for (int i=0; i<numRotations; i++)

{

glBegin(GL_LINE_STRIP);

for (int j=0; j< N_kontur; j=j+skipPoints)

glVertex2f( -allX[i][j], allY[i][j] ); // negative X-values

glEnd();

glBegin(GL_LINE_STRIP);

for (int j=0; j< N_kontur; j=j+skipPoints)

glVertex2f( allX[i][j], allY[i][j] ); // positive X-values

glEnd();

}

Finally, I tried to make the gear rotate using gluttimerfunc - BAD idea... The animation is "flashing", due to the high number of points. I then introduced "skipPoints" in the code above, and this kind of solves the flashing problem. My new problem is lack of detail:

Question: How do I interpolate my gear profile, maybe using splines/bezier curves/manipulators (?? whatever they're called) to draw the whole gear using only a fragment of the current (large) number of points?

I read a bit about it - I think I need to figure out the control points - or is there a better option?