diff --git a/sources/main.cpp b/sources/main.cpp index 3419eb5..915ad5e 100755 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -14,6 +14,8 @@ #include // This file import the OpenGL interface #include // This file offers some OpenGL-related utilities +#include + #include ///////////// @@ -212,6 +214,54 @@ float lightdelta = 0.8f; +/* +Tri** importModel(char* fname) { + + FILE *fp; + char lbuf[200]; + char* buf2; + int numpoints = 0; + int numfaces = 0; + float[3] tpf = {0.0,0.0,0.0}; + int* tp = NULL; + int tps = 0; + Vec** points = NULL; + Tri** faces = NULL; + + fp = fopen(fname, "r"); + + if ( fp == NULL ) { + printf("Error reading file %s\n", fname); + return; + } + + while( fgets(lbuf, sizeof(lbuf), fp) != NULL ) { + buf2 = strtok(lbuf, " "); + if ( buf2 == "v" ) { + numpoints++; + points = realloc(points, numpoints*sizeof(Vec*)); + tpf[0] = atof(strtok(str, null)); + tpf[1] = atof(strtok(str, null)); + tpf[2] = atof(strtok(str, null)); + points[numpoints-1] = new Vec(tpf[0], tpf[1], tpf[2]); + } + if ( buf2 == "f" ) { + numfaces++; + faces = realloc(faces, numfaces*sizeof(Tri*)); + tps = 0; + while ( (buf2 = strtok(str, null)) != NULL ) { + tps++; + tp = realloc(tp, tps*(sizeof(int)); + tp[tps-1] = atoi(buf2); + } + faces[numfaces-1] = new Tri(); + } + } + + fclose(fp); + return faces; +} +*/ /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// @@ -235,7 +285,7 @@ Color green (0,1,0); Color yellow (1,1,0); - Vec p0 (0,0,0); + /*Vec p0 (0,0,0); Vec p1 (1,0,0); Vec p2 (1,1,0); Vec p3 (0,1,0); @@ -252,7 +302,7 @@ Rect (&p2, &p3, &p7, &p6, &yellow), Rect (&p1, &p2, &p6, &p5, &black), Rect (&p3, &p0, &p4, &p7, &white) - }; + };*/ // Prepare configuration: int bitsPerColor = 8; @@ -331,6 +381,7 @@ for (int i = 0; i < SURFACE_COUNT; i++) { surf[i].draw(); } + /* glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0f); glLightfv(GL_LIGHT0, GL_POSITION, lightpos);