diff --git a/sources/array.cpp b/sources/array.cpp new file mode 100755 index 0000000..f8c6156 --- /dev/null +++ b/sources/array.cpp @@ -0,0 +1,124 @@ +#include + +class Array { +private: + int _size; + int _current; + int _stacksize; + void** _data; +public: + Array() { + _size = 0; + _current = 0; + _stacksize = 0; + } + + Array(Array* oa) { + _size = 0; + _current = 0; + _stacksize = 0; + void* telem; + int tc = oa->pos(); + oa->reset(); + + while ( (telem = oa->next()) ) { + push(telem); + } + + oa->setPos(tc); + + } + + void setPos(int np) { + _current = np; + } + + int pos() { + return _current; + } + + int length() { + return _size; + } + + void reset() { + _current = 0; + } + + void* current() { + if ( _current < _size ) { + return _data[_current]; + } else { + return 0; + } + } + + void* next() { + if ( _current < _size ) { + _current++; + return _data[_current-1]; + } else { + return 0; + } + } + + void push(void* elem) { + if ( _size >= _stacksize ) { + _stacksize = _stacksize + 3; + void** tdat = new void*[_stacksize]; + + for ( int i = 0; i < _size; i++ ) { + tdat[i] = _data[i]; + } + + if ( _size > 0 ) { + delete[] _data; + } + _data = tdat; + } + + _data[_size] = elem; + _size++; + } + + void* pop() { + _size--; + if ( _current == _size ) { + _current = _size-1; + } + return _data[_size]; + } + + void* get(int p) { + assert(p>=0); + assert(p<_size); + return _data[p]; + } + + void set(int p, void* ne) { + assert(p>=0); + assert(p<_size); + _data[p] = ne; + } + + void clear() { + _size = 0; + _current = 0; + _stacksize = 0; + delete[] _data; + } + + void operator+=(void* ne) { + push(ne); + } + + void*& operator[](int p) { + assert(p>=0); + assert(p<_size); + return _data[p]; + } + + ~Array() { + delete[] _data; + } +}; diff --git a/sources/main.cpp b/sources/main.cpp index 9ea5b45..1f11c94 100755 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -9,18 +9,31 @@ ////////////// // #INCLUDE // ////////////// + +#ifdef WIN32 #include // Only required under Windows :-D +#endif + #include // This file import the SDL inteface +#include // This file import the SDL inteface #include // This file import the OpenGL interface -#include // This file offers some OpenGL-related utilities +#include // This file offers some OpenGL-related utilities #include +#include +#include +#include + +#include +#include +#include #include +#ifdef WIN32 ///////////// // #PRAGMA // -///////////// +///////////// // Visual Studio specific: you can import libraries directly by // specifing them through a #pragma. On other compilters/platforms add // the required .lib to the makefile or project proprieties @@ -28,6 +41,11 @@ #pragma comment(lib, "glu32.lib") #pragma comment(lib, "sdl.lib") #pragma comment(lib, "sdlmain.lib") +#endif + +#include "array.cpp" + +using namespace std; ///////////// // #DEFINE // @@ -39,15 +57,23 @@ #define WINDOW_COLORDEPTH 32 // Color depth (in bits) #define WINDOW_ZETADEPTH 24 // z-buffer depth (in bits) -#define SURFACE_COUNT 6 +#define SURFACE_COUNT 6 #define PI 3.14159265f +#define DEBUG + +int debugct = 0; +int firstprint = 1; + +#define DD() do { printf("DD:%d\n", debugct); debugct++;} while(0); +#define DD1(x) while(firstprint) { printf("DD1: %d\n", x); firstprint = 0;}; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// CLASSES +// CLASSES + class Color { @@ -59,7 +85,7 @@ r = _r; g = _g; b = _b; - } + } void drawColor() { glColor4f(r, g, b, 1.0f); @@ -101,10 +127,15 @@ return c; } - Vec operator+(Vec& v) { + Vec operator+(Vec* v) { + return Vec(x() + v->x(), y() + v->y(), z() + v->z()); + } + + Vec operator+(Vec v) { return Vec(x() + v.x(), y() + v.y(), z() + v.z()); } + void add(Vec& a) { c[0] += a.x(); c[1] += a.y(); @@ -121,18 +152,17 @@ } Vec operator*(Vec& s) { - Vec r = Vec(x()*s.x(), y()*s.y(), z()*s.z()); + return Vec(x()*s.x(), y()*s.y(), z()*s.z()); } Vec operator/(float s) { - Vec r = Vec(x()/s, y()/s, z()/s); - return r; + return Vec(x()/s, y()/s, z()/s); } - Vec cross(Vec& v) { - return Vec(y() * v.z() - z() * v.y(), - z() * v.x() - x() * v.z(), - x() * v.y() - y() * v.x()); + Vec cross(Vec* v) { + return Vec(y() * v->z() - z() * v->y(), + z() * v->x() - x() * v->z(), + x() * v->y() - y() * v->x()); } Vec normalize() { @@ -155,7 +185,7 @@ class Poly { private: - Vec** initpoints; + Array* initpoints; int size; Vec* position; @@ -163,42 +193,36 @@ Color* color; public: - Poly(Vec** _points, int _size) { - //TODO constructor almost same as below - size = _size; - initpoints = _points; - - color = new Color (1,1,1); - - Vec c = calcCenter(); - setCenter(c); - - rotation = new Vec(0,0,0); + Poly(Array* _points) { + Poly(_points, Color(1,1,1)); } - Poly(Vec** _points, int _size, Color _color) { - size = _size; - initpoints = _points; - + Poly(Array* _points, Color _color) { + size = _points->length(); + position = new Vec(0,0,0); + rotation = new Vec(0,0,0); color = _color.clone(); - Vec c = calcCenter(); - setCenter(c); +#ifdef DEBUG + printf("new Poly(%d)\n", size); +#endif + initpoints = new Array(_points); - rotation = new Vec(0,0,0); + setCenter(calcCenter()); } ~Poly() { delete position; delete rotation; delete color; + delete initpoints; } - /* - * set the position where the (rotation-)center of + /* + * set the position where the (rotation-)center of * the polygon is located */ - void setCenter(Vec& c) { + void setCenter(Vec c) { delete position; position = c.clone(); } @@ -217,8 +241,10 @@ */ Vec calcCenter() { Vec s (0,0,0); - for (int i = 0; i < size; i++) { - s = s+*initpoints[i]; + Vec* t; + initpoints->reset(); + while ( t = (Vec*)initpoints->next() ) { + s = s+*t; } return s / ((float)size); } @@ -231,9 +257,11 @@ Vec diff = newcenter - (*position); delete position; position = newcenter.clone(); - for (int i = 0; i < size; i++) { - initpoints[i]->add(diff); - } + Vec* t; + initpoints->reset(); + while ( t = (Vec*)initpoints->next() ) { + t->add(diff); + } } //additional rotation in arcs @@ -244,42 +272,46 @@ Vec rotate_x(Vec& c) { Vec initrot = getInitRotation(c); Vec rot = initrot + *rotation; - float r = Vec(0, c.y(), c.z()).length(); + float r = Vec(0, c.y(), c.z()).length(); return Vec (c.x(), r*cos(rot.x()), r*sin(rot.x())); } Vec rotate_y(Vec& c) { Vec initrot = getInitRotation(c); Vec rot = initrot + *rotation; - float r = Vec(c.x(), 0, c.z()).length(); + float r = Vec(c.x(), 0, c.z()).length(); return Vec (r*sin(rot.y()), c.y(), r*cos(rot.y())); } Vec rotate_z(Vec& c) { Vec initrot = getInitRotation(c); Vec rot = initrot + *rotation; - float r = Vec(c.x(), c.y(), 0).length(); + float r = Vec(c.x(), c.y(), 0).length(); return Vec (r*cos(rot.z()), r*sin(rot.z()), c.z()); } - void draw() { - glBegin (GL_POLYGON); - - Vec v1 = *initpoints[2] - *initpoints[0]; - Vec v2 = *initpoints[1] - *initpoints[0]; - glNormal3fv( (v1.cross(v2)+ *initpoints[0]).c ); - - for (int v = 0; v < size; v++) { + void draw() { + glBegin (GL_POLYGON); + //Vec v1 = *((Vec*)initpoints->get(2)) - *((Vec*)initpoints->get(0)); + //Vec v2 = *((Vec*)initpoints->get(1)) - *((Vec*)initpoints->get(0)); + //glNormal3fv( v1.cross(v2)+ *(Vec*)((*initpoints)[0]).c ); + //glNormal3fv( v1.cross(v2) + ((Vec*)initpoints->get(0))->c ); + + Vec* t; + Vec* mv; + initpoints->reset(); + while ( (t = (Vec*)initpoints->next()) ) { color->drawColor(); - Vec out = (*initpoints[v] - *position); + Vec out = (*t - *position); out = rotate_x(out); out = rotate_y(out); out = rotate_z(out); - glVertex3fv((*position + out).c); - } + mv = (*position + out).clone(); + glVertex3fv(mv->c); + } glEnd(); - } + } }; @@ -299,7 +331,7 @@ glBegin (GL_LINES); glVertex3fv(pos->getCoords()); glVertex3fv(dir->getCoords()); - glEnd(); + glEnd(); } void draw() { @@ -314,16 +346,14 @@ class Model { private: - Poly** faces; - int size; + Array* faces; Vec* position; Vec* rotation; public: - Model(Poly** _faces, int _size) { - size = _size; - faces = _faces; + Model(Array* _faces) { + faces = new Array(*_faces); Vec c = calcCenter(); setCenter(c); rotation = new Vec(0,0,0); @@ -332,6 +362,7 @@ ~Model() { delete position; delete rotation; + delete faces; } void setCenter(Vec& c) { @@ -341,33 +372,37 @@ Vec calcCenter() { Vec s(0,0,0); - for ( int i = 0; i < size; i++ ) { - Vec c = faces[i]->calcCenter(); - s = s + c; - } - return s/((float)size); + Poly* t; + faces->reset(); + while ( t = (Poly*)faces->next() ) { + s = s + t->calcCenter(); + } + return s/((float)faces->length()); } void rotate(Vec rot) { rotation->add(rot); - for ( int i = 0; i < size; i++ ) { - faces[i]->rotate(rot); + faces->reset(); + Poly* t; + while ( t = (Poly*)faces->next() ) { + t->rotate(rot); } } void draw() { - for ( int i = 0; i draw(); + faces->reset(); + Poly* t; + while ( t = (Poly*)faces->next() ) { + t->draw(); } } void addFace(Poly* face) { - Poly** t = faces; - size++; - for ( int i = 0; i < size-1; i++ ) { - faces[i] = t[i]; - } - faces[size-1] = face; + faces->push(face); + } + + int numberOfFaces() { + return faces->length(); } }; @@ -376,58 +411,96 @@ /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// GLOBAL VARS +// GLOBAL VARS int MouseX, MouseY, OldMouseX, OldMouseY; bool MouseButtonRight, MouseButtonLeft; bool done = false; // Quit application when true -Model* importModel(char* fname) { - - FILE *fp; - char lbuf[200]; - char* buf2; - int numpoints = 0; - float tpf[3] = {0.0f, 0.0f, 0.0f}; - int* tp = NULL; - int tps = 0; - int cp = 0; - Vec** points; - Vec** tpoints; - Model* mm = new Model(NULL, 0); - Poly* tpp; - - - fp = fopen(fname, "r"); - - if ( fp == NULL ) { - printf("Error reading file %s\n", fname); +const char* getNextToken(string& line) { + if ( line.length() < 1 ) { return NULL; } - while( fgets(lbuf, sizeof(lbuf), fp) != NULL ) { - buf2 = strtok(lbuf, " "); - if ( buf2 == "v" ) { - numpoints++; - tpf[0] = (float)atof(strtok(lbuf, NULL)); - tpf[1] = (float)atof(strtok(lbuf, NULL)); - tpf[2] = (float)atof(strtok(lbuf, NULL)); - points[numpoints-1] = new Vec(tpf[0], tpf[1], tpf[2]); + string mp; + + while ( line[0] == ' ' ) { + line.erase(0, 1); + } + + int np = line.find(" ", 0); + + if ( (unsigned int)np == string::npos ) { + np = line.length(); + } + + mp = line.substr(0, np); + line.erase(0, np); + + return mp.c_str(); +} + +int getNextPoint(string& line) { + const char* tch; + tch = getNextToken(line); + if ( tch == NULL ) { + return -1; + } + return (int)atoi(tch); +} + +float getNextCoord(string& line) { + const char* tch; + tch = getNextToken(line); + if ( tch == NULL ) { + return -1; + } + return (float)atof(tch); +} + +Model* importModel(char* fname) { + + string line; + ifstream fp; + + Array* points = new Array(); + Array* tpoints = new Array(); + Model* mm = new Model(new Array()); + + int tp = -1; + + + fp.open(fname); + + if ( ! fp.is_open()) { + printf("Error reading file %s\n", fname); + return mm; + } + + while ( !fp.eof() ) { + getline(fp, line); + + if ( line[0] == 'v' ) { + line.erase(0,1); + points->push(new Vec(getNextCoord(line), getNextCoord(line), getNextCoord(line))); } - if ( buf2 == "f" ) { - tps = 0; - while ( (buf2 = strtok(lbuf, NULL)) != NULL ) { - cp = atoi(buf2); - tpoints[tps] = points[cp]->clone(); - tps++; + + if ( line[0] == 'f' ) { + line.erase(0,1); + + tpoints->clear(); + while ( (tp = getNextPoint(line)) > -1 ) { + tpoints->push(points->get(tp-1)); } - tpp = new Poly(tpoints, tps); - mm->addFace(tpp); + mm->addFace(new Poly(tpoints)); } } + fp.close(); - fclose(fp); + delete points; + delete tpoints; + return mm; } @@ -441,128 +514,163 @@ int main( int argc, char **argv ) { // Initialize SDL: - if (SDL_Init(SDL_INIT_VIDEO) == -1) + if (SDL_Init(SDL_INIT_VIDEO) == -1) { printf("ERROR: unable to init SDL!\n"); return 1; - } + } - Color white (1,1,1); - Color black (0,0,0); - Color red (1,0,0); - Color blue (0,0,1); - Color green (0,1,0); + Color black (0,0,0); + Color blue (0,0,1); + Color red (1,0,0); + Color violet (1,0,1); Color yellow (1,1,0); - - Vec p0 (0 ,0 ,0 ); - Vec p1 (10,0 ,0 ); - Vec p2 (10,10,0 ); - Vec p3 (0 ,10,0 ); + Color white (1,1,1); + Color green (0,1,0); + Color cyan (0,1,1); - Vec p4 (0 ,0 ,10); - Vec p5 (10,0 ,10); - Vec p6 (10,10,10); - Vec p7 (0 ,10,10); + Vec* p0 = new Vec(0 ,0 ,0 ); + Vec* p1 = new Vec(10,0 ,0 ); + Vec* p2 = new Vec(10,10,0 ); + Vec* p3 = new Vec(0 ,10,0 ); + + Vec* p4 = new Vec(0 ,0 ,10); + Vec* p5 = new Vec(10,0 ,10); + Vec* p6 = new Vec(10,10,10); + Vec* p7 = new Vec(0 ,10,10); Vec cen (5,5,5); - /*Rect surf [SURFACE_COUNT] = { - Rect (&p0, &p3, &p2, &p1, &red), - Rect (&p4, &p5, &p6, &p7, &blue), - Rect (&p4, &p0, &p1, &p5, &green), - Rect (&p2, &p3, &p7, &p6, &yellow), - Rect (&p1, &p2, &p6, &p5, &black), - Rect (&p3, &p0, &p4, &p7, &white) - };*/ + /* - Vec* pp0[4] = {&p0, &p3, &p2, &p1}; - Vec* pp1[4] = {&p4, &p5, &p6, &p7}; - Vec* pp2[4] = {&p4, &p0, &p1, &p5}; - Vec* pp3[4] = {&p2, &p3, &p7, &p6}; - Vec* pp4[4] = {&p1, &p2, &p6, &p5}; - Vec* pp5[4] = {&p3, &p0, &p4, &p7}; + 4---7 + |pp5| + 4---0---3---7---4 + |pp2|pp0|pp3|pp1| + 5---1---2---6---5 + |pp4| + 5---6 - Poly* polys [SURFACE_COUNT] = { - new Poly(pp0, 4, red), - new Poly(pp1, 4, green), - new Poly(pp2, 4, black), - new Poly(pp3, 4, blue), - new Poly(pp4, 4, yellow), - new Poly(pp5, 4), - }; + */ - Model* myModel = importModel("teapot.obj"); - - for (int x = 0; x < SURFACE_COUNT; x++) { - polys[x]->setCenter(cen); - } + Array* pp0 = new Array(); + pp0->push(p0); + pp0->push(p3); + pp0->push(p2); + pp0->push(p1); - //Vec* pp [4] = {&p0, &p3, &p2, &p1}; - //Poly poly0 (pp,4); + Array* pp1 = new Array(); + pp1->push(p4); + pp1->push(p5); + pp1->push(p6); + pp1->push(p7); + + Array* pp2 = new Array(); + pp2->push(p4); + pp2->push(p0); + pp2->push(p1); + pp2->push(p5); + + Array* pp3 = new Array(); + pp3->push(p2); + pp3->push(p3); + pp3->push(p7); + pp3->push(p6); + + Array* pp4 = new Array(); + pp4->push(p1); + pp4->push(p2); + pp4->push(p6); + pp4->push(p5); + + Array* pp5 = new Array(); + pp5->push(p3); + pp5->push(p0); + pp5->push(p4); + pp5->push(p7); + + Array* polys = new Array(); + polys->push(new Poly(pp0, red)); + polys->push(new Poly(pp1, green)); + polys->push(new Poly(pp2, cyan)); + polys->push(new Poly(pp3, blue)); + polys->push(new Poly(pp4, yellow)); + polys->push(new Poly(pp5, violet)); + + //Model* myModel = importModel("teapot.obj"); + // printf("imported teapot.obj : %d faces\n", myModel->numberOfFaces()); + + Poly* t; + polys->reset(); + while ( t = (Poly*)polys->next() ) { + //printf("polys %d setCenter\n", polys->pos()-1); + t->setCenter(cen); + } //light info - Vec pos0(10.0f, 12.0f, 15.0f); - Vec dir0(5.0f, 5.0f, 5.0f); + Vec pos0(-10.0f, 12.0f, 15.0f); + Vec dir0(5.0f, -5.0f, 5.0f); Light light0(&pos0, &dir0); - // Prepare configuration: + // Prepare configuration: int bitsPerColor = 8; - if (WINDOW_COLORDEPTH == 16) + if (WINDOW_COLORDEPTH == 16) bitsPerColor = 5; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, bitsPerColor); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, bitsPerColor); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bitsPerColor); - SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bitsPerColor); + SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0); - if (WINDOW_COLORDEPTH == 32) + SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0); + if (WINDOW_COLORDEPTH == 32) SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - else - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, WINDOW_ZETADEPTH); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - // Create surface: - unsigned flags = SDL_OPENGL; - SDL_WM_SetCaption(WINDOW_TITLE, NULL); - if (SDL_SetVideoMode(WINDOW_X, WINDOW_Y, WINDOW_COLORDEPTH, flags) == NULL) + else + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, WINDOW_ZETADEPTH); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + // Create surface: + unsigned flags = SDL_OPENGL; + SDL_WM_SetCaption(WINDOW_TITLE, NULL); + if (SDL_SetVideoMode(WINDOW_X, WINDOW_Y, WINDOW_COLORDEPTH, flags) == NULL) { printf("ERROR: unsupported video configuration!\n"); - return 1; + return 1; } - + // Ok, SDL up with a valid OpenGL context! // Now setup some OpenGL parameter: // Clear background with a darkblue color - glClearColor(0.0f, 0.0f, 0.5f, 1.0f); - + glClearColor(0.0f, 0.0f, 0.5f, 1.0f); + // correct clipping glEnable (GL_DEPTH_TEST); - + //enable light glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - + glEnable(GL_COLOR_MATERIAL); - + /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// - // Mainloop: - + // Mainloop: + float deltay = 0.0f; float deltaz = 0.0f; float deltacolor = 0.0f; - + + while (!done) - { +{ ///////////////////// // Do some rendering: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - + // Setup a perspective view: glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -570,39 +678,37 @@ WINDOW_X/WINDOW_Y, // width/height ratio 1.0f, // near clipping plane 1000.0f); // far clipping plane - + // Place the viewer 50 units backward: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -50.0f); - - // Draw a rotating triangle: - glRotatef(deltay, 0.0f, 1.0f, 0.0f); // Rotation around the Y axis - glRotatef(deltaz, 1.0f, 0.0f, 0.0f); - for (int i = 0; i < SURFACE_COUNT; i++) { - polys[i]->draw(); - polys[i]->rotate(Vec(0.0f, 0.01f, 0.01f)); + // Draw a rotating triangle: + glRotatef(deltay, 0.0f, 1.0f, 0.0f); // Rotation around the Y axis + glRotatef(deltaz, 1.0f, 0.0f, 0.0f); + + polys->reset(); + while ( t = (Poly*)polys->next() ) { + t->draw(); + t->rotate(Vec(0.0f, 0.01f, 0.01f)); } - //poly0.draw(); - //poly0.rotate(Vec(0.0, 0.01, 0.01)); - light0.draw(); light0.trace(); - + //myModel->draw(); //////////////// - // Check events: - SDL_Event event; - while (SDL_PollEvent(&event)) + // Check events: + SDL_Event event; + while (SDL_PollEvent(&event)) { // Quit by click on X: - if (event.type == SDL_QUIT) - done = true; - } - + if (event.type == SDL_QUIT) + done = true; + } + // Update mouse: OldMouseX = MouseX; OldMouseY = MouseY; @@ -611,27 +717,27 @@ MouseButtonLeft = true; else MouseButtonLeft = false; - if (buttons&SDL_BUTTON(3)) // <-- Beware: may be 2 on mouses + if (buttons&SDL_BUTTON(3)) // <-- Beware: may be 2 on mouses // without the middle button! MouseButtonRight = true; else - MouseButtonRight = false; - + MouseButtonRight = false; + //if (MouseButtonLeft) - // delta += 1.0f; - + // delta += 1.0f; + // Update keyboard (used like a joypad): Uint8 *keystate = SDL_GetKeyState(NULL); - if (keystate[SDLK_ESCAPE]) - done = true; + if (keystate[SDLK_ESCAPE]) + done = true; //background color if (keystate[SDLK_1]) glClearColor(0.5f, 0.0f, 0.0f, 1.0f); if (keystate[SDLK_2]) - glClearColor(0.0f, 0.5f, 0.0f, 1.0f); + glClearColor(0.0f, 0.5f, 0.0f, 1.0f); if (keystate[SDLK_3]) - glClearColor(0.0f, 0.0f, 0.5f, 1.0f); + glClearColor(0.0f, 0.0f, 0.5f, 1.0f); //scene rotation if (keystate[SDLK_LEFT]) @@ -646,15 +752,15 @@ //light rotation /* if (keystate[SDLK_a]) lightpos[0]+=lightdelta; - if (keystate[SDLK_d]) + if (keystate[SDLK_d]) lightpos[0]-=lightdelta; if (keystate[SDLK_w]) lightpos[1]+=lightdelta; - if (keystate[SDLK_s]) + if (keystate[SDLK_s]) lightpos[1]-=lightdelta; if (keystate[SDLK_q]) lightpos[2]+=lightdelta; - if (keystate[SDLK_e]) + if (keystate[SDLK_e]) lightpos[2]-=lightdelta; */ if (keystate[SDLK_SPACE]) { @@ -664,101 +770,19 @@ } } - - + + //////////////// // Swap buffers: - _sleep(20); // Just don't kill computer resources ;) - SDL_GL_SwapBuffers(); - + usleep(2000); // Just don't kill computer resources ;) + SDL_GL_SwapBuffers(); + // Plain stupid log, just to show values: - //printf("X: %d, Y: %d, but1: %d, but2: %d\n", + //printf("X: %d, Y: %d, but1: %d, but2: %d\n", // MouseX, MouseY, MouseButtonLeft, MouseButtonRight); } - + // Ok, release everything and byebye: SDL_Quit(); return 0; } -/* -//DEPRECATED -class Tri{ - public: - Vec *p[3]; - Color *col; - Vec *normal; - - Tri(Vec* p0, Vec* p1, Vec* p2, Color* c) { - p[0] = p0; - p[1] = p1; - p[2] = p2; - col = c; - Vec v1 = (*p[1] - *p[0]); - Vec v2 = (*p[2] - *p[0]); - normal = (v1).cross(v2); - } - - ~Tri() { - delete normal; - } - - void draw() { - glBegin (GL_TRIANGLES); - this->setNormal(); - col->setColor(); - for (int v = 0; v < 3; v++) { - glVertex3f(p[v]->c[0], p[v]->c[1], p[v]->c[2]); - } - glEnd(); - this->drawNormals(); - this->print(); - } - - void drawNormals() { - for (int v = 0; v < 3; v++) { - glBegin (GL_LINES); - glVertex3f(p[v]->x(), p[v]->y(), p[v]->z()); - //glVertex3fv(((*p[v])*scale).getCoords()); - glVertex3f(p[v]->x() + this->normal->x(), - p[v]->y() + this->normal->y(), - p[v]->z() + this->normal->z()); - //glVertex3fv(((*p[v])*scale + this->normal).getCoords()); - glEnd(); - } - } - - void setNormal() { - glNormal3fv(this->normal->getCoords()); - } - - void print() { - printf("triangle: \n"); - for (int v = 0; v < 3; v++) { - p[v]->print(); - } - printf("normal: "); - normal->print(); - printf("\n"); - } -}; - - -//DEPRECATED -class Rect { - public: - Tri* t1; - Tri* t2; - Rect(Vec* p1, Vec* p2, Vec* p3, Vec* p4, Color* c) { - t1 = new Tri (p1, p2, p3, c); - t2 = new Tri (p1, p3, p4, c); - } - ~Rect() { - delete t1; - delete t2; - } - void draw() { - t1->draw(); - t2->draw(); - } -}; -*/ diff --git a/teapot.obj b/teapot.obj new file mode 100755 index 0000000..0df7408 --- /dev/null +++ b/teapot.obj @@ -0,0 +1,1532 @@ +# Max2Obj Version 4.0 Mar 10th, 2001 +# +# object Teapot01 to come ... +# +v 32.631016 59.222961 0.000000 +v 32.149059 61.044758 0.000000 +v 32.708130 61.652023 0.000000 +v 33.845551 61.044758 0.000000 +v 35.098640 59.222961 0.000000 +v 29.953646 59.222961 13.559590 +v 29.509041 61.044758 13.370422 +v 30.024784 61.652023 13.589856 +v 31.074053 61.044758 14.036295 +v 32.230026 59.222961 14.528132 +v 22.612467 59.222961 24.528175 +v 22.270277 61.044758 24.185986 +v 22.667217 61.652023 24.582926 +v 23.474787 61.044758 25.390495 +v 24.364479 59.222961 26.280188 +v 11.643882 59.222961 31.869354 +v 11.454714 61.044758 31.424749 +v 11.674148 61.652023 31.940493 +v 12.120586 61.044758 32.989761 +v 12.612424 59.222961 34.145737 +v -1.915709 59.222961 34.546726 +v -1.915709 61.044758 34.064770 +v -1.915709 61.652023 34.623840 +v -1.915709 61.044758 35.761261 +v -1.915709 59.222961 37.014351 +v -16.412226 59.222961 31.869354 +v -15.681396 61.044758 31.424749 +v -15.622682 61.652023 31.940493 +v -15.966643 61.044758 32.989761 +v -16.443842 59.222961 34.145737 +v -27.276709 59.222961 24.528175 +v -26.453043 61.044758 24.185986 +v -26.602737 61.652023 24.582926 +v -27.319214 61.044758 25.390495 +v -28.195896 59.222961 26.280188 +v -34.097374 59.222961 13.559590 +v -33.472214 61.044758 13.370422 +v -33.895241 61.652023 13.589856 +v -34.910351 61.044758 14.036295 +v -36.061447 59.222961 14.528132 +v -36.462437 59.222961 0.000000 +v -35.980480 61.044758 0.000000 +v -36.539551 61.652023 0.000000 +v -37.676971 61.044758 0.000000 +v -38.930061 59.222961 0.000000 +v -33.785065 59.222961 -13.559590 +v -33.340458 61.044758 -13.370422 +v -33.856201 61.652023 -13.589856 +v -34.905472 61.044758 -14.036295 +v -36.061447 59.222961 -14.528132 +v -26.443884 59.222961 -24.528175 +v -26.101694 61.044758 -24.185986 +v -26.498634 61.652023 -24.582926 +v -27.306204 61.044758 -25.390495 +v -28.195896 59.222961 -26.280188 +v -15.475299 59.222961 -31.869354 +v -15.286131 61.044758 -31.424749 +v -15.505565 61.652023 -31.940493 +v -15.952003 61.044758 -32.989761 +v -16.443842 59.222961 -34.145737 +v -1.915709 59.222961 -34.546726 +v -1.915709 61.044758 -34.064770 +v -1.915709 61.652023 -34.623840 +v -1.915709 61.044758 -35.761261 +v -1.915709 59.222961 -37.014351 +v 11.643882 59.222961 -31.869354 +v 11.454714 61.044758 -31.424749 +v 11.674148 61.652023 -31.940493 +v 12.120586 61.044758 -32.989761 +v 12.612424 59.222961 -34.145737 +v 22.612467 59.222961 -24.528175 +v 22.270277 61.044758 -24.185986 +v 22.667217 61.652023 -24.582926 +v 23.474787 61.044758 -25.390495 +v 24.364479 59.222961 -26.280188 +v 29.953646 59.222961 -13.559590 +v 29.509041 61.044758 -13.370422 +v 30.024784 61.652023 -13.589856 +v 31.074053 61.044758 -14.036295 +v 32.230026 59.222961 -14.528132 +v 39.629044 49.535614 0.000000 +v 43.581093 40.021767 0.000000 +v 46.376450 30.854931 0.000000 +v 47.436756 22.208609 0.000000 +v 36.409325 49.535614 16.306314 +v 40.055092 40.021767 17.857496 +v 42.633808 30.854931 18.954674 +v 43.611942 22.208609 19.370844 +v 27.581066 49.535614 29.496775 +v 30.387022 40.021767 32.302731 +v 32.371723 30.854931 34.287434 +v 33.124538 22.208609 35.040249 +v 14.390606 49.535614 38.325035 +v 15.941788 40.021767 41.970802 +v 17.038965 30.854931 44.549519 +v 17.455135 22.208609 45.527653 +v -1.915709 49.535614 41.544754 +v -1.915709 40.021767 45.496803 +v -1.915709 30.854931 48.292160 +v -1.915709 22.208609 49.352467 +v -18.222023 49.535614 38.325035 +v -19.773205 40.021767 41.970802 +v -20.870382 30.854931 44.549519 +v -21.286552 22.208609 45.527653 +v -31.412483 49.535614 29.496775 +v -34.218441 40.021767 32.302731 +v -36.203144 30.854931 34.287434 +v -36.955959 22.208609 35.040249 +v -40.240746 49.535614 16.306314 +v -43.886513 40.021767 17.857496 +v -46.465229 30.854931 18.954674 +v -47.443363 22.208609 19.370844 +v -43.460464 49.535614 0.000000 +v -47.412514 40.021767 0.000000 +v -50.207870 30.854931 0.000000 +v -51.268177 22.208609 0.000000 +v -40.240746 49.535614 -16.306314 +v -43.886513 40.021767 -17.857496 +v -46.465229 30.854931 -18.954674 +v -47.443363 22.208609 -19.370844 +v -31.412483 49.535614 -29.496775 +v -34.218441 40.021767 -32.302731 +v -36.203144 30.854931 -34.287434 +v -36.955959 22.208609 -35.040249 +v -18.222023 49.535614 -38.325035 +v -19.773205 40.021767 -41.970802 +v -20.870382 30.854931 -44.549519 +v -21.286552 22.208609 -45.527653 +v -1.915709 49.535614 -41.544754 +v -1.915709 40.021767 -45.496803 +v -1.915709 30.854931 -48.292160 +v -1.915709 22.208609 -49.352467 +v 14.390606 49.535614 -38.325035 +v 15.941788 40.021767 -41.970802 +v 17.038965 30.854931 -44.549519 +v 17.455135 22.208609 -45.527653 +v 27.581066 49.535614 -29.496775 +v 30.387022 40.021767 -32.302731 +v 32.371723 30.854931 -34.287434 +v 33.124538 22.208609 -35.040249 +v 36.409325 49.535614 -16.306314 +v 40.055092 40.021767 -17.857496 +v 42.633808 30.854931 -18.954674 +v 43.611942 22.208609 -19.370844 +v 45.508926 14.892492 0.000000 +v 41.267696 9.484926 0.000000 +v 37.026470 5.812409 0.000000 +v 35.098640 3.701435 0.000000 +v 41.833515 14.892492 18.614170 +v 37.920982 9.484926 16.949488 +v 34.008450 5.812409 15.284806 +v 32.230026 3.701435 14.528132 +v 31.755781 14.892492 33.671490 +v 28.744511 9.484926 30.660219 +v 25.733240 5.812409 27.648949 +v 24.364479 3.701435 26.280188 +v 16.698462 14.892492 43.749226 +v 15.033779 9.484926 39.836693 +v 13.369098 5.812409 35.924160 +v 12.612424 3.701435 34.145737 +v -1.915709 14.892492 47.424637 +v -1.915709 9.484926 43.183407 +v -1.915709 5.812409 38.942181 +v -1.915709 3.701435 37.014351 +v -20.529879 14.892492 43.749226 +v -18.865196 9.484926 39.836693 +v -17.200516 5.812409 35.924160 +v -16.443842 3.701435 34.145737 +v -35.587200 14.892492 33.671490 +v -32.575928 9.484926 30.660219 +v -29.564657 5.812409 27.648949 +v -28.195896 3.701435 26.280188 +v -45.664936 14.892492 18.614170 +v -41.752403 9.484926 16.949488 +v -37.839870 5.812409 15.284806 +v -36.061447 3.701435 14.528132 +v -49.340347 14.892492 0.000000 +v -45.099117 9.484926 0.000000 +v -40.857891 5.812409 0.000000 +v -38.930061 3.701435 0.000000 +v -45.664936 14.892492 -18.614170 +v -41.752403 9.484926 -16.949488 +v -37.839870 5.812409 -15.284806 +v -36.061447 3.701435 -14.528132 +v -35.587200 14.892492 -33.671490 +v -32.575928 9.484926 -30.660219 +v -29.564657 5.812409 -27.648949 +v -28.195896 3.701435 -26.280188 +v -20.529879 14.892492 -43.749226 +v -18.865196 9.484926 -39.836693 +v -17.200516 5.812409 -35.924160 +v -16.443842 3.701435 -34.145737 +v -1.915709 14.892492 -47.424637 +v -1.915709 9.484926 -43.183407 +v -1.915709 5.812409 -38.942181 +v -1.915709 3.701435 -37.014351 +v 16.698462 14.892492 -43.749226 +v 15.033779 9.484926 -39.836693 +v 13.369098 5.812409 -35.924160 +v 12.612424 3.701435 -34.145737 +v 31.755781 14.892492 -33.671490 +v 28.744511 9.484926 -30.660219 +v 25.733240 5.812409 -27.648949 +v 24.364479 3.701435 -26.280188 +v 41.833515 14.892492 -18.614170 +v 37.920982 9.484926 -16.949488 +v 34.008450 5.812409 -15.284806 +v 32.230026 3.701435 -14.528132 +v 34.260033 2.342314 0.000000 +v 29.777828 1.156698 0.000000 +v 18.702440 0.318092 0.000000 +v -1.915709 0.000000 0.000000 +v 31.456415 2.342314 14.198979 +v 27.321579 1.156698 12.439713 +v 17.104534 0.318092 8.092624 +v 23.769068 2.342314 25.684776 +v 20.586702 1.156698 22.502411 +v 12.723177 0.318092 14.638885 +v 12.283271 2.342314 33.372124 +v 10.524005 1.156698 29.237288 +v 6.176915 0.318092 19.020243 +v -1.915709 2.342314 36.175743 +v -1.915709 1.156698 31.693537 +v -1.915709 0.318092 20.618149 +v -16.114689 2.342314 33.372124 +v -14.355422 1.156698 29.237288 +v -10.008332 0.318092 19.020243 +v -27.600485 2.342314 25.684776 +v -24.418119 1.156698 22.502411 +v -16.554594 0.318092 14.638885 +v -35.287834 2.342314 14.198979 +v -31.152996 1.156698 12.439713 +v -20.935951 0.318092 8.092624 +v -38.091454 2.342314 0.000000 +v -33.609245 1.156698 0.000000 +v -22.533857 0.318092 0.000000 +v -35.287834 2.342314 -14.198979 +v -31.152996 1.156698 -12.439713 +v -20.935951 0.318092 -8.092624 +v -27.600485 2.342314 -25.684776 +v -24.418119 1.156698 -22.502411 +v -16.554594 0.318092 -14.638885 +v -16.114689 2.342314 -33.372124 +v -14.355422 1.156698 -29.237288 +v -10.008332 0.318092 -19.020243 +v -1.915709 2.342314 -36.175743 +v -1.915709 1.156698 -31.693537 +v -1.915709 0.318092 -20.618149 +v 12.283271 2.342314 -33.372124 +v 10.524005 1.156698 -29.237288 +v 6.176915 0.318092 -19.020243 +v 23.769068 2.342314 -25.684776 +v 20.586702 1.156698 -22.502411 +v 12.723177 0.318092 -14.638885 +v 31.456415 2.342314 -14.198979 +v 27.321579 1.156698 -12.439713 +v 17.104534 0.318092 -8.092624 +v -41.397686 49.969376 0.000000 +v -52.926113 49.882622 0.000000 +v -61.447121 49.275356 0.000000 +v -66.729385 47.627060 0.000000 +v -68.541542 44.417217 0.000000 +v -41.012119 50.836899 4.164114 +v -53.269508 50.736588 4.164114 +v -62.266449 50.034439 4.164114 +v -67.807762 48.128597 4.164114 +v -69.698242 44.417217 4.164114 +v -40.163872 52.745449 5.552153 +v -54.024971 52.615322 5.552153 +v -64.068970 51.704422 5.552153 +v -70.180199 49.231976 5.552153 +v -72.242973 44.417217 5.552153 +v -39.315628 54.653999 4.164114 +v -54.780445 54.494053 4.164114 +v -65.871490 53.374401 4.164114 +v -72.552635 50.335361 4.164114 +v -74.787712 44.417217 4.164114 +v -38.930061 55.521526 0.000000 +v -55.123840 55.348022 0.000000 +v -66.690826 54.133484 0.000000 +v -73.631012 50.836899 0.000000 +v -75.944412 44.417217 0.000000 +v -39.315628 54.653999 -4.164114 +v -54.780445 54.494053 -4.164114 +v -65.871490 53.374401 -4.164114 +v -72.552635 50.335361 -4.164114 +v -74.787712 44.417217 -4.164114 +v -40.163872 52.745449 -5.552153 +v -54.024971 52.615322 -5.552153 +v -64.068970 51.704422 -5.552153 +v -70.180199 49.231976 -5.552153 +v -72.242973 44.417217 -5.552153 +v -41.012119 50.836899 -4.164114 +v -53.269508 50.736588 -4.164114 +v -62.266449 50.034439 -4.164114 +v -67.807762 48.128597 -4.164114 +v -69.698242 44.417217 -4.164114 +v -67.577629 39.385582 0.000000 +v -64.531647 33.312916 0.000000 +v -59.172283 27.240250 0.000000 +v -51.268177 22.208609 0.000000 +v -68.628899 38.899860 4.164114 +v -65.278679 32.571907 4.164114 +v -59.434349 26.325283 4.164114 +v -50.882610 21.051910 4.164114 +v -70.941689 37.831268 5.552153 +v -66.922165 30.941683 5.552153 +v -60.010891 24.312355 5.552153 +v -50.034367 18.507175 5.552153 +v -73.254486 36.762680 4.164114 +v -68.565636 29.311460 4.164114 +v -60.587433 22.299429 4.164114 +v -49.186119 15.962439 4.164114 +v -74.305756 36.276955 0.000000 +v -69.312675 28.570450 0.000000 +v -60.849499 21.384462 0.000000 +v -48.800552 14.805740 0.000000 +v -73.254486 36.762680 -4.164114 +v -68.565636 29.311460 -4.164114 +v -60.587433 22.299429 -4.164114 +v -49.186119 15.962439 -4.164114 +v -70.941689 37.831268 -5.552153 +v -66.922165 30.941683 -5.552153 +v -60.010891 24.312355 -5.552153 +v -50.034367 18.507175 -5.552153 +v -68.628899 38.899860 -4.164114 +v -65.278679 32.571907 -4.164114 +v -59.434349 26.325283 -4.164114 +v -50.882610 21.051910 -4.164114 +v 40.033886 35.163631 0.000000 +v 51.870766 37.881874 0.000000 +v 56.998798 44.417217 0.000000 +v 59.813431 52.340603 0.000000 +v 64.710121 59.222961 0.000000 +v 40.033886 31.982710 9.161052 +v 52.774437 35.523293 8.271840 +v 58.155495 43.043640 6.315574 +v 61.223160 51.843586 4.359307 +v 67.023514 59.222961 3.470095 +v 40.033886 24.984688 12.214736 +v 54.762512 30.334417 11.029119 +v 60.700230 40.021767 8.420765 +v 64.324554 50.750145 5.812409 +v 72.112991 59.222961 4.626794 +v 40.033886 17.986662 9.161052 +v 56.750587 25.145538 8.271840 +v 63.244965 36.999893 6.315574 +v 67.425949 49.656704 4.359307 +v 77.202461 59.222961 3.470095 +v 40.033886 14.805740 0.000000 +v 57.654259 22.786961 0.000000 +v 64.401665 35.626312 0.000000 +v 68.835678 49.159687 0.000000 +v 79.515862 59.222961 0.000000 +v 40.033886 17.986662 -9.161052 +v 56.750587 25.145538 -8.271840 +v 63.244965 36.999893 -6.315574 +v 67.425949 49.656704 -4.359307 +v 77.202461 59.222961 -3.470095 +v 40.033886 24.984688 -12.214736 +v 54.762512 30.334417 -11.029119 +v 60.700230 40.021767 -8.420765 +v 64.324554 50.750145 -5.812409 +v 72.112991 59.222961 -4.626794 +v 40.033886 31.982710 -9.161052 +v 52.774437 35.523293 -8.271840 +v 58.155495 43.043640 -6.315574 +v 61.223160 51.843586 -4.359307 +v 67.023514 59.222961 -3.470095 +v 66.483719 60.263988 0.000000 +v 67.794647 60.610996 0.000000 +v 68.180214 60.263988 0.000000 +v 67.177742 59.222961 0.000000 +v 68.961288 60.314819 3.253214 +v 70.120094 60.692326 2.776076 +v 70.154739 60.335155 2.298938 +v 68.720009 59.222961 2.082057 +v 74.411926 60.426651 4.337619 +v 75.236076 60.871254 3.701435 +v 74.498680 60.491714 3.065251 +v 72.112991 59.222961 2.776076 +v 79.862572 60.538479 3.253214 +v 80.352058 61.050182 2.776076 +v 78.842621 60.648277 2.298938 +v 75.505974 59.222961 2.082057 +v 82.340134 60.589310 0.000000 +v 82.677505 61.131512 0.000000 +v 80.817146 60.719444 0.000000 +v 77.048241 59.222961 0.000000 +v 79.862572 60.538479 -3.253214 +v 80.352058 61.050182 -2.776076 +v 78.842621 60.648277 -2.298938 +v 75.505974 59.222961 -2.082057 +v 74.411926 60.426651 -4.337619 +v 75.236076 60.871254 -3.701435 +v 74.498680 60.491714 -3.065251 +v 72.112991 59.222961 -2.776076 +v 68.961288 60.314819 -3.253214 +v 70.120094 60.692326 -2.776076 +v 70.154739 60.335155 -2.298938 +v 68.720009 59.222961 -2.082057 +v -1.915709 77.730141 0.000000 +v 6.489634 76.515602 0.000000 +v 6.104068 73.566025 0.000000 +v 2.942425 69.922424 0.000000 +v 3.019538 66.625832 0.000000 +v 5.841147 76.515602 3.307880 +v 5.485137 73.566025 3.155570 +v 2.566896 69.922424 1.909745 +v 2.637057 66.625832 1.937084 +v 4.059892 76.515602 5.975601 +v 3.785272 73.566025 5.700981 +v 1.536169 69.922424 3.451877 +v 1.588316 66.625832 3.504025 +v 1.392171 76.515602 7.756856 +v 1.239861 73.566025 7.400846 +v -0.005964 69.922424 4.482605 +v 0.021376 66.625832 4.552765 +v -1.915709 76.515602 8.405342 +v -1.915709 73.566025 8.019776 +v -1.915709 69.922424 4.858134 +v -1.915709 66.625832 4.935247 +v -5.223589 76.515602 7.756856 +v -5.071279 73.566025 7.400846 +v -3.825454 69.922424 4.482605 +v -3.852793 66.625832 4.552765 +v -7.891310 76.515602 5.975601 +v -7.616690 73.566025 5.700981 +v -5.367586 69.922424 3.451877 +v -5.419734 66.625832 3.504025 +v -9.672565 76.515602 3.307880 +v -9.316554 73.566025 3.155570 +v -6.398314 69.922424 1.909745 +v -6.468474 66.625832 1.937084 +v -10.321051 76.515602 0.000000 +v -9.935485 73.566025 0.000000 +v -6.773843 69.922424 0.000000 +v -6.850956 66.625832 0.000000 +v -9.672565 76.515602 -3.307880 +v -9.316554 73.566025 -3.155570 +v -6.398314 69.922424 -1.909745 +v -6.468474 66.625832 -1.937084 +v -7.891310 76.515602 -5.975601 +v -7.616690 73.566025 -5.700981 +v -5.367586 69.922424 -3.451877 +v -5.419734 66.625832 -3.504025 +v -5.223589 76.515602 -7.756856 +v -5.071279 73.566025 -7.400846 +v -3.825454 69.922424 -4.482605 +v -3.852793 66.625832 -4.552765 +v -1.915709 76.515602 -8.405342 +v -1.915709 73.566025 -8.019776 +v -1.915709 69.922424 -4.858134 +v -1.915709 66.625832 -4.935247 +v 1.392171 76.515602 -7.756856 +v 1.239861 73.566025 -7.400846 +v -0.005964 69.922424 -4.482605 +v 0.021376 66.625832 -4.552765 +v 4.059892 76.515602 -5.975601 +v 3.785272 73.566025 -5.700981 +v 1.536169 69.922424 -3.451877 +v 1.588316 66.625832 -3.504025 +v 5.841147 76.515602 -3.307880 +v 5.485137 73.566025 -3.155570 +v 2.566896 69.922424 -1.909745 +v 2.637057 66.625832 -1.937084 +v 9.342822 64.428108 0.000000 +v 18.442184 62.924393 0.000000 +v 26.616186 61.420689 0.000000 +v 30.163393 59.222961 0.000000 +v 8.470286 64.428108 4.418973 +v 16.864447 62.924393 7.990472 +v 24.404964 61.420689 11.198768 +v 27.677263 59.222961 12.591047 +v 6.077848 64.428108 7.993557 +v 12.538395 62.924393 14.454103 +v 18.341936 61.420689 20.257645 +v 20.860455 59.222961 22.776163 +v 2.503265 64.428108 10.385995 +v 6.074763 62.924393 18.780155 +v 9.283059 61.420689 26.320673 +v 10.675339 59.222961 29.592972 +v -1.915709 64.428108 11.258531 +v -1.915709 62.924393 20.357893 +v -1.915709 61.420689 28.531895 +v -1.915709 59.222961 32.079102 +v -6.334682 64.428108 10.385995 +v -9.906181 62.924393 18.780155 +v -13.114476 61.420689 26.320673 +v -14.506756 59.222961 29.592972 +v -9.909266 64.428108 7.993557 +v -16.369812 62.924393 14.454103 +v -22.173353 61.420689 20.257645 +v -24.691872 59.222961 22.776163 +v -12.301703 64.428108 4.418973 +v -20.695864 62.924393 7.990472 +v -28.236382 61.420689 11.198768 +v -31.508680 59.222961 12.591047 +v -13.174239 64.428108 0.000000 +v -22.273602 62.924393 0.000000 +v -30.447603 61.420689 0.000000 +v -33.994812 59.222961 0.000000 +v -12.301703 64.428108 -4.418973 +v -20.695864 62.924393 -7.990472 +v -28.236382 61.420689 -11.198768 +v -31.508680 59.222961 -12.591047 +v -9.909266 64.428108 -7.993557 +v -16.369812 62.924393 -14.454103 +v -22.173353 61.420689 -20.257645 +v -24.691872 59.222961 -22.776163 +v -6.334682 64.428108 -10.385995 +v -9.906181 62.924393 -18.780155 +v -13.114476 61.420689 -26.320673 +v -14.506756 59.222961 -29.592972 +v -1.915709 64.428108 -11.258531 +v -1.915709 62.924393 -20.357893 +v -1.915709 61.420689 -28.531895 +v -1.915709 59.222961 -32.079102 +v 2.503265 64.428108 -10.385995 +v 6.074763 62.924393 -18.780155 +v 9.283059 61.420689 -26.320673 +v 10.675339 59.222961 -29.592972 +v 6.077848 64.428108 -7.993557 +v 12.538395 62.924393 -14.454103 +v 18.341936 61.420689 -20.257645 +v 20.860455 59.222961 -22.776163 +v 8.470286 64.428108 -4.418973 +v 16.864447 62.924393 -7.990472 +v 24.404964 61.420689 -11.198768 +v 27.677263 59.222961 -12.591047 +# 530 vertices + +g Teapot01 +f 1 6 7 +f 7 2 1 +f 2 7 8 +f 8 3 2 +f 3 8 9 +f 9 4 3 +f 4 9 10 +f 10 5 4 +f 6 11 12 +f 12 7 6 +f 7 12 13 +f 13 8 7 +f 8 13 14 +f 14 9 8 +f 9 14 15 +f 15 10 9 +f 11 16 17 +f 17 12 11 +f 12 17 18 +f 18 13 12 +f 13 18 19 +f 19 14 13 +f 14 19 20 +f 20 15 14 +f 16 21 22 +f 22 17 16 +f 17 22 23 +f 23 18 17 +f 18 23 24 +f 24 19 18 +f 19 24 25 +f 25 20 19 +f 21 26 27 +f 27 22 21 +f 22 27 28 +f 28 23 22 +f 23 28 29 +f 29 24 23 +f 24 29 30 +f 30 25 24 +f 26 31 32 +f 32 27 26 +f 27 32 33 +f 33 28 27 +f 28 33 34 +f 34 29 28 +f 29 34 35 +f 35 30 29 +f 31 36 37 +f 37 32 31 +f 32 37 38 +f 38 33 32 +f 33 38 39 +f 39 34 33 +f 34 39 40 +f 40 35 34 +f 36 41 42 +f 42 37 36 +f 37 42 43 +f 43 38 37 +f 38 43 44 +f 44 39 38 +f 39 44 45 +f 45 40 39 +f 41 46 47 +f 47 42 41 +f 42 47 48 +f 48 43 42 +f 43 48 49 +f 49 44 43 +f 44 49 50 +f 50 45 44 +f 46 51 52 +f 52 47 46 +f 47 52 53 +f 53 48 47 +f 48 53 54 +f 54 49 48 +f 49 54 55 +f 55 50 49 +f 51 56 57 +f 57 52 51 +f 52 57 58 +f 58 53 52 +f 53 58 59 +f 59 54 53 +f 54 59 60 +f 60 55 54 +f 56 61 62 +f 62 57 56 +f 57 62 63 +f 63 58 57 +f 58 63 64 +f 64 59 58 +f 59 64 65 +f 65 60 59 +f 61 66 67 +f 67 62 61 +f 62 67 68 +f 68 63 62 +f 63 68 69 +f 69 64 63 +f 64 69 70 +f 70 65 64 +f 66 71 72 +f 72 67 66 +f 67 72 73 +f 73 68 67 +f 68 73 74 +f 74 69 68 +f 69 74 75 +f 75 70 69 +f 71 76 77 +f 77 72 71 +f 72 77 78 +f 78 73 72 +f 73 78 79 +f 79 74 73 +f 74 79 80 +f 80 75 74 +f 76 1 2 +f 2 77 76 +f 77 2 3 +f 3 78 77 +f 78 3 4 +f 4 79 78 +f 79 4 5 +f 5 80 79 +f 5 10 85 +f 85 81 5 +f 81 85 86 +f 86 82 81 +f 82 86 87 +f 87 83 82 +f 83 87 88 +f 88 84 83 +f 10 15 89 +f 89 85 10 +f 85 89 90 +f 90 86 85 +f 86 90 91 +f 91 87 86 +f 87 91 92 +f 92 88 87 +f 15 20 93 +f 93 89 15 +f 89 93 94 +f 94 90 89 +f 90 94 95 +f 95 91 90 +f 91 95 96 +f 96 92 91 +f 20 25 97 +f 97 93 20 +f 93 97 98 +f 98 94 93 +f 94 98 99 +f 99 95 94 +f 95 99 100 +f 100 96 95 +f 25 30 101 +f 101 97 25 +f 97 101 102 +f 102 98 97 +f 98 102 103 +f 103 99 98 +f 99 103 104 +f 104 100 99 +f 30 35 105 +f 105 101 30 +f 101 105 106 +f 106 102 101 +f 102 106 107 +f 107 103 102 +f 103 107 108 +f 108 104 103 +f 35 40 109 +f 109 105 35 +f 105 109 110 +f 110 106 105 +f 106 110 111 +f 111 107 106 +f 107 111 112 +f 112 108 107 +f 40 45 113 +f 113 109 40 +f 109 113 114 +f 114 110 109 +f 110 114 115 +f 115 111 110 +f 111 115 116 +f 116 112 111 +f 45 50 117 +f 117 113 45 +f 113 117 118 +f 118 114 113 +f 114 118 119 +f 119 115 114 +f 115 119 120 +f 120 116 115 +f 50 55 121 +f 121 117 50 +f 117 121 122 +f 122 118 117 +f 118 122 123 +f 123 119 118 +f 119 123 124 +f 124 120 119 +f 55 60 125 +f 125 121 55 +f 121 125 126 +f 126 122 121 +f 122 126 127 +f 127 123 122 +f 123 127 128 +f 128 124 123 +f 60 65 129 +f 129 125 60 +f 125 129 130 +f 130 126 125 +f 126 130 131 +f 131 127 126 +f 127 131 132 +f 132 128 127 +f 65 70 133 +f 133 129 65 +f 129 133 134 +f 134 130 129 +f 130 134 135 +f 135 131 130 +f 131 135 136 +f 136 132 131 +f 70 75 137 +f 137 133 70 +f 133 137 138 +f 138 134 133 +f 134 138 139 +f 139 135 134 +f 135 139 140 +f 140 136 135 +f 75 80 141 +f 141 137 75 +f 137 141 142 +f 142 138 137 +f 138 142 143 +f 143 139 138 +f 139 143 144 +f 144 140 139 +f 80 5 81 +f 81 141 80 +f 141 81 82 +f 82 142 141 +f 142 82 83 +f 83 143 142 +f 143 83 84 +f 84 144 143 +f 84 88 149 +f 149 145 84 +f 145 149 150 +f 150 146 145 +f 146 150 151 +f 151 147 146 +f 147 151 152 +f 152 148 147 +f 88 92 153 +f 153 149 88 +f 149 153 154 +f 154 150 149 +f 150 154 155 +f 155 151 150 +f 151 155 156 +f 156 152 151 +f 92 96 157 +f 157 153 92 +f 153 157 158 +f 158 154 153 +f 154 158 159 +f 159 155 154 +f 155 159 160 +f 160 156 155 +f 96 100 161 +f 161 157 96 +f 157 161 162 +f 162 158 157 +f 158 162 163 +f 163 159 158 +f 159 163 164 +f 164 160 159 +f 100 104 165 +f 165 161 100 +f 161 165 166 +f 166 162 161 +f 162 166 167 +f 167 163 162 +f 163 167 168 +f 168 164 163 +f 104 108 169 +f 169 165 104 +f 165 169 170 +f 170 166 165 +f 166 170 171 +f 171 167 166 +f 167 171 172 +f 172 168 167 +f 108 112 173 +f 173 169 108 +f 169 173 174 +f 174 170 169 +f 170 174 175 +f 175 171 170 +f 171 175 176 +f 176 172 171 +f 112 116 177 +f 177 173 112 +f 173 177 178 +f 178 174 173 +f 174 178 179 +f 179 175 174 +f 175 179 180 +f 180 176 175 +f 116 120 181 +f 181 177 116 +f 177 181 182 +f 182 178 177 +f 178 182 183 +f 183 179 178 +f 179 183 184 +f 184 180 179 +f 120 124 185 +f 185 181 120 +f 181 185 186 +f 186 182 181 +f 182 186 187 +f 187 183 182 +f 183 187 188 +f 188 184 183 +f 124 128 189 +f 189 185 124 +f 185 189 190 +f 190 186 185 +f 186 190 191 +f 191 187 186 +f 187 191 192 +f 192 188 187 +f 128 132 193 +f 193 189 128 +f 189 193 194 +f 194 190 189 +f 190 194 195 +f 195 191 190 +f 191 195 196 +f 196 192 191 +f 132 136 197 +f 197 193 132 +f 193 197 198 +f 198 194 193 +f 194 198 199 +f 199 195 194 +f 195 199 200 +f 200 196 195 +f 136 140 201 +f 201 197 136 +f 197 201 202 +f 202 198 197 +f 198 202 203 +f 203 199 198 +f 199 203 204 +f 204 200 199 +f 140 144 205 +f 205 201 140 +f 201 205 206 +f 206 202 201 +f 202 206 207 +f 207 203 202 +f 203 207 208 +f 208 204 203 +f 144 84 145 +f 145 205 144 +f 205 145 146 +f 146 206 205 +f 206 146 147 +f 147 207 206 +f 207 147 148 +f 148 208 207 +f 148 152 213 +f 213 209 148 +f 209 213 214 +f 214 210 209 +f 210 214 215 +f 215 211 210 +f 211 215 212 +f 152 156 216 +f 216 213 152 +f 213 216 217 +f 217 214 213 +f 214 217 218 +f 218 215 214 +f 215 218 212 +f 156 160 219 +f 219 216 156 +f 216 219 220 +f 220 217 216 +f 217 220 221 +f 221 218 217 +f 218 221 212 +f 160 164 222 +f 222 219 160 +f 219 222 223 +f 223 220 219 +f 220 223 224 +f 224 221 220 +f 221 224 212 +f 164 168 225 +f 225 222 164 +f 222 225 226 +f 226 223 222 +f 223 226 227 +f 227 224 223 +f 224 227 212 +f 168 172 228 +f 228 225 168 +f 225 228 229 +f 229 226 225 +f 226 229 230 +f 230 227 226 +f 227 230 212 +f 172 176 231 +f 231 228 172 +f 228 231 232 +f 232 229 228 +f 229 232 233 +f 233 230 229 +f 230 233 212 +f 176 180 234 +f 234 231 176 +f 231 234 235 +f 235 232 231 +f 232 235 236 +f 236 233 232 +f 233 236 212 +f 180 184 237 +f 237 234 180 +f 234 237 238 +f 238 235 234 +f 235 238 239 +f 239 236 235 +f 236 239 212 +f 184 188 240 +f 240 237 184 +f 237 240 241 +f 241 238 237 +f 238 241 242 +f 242 239 238 +f 239 242 212 +f 188 192 243 +f 243 240 188 +f 240 243 244 +f 244 241 240 +f 241 244 245 +f 245 242 241 +f 242 245 212 +f 192 196 246 +f 246 243 192 +f 243 246 247 +f 247 244 243 +f 244 247 248 +f 248 245 244 +f 245 248 212 +f 196 200 249 +f 249 246 196 +f 246 249 250 +f 250 247 246 +f 247 250 251 +f 251 248 247 +f 248 251 212 +f 200 204 252 +f 252 249 200 +f 249 252 253 +f 253 250 249 +f 250 253 254 +f 254 251 250 +f 251 254 212 +f 204 208 255 +f 255 252 204 +f 252 255 256 +f 256 253 252 +f 253 256 257 +f 257 254 253 +f 254 257 212 +f 208 148 209 +f 209 255 208 +f 255 209 210 +f 210 256 255 +f 256 210 211 +f 211 257 256 +f 257 211 212 +f 258 263 264 +f 264 259 258 +f 259 264 265 +f 265 260 259 +f 260 265 266 +f 266 261 260 +f 261 266 267 +f 267 262 261 +f 263 268 269 +f 269 264 263 +f 264 269 270 +f 270 265 264 +f 265 270 271 +f 271 266 265 +f 266 271 272 +f 272 267 266 +f 268 273 274 +f 274 269 268 +f 269 274 275 +f 275 270 269 +f 270 275 276 +f 276 271 270 +f 271 276 277 +f 277 272 271 +f 273 278 279 +f 279 274 273 +f 274 279 280 +f 280 275 274 +f 275 280 281 +f 281 276 275 +f 276 281 282 +f 282 277 276 +f 278 283 284 +f 284 279 278 +f 279 284 285 +f 285 280 279 +f 280 285 286 +f 286 281 280 +f 281 286 287 +f 287 282 281 +f 283 288 289 +f 289 284 283 +f 284 289 290 +f 290 285 284 +f 285 290 291 +f 291 286 285 +f 286 291 292 +f 292 287 286 +f 288 293 294 +f 294 289 288 +f 289 294 295 +f 295 290 289 +f 290 295 296 +f 296 291 290 +f 291 296 297 +f 297 292 291 +f 293 258 259 +f 259 294 293 +f 294 259 260 +f 260 295 294 +f 295 260 261 +f 261 296 295 +f 296 261 262 +f 262 297 296 +f 262 267 302 +f 302 298 262 +f 298 302 303 +f 303 299 298 +f 299 303 304 +f 304 300 299 +f 300 304 305 +f 305 301 300 +f 267 272 306 +f 306 302 267 +f 302 306 307 +f 307 303 302 +f 303 307 308 +f 308 304 303 +f 304 308 309 +f 309 305 304 +f 272 277 310 +f 310 306 272 +f 306 310 311 +f 311 307 306 +f 307 311 312 +f 312 308 307 +f 308 312 313 +f 313 309 308 +f 277 282 314 +f 314 310 277 +f 310 314 315 +f 315 311 310 +f 311 315 316 +f 316 312 311 +f 312 316 317 +f 317 313 312 +f 282 287 318 +f 318 314 282 +f 314 318 319 +f 319 315 314 +f 315 319 320 +f 320 316 315 +f 316 320 321 +f 321 317 316 +f 287 292 322 +f 322 318 287 +f 318 322 323 +f 323 319 318 +f 319 323 324 +f 324 320 319 +f 320 324 325 +f 325 321 320 +f 292 297 326 +f 326 322 292 +f 322 326 327 +f 327 323 322 +f 323 327 328 +f 328 324 323 +f 324 328 329 +f 329 325 324 +f 297 262 298 +f 298 326 297 +f 326 298 299 +f 299 327 326 +f 327 299 300 +f 300 328 327 +f 328 300 301 +f 301 329 328 +f 330 335 336 +f 336 331 330 +f 331 336 337 +f 337 332 331 +f 332 337 338 +f 338 333 332 +f 333 338 339 +f 339 334 333 +f 335 340 341 +f 341 336 335 +f 336 341 342 +f 342 337 336 +f 337 342 343 +f 343 338 337 +f 338 343 344 +f 344 339 338 +f 340 345 346 +f 346 341 340 +f 341 346 347 +f 347 342 341 +f 342 347 348 +f 348 343 342 +f 343 348 349 +f 349 344 343 +f 345 350 351 +f 351 346 345 +f 346 351 352 +f 352 347 346 +f 347 352 353 +f 353 348 347 +f 348 353 354 +f 354 349 348 +f 350 355 356 +f 356 351 350 +f 351 356 357 +f 357 352 351 +f 352 357 358 +f 358 353 352 +f 353 358 359 +f 359 354 353 +f 355 360 361 +f 361 356 355 +f 356 361 362 +f 362 357 356 +f 357 362 363 +f 363 358 357 +f 358 363 364 +f 364 359 358 +f 360 365 366 +f 366 361 360 +f 361 366 367 +f 367 362 361 +f 362 367 368 +f 368 363 362 +f 363 368 369 +f 369 364 363 +f 365 330 331 +f 331 366 365 +f 366 331 332 +f 332 367 366 +f 367 332 333 +f 333 368 367 +f 368 333 334 +f 334 369 368 +f 334 339 374 +f 374 370 334 +f 370 374 375 +f 375 371 370 +f 371 375 376 +f 376 372 371 +f 372 376 377 +f 377 373 372 +f 339 344 378 +f 378 374 339 +f 374 378 379 +f 379 375 374 +f 375 379 380 +f 380 376 375 +f 376 380 381 +f 381 377 376 +f 344 349 382 +f 382 378 344 +f 378 382 383 +f 383 379 378 +f 379 383 384 +f 384 380 379 +f 380 384 385 +f 385 381 380 +f 349 354 386 +f 386 382 349 +f 382 386 387 +f 387 383 382 +f 383 387 388 +f 388 384 383 +f 384 388 389 +f 389 385 384 +f 354 359 390 +f 390 386 354 +f 386 390 391 +f 391 387 386 +f 387 391 392 +f 392 388 387 +f 388 392 393 +f 393 389 388 +f 359 364 394 +f 394 390 359 +f 390 394 395 +f 395 391 390 +f 391 395 396 +f 396 392 391 +f 392 396 397 +f 397 393 392 +f 364 369 398 +f 398 394 364 +f 394 398 399 +f 399 395 394 +f 395 399 400 +f 400 396 395 +f 396 400 401 +f 401 397 396 +f 369 334 370 +f 370 398 369 +f 398 370 371 +f 371 399 398 +f 399 371 372 +f 372 400 399 +f 400 372 373 +f 373 401 400 +f 407 403 402 +f 403 407 408 +f 408 404 403 +f 404 408 409 +f 409 405 404 +f 405 409 410 +f 410 406 405 +f 411 407 402 +f 407 411 412 +f 412 408 407 +f 408 412 413 +f 413 409 408 +f 409 413 414 +f 414 410 409 +f 415 411 402 +f 411 415 416 +f 416 412 411 +f 412 416 417 +f 417 413 412 +f 413 417 418 +f 418 414 413 +f 419 415 402 +f 415 419 420 +f 420 416 415 +f 416 420 421 +f 421 417 416 +f 417 421 422 +f 422 418 417 +f 423 419 402 +f 419 423 424 +f 424 420 419 +f 420 424 425 +f 425 421 420 +f 421 425 426 +f 426 422 421 +f 427 423 402 +f 423 427 428 +f 428 424 423 +f 424 428 429 +f 429 425 424 +f 425 429 430 +f 430 426 425 +f 431 427 402 +f 427 431 432 +f 432 428 427 +f 428 432 433 +f 433 429 428 +f 429 433 434 +f 434 430 429 +f 435 431 402 +f 431 435 436 +f 436 432 431 +f 432 436 437 +f 437 433 432 +f 433 437 438 +f 438 434 433 +f 439 435 402 +f 435 439 440 +f 440 436 435 +f 436 440 441 +f 441 437 436 +f 437 441 442 +f 442 438 437 +f 443 439 402 +f 439 443 444 +f 444 440 439 +f 440 444 445 +f 445 441 440 +f 441 445 446 +f 446 442 441 +f 447 443 402 +f 443 447 448 +f 448 444 443 +f 444 448 449 +f 449 445 444 +f 445 449 450 +f 450 446 445 +f 451 447 402 +f 447 451 452 +f 452 448 447 +f 448 452 453 +f 453 449 448 +f 449 453 454 +f 454 450 449 +f 455 451 402 +f 451 455 456 +f 456 452 451 +f 452 456 457 +f 457 453 452 +f 453 457 458 +f 458 454 453 +f 459 455 402 +f 455 459 460 +f 460 456 455 +f 456 460 461 +f 461 457 456 +f 457 461 462 +f 462 458 457 +f 463 459 402 +f 459 463 464 +f 464 460 459 +f 460 464 465 +f 465 461 460 +f 461 465 466 +f 466 462 461 +f 403 463 402 +f 463 403 404 +f 404 464 463 +f 464 404 405 +f 405 465 464 +f 465 405 406 +f 406 466 465 +f 406 410 471 +f 471 467 406 +f 467 471 472 +f 472 468 467 +f 468 472 473 +f 473 469 468 +f 469 473 474 +f 474 470 469 +f 410 414 475 +f 475 471 410 +f 471 475 476 +f 476 472 471 +f 472 476 477 +f 477 473 472 +f 473 477 478 +f 478 474 473 +f 414 418 479 +f 479 475 414 +f 475 479 480 +f 480 476 475 +f 476 480 481 +f 481 477 476 +f 477 481 482 +f 482 478 477 +f 418 422 483 +f 483 479 418 +f 479 483 484 +f 484 480 479 +f 480 484 485 +f 485 481 480 +f 481 485 486 +f 486 482 481 +f 422 426 487 +f 487 483 422 +f 483 487 488 +f 488 484 483 +f 484 488 489 +f 489 485 484 +f 485 489 490 +f 490 486 485 +f 426 430 491 +f 491 487 426 +f 487 491 492 +f 492 488 487 +f 488 492 493 +f 493 489 488 +f 489 493 494 +f 494 490 489 +f 430 434 495 +f 495 491 430 +f 491 495 496 +f 496 492 491 +f 492 496 497 +f 497 493 492 +f 493 497 498 +f 498 494 493 +f 434 438 499 +f 499 495 434 +f 495 499 500 +f 500 496 495 +f 496 500 501 +f 501 497 496 +f 497 501 502 +f 502 498 497 +f 438 442 503 +f 503 499 438 +f 499 503 504 +f 504 500 499 +f 500 504 505 +f 505 501 500 +f 501 505 506 +f 506 502 501 +f 442 446 507 +f 507 503 442 +f 503 507 508 +f 508 504 503 +f 504 508 509 +f 509 505 504 +f 505 509 510 +f 510 506 505 +f 446 450 511 +f 511 507 446 +f 507 511 512 +f 512 508 507 +f 508 512 513 +f 513 509 508 +f 509 513 514 +f 514 510 509 +f 450 454 515 +f 515 511 450 +f 511 515 516 +f 516 512 511 +f 512 516 517 +f 517 513 512 +f 513 517 518 +f 518 514 513 +f 454 458 519 +f 519 515 454 +f 515 519 520 +f 520 516 515 +f 516 520 521 +f 521 517 516 +f 517 521 522 +f 522 518 517 +f 458 462 523 +f 523 519 458 +f 519 523 524 +f 524 520 519 +f 520 524 525 +f 525 521 520 +f 521 525 526 +f 526 522 521 +f 462 466 527 +f 527 523 462 +f 523 527 528 +f 528 524 523 +f 524 528 529 +f 529 525 524 +f 525 529 530 +f 530 526 525 +f 466 406 467 +f 467 527 466 +f 527 467 468 +f 468 528 527 +f 528 468 469 +f 469 529 528 +f 529 469 470 +f 470 530 529 +# 992 faces + +g