// // Computergraphik II // Prof. Dr. Juergen Doellner // Wintersemester 2001/02 // // Rahmenprogramm zu Aufgabenzettel 9 // #include "cgcontour.h" #include "vector.h" // degree of tessellation const int PATCHSIZE = 100; // range of x,z const double MINIMUM = -2.0; const double MAXIMUM = +2.0; const double SPAN = MAXIMUM - MINIMUM; const double DELTA = SPAN/(PATCHSIZE-1); // store values of the function bool calculationdone = false; double arPatch[PATCHSIZE][PATCHSIZE]; // correspending normals Vector arNormals[PATCHSIZE][PATCHSIZE]; CGContour::CGContour() { run_ = false; normals_ = false; zoom_ = 0.4; } CGContour::~CGContour() { } void CGContour::drawScene() { glPushMatrix(); glRotated(30, 1.0, 0.0, 0.0); glScaled(zoom_, zoom_, zoom_); // Achsen glLineWidth(3.0); glColor3f(0.0, 0.0, 0.0); glDisable(GL_LIGHTING); glBegin(GL_LINES); glVertex3f( 0.0, 0.0, 0.0); glVertex3f( 3.0, 0.0, 0.0); glVertex3f( 0.0, 0.0, 0.0); glVertex3f( 0.0, 6.0, 0.0); glVertex3f( 0.0, 0.0, 0.0); glVertex3f( 0.0, 0.0, 3.0); glEnd(); glEnable(GL_LIGHTING); // Licht 1 static GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0}; // diffuse light static GLfloat light_position[]= {0.0, 1.0, 0.0, 0.0}; // infinite light location glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse ); glLightfv(GL_LIGHT1, GL_POSITION, light_position); // Funktion drawFunction(); glPopMatrix(); } void CGContour::drawFunction() { // Hier die Funktion zeichnen. // perform calculation only once if (!calculationdone) { for (int x=0; x