void TranslationCatmull::glTranslate() { static float up[3] = { 0.0, 1.0, 0.0 }; float res[3], dir[3], left[3], m[16]; float now = glutGet(GLUT_ELAPSED_TIME); float timeMiliSeconds = time * 1000; float t = fmod(now, timeMiliSeconds) / timeMiliSeconds; getGlobalCatmullRomPoint(t, res); getGlobalCatmullRomDirection(t, dir); drawCatmullRomCurve(); glTranslatef(res[0], res[1], res[2]); }
void TranslationCatmull::loadCatmullRomCurve() { float res[3], t; vector<float> p; for (t = 0; t < 1; t += 0.001) { getGlobalCatmullRomPoint(t, res); p.push_back(res[0]); p.push_back(res[1]); p.push_back(res[2]); } glBindBuffer(GL_ARRAY_BUFFER, coordinatesID); glBufferData(GL_ARRAY_BUFFER, p.size() * sizeof(float), &p.front(), GL_STATIC_DRAW); }
void renderCatmullRomCurve(float** p, int point_count) { // desenhar a curva usando segmentos de reta - GL_LINE_LOOP float n_pontos = 100; float res[3]; float inc = 1 / n_pontos; float f = 0; glDisable(GL_LIGHTING); glColor3f(0.5, 0.5, 0.5); glBegin(GL_LINE_LOOP); for (int a = 0; a < n_pontos; a++) { f += inc; getGlobalCatmullRomPoint(p,point_count, f, res); glVertex3fv(res); } glEnd(); glEnable(GL_LIGHTING); }