-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_obj.cpp
755 lines (623 loc) · 17.9 KB
/
display_obj.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
// release 02/03/12 - added significant comments
//
//
// Notes: in this assignment, you will be reading in a file describing a series
// of curves & or surfaces, and then "sampling" them so that they may be displayed.
//
// "Sampling" means that you will compute a set of points on each curve (or
// surface), which you will then provide to OpenGL to draw lines between
// (approximating the curve) or triangles between (approximating the surface).
//
// Your code should do these things, in order:
// 1. read in the scene file, and convert to geometric entities (much
// of this is aready done - see the parser provided in the Resources
// section of the wiki. This should be done in the main() before
// setting up the OpenGL callbacks.
//
// 2. sample the geometry - using the deBoor algorithm or the b-spline
// basis. if it's a curve, you will be sampling the curve at regular
// spacings in u, and storing the resulting samples in a 1-D array. if
// it's a surface, you will be sampling at regular intervals in both
// u AND v, generating a 2-D array of sample points (though you may
// still be storing that in a 1-d data structure). this is the bulk of
// your assignment.
//
// 3. outputting it to OpenGL. you should make (minor) modifications to the
// function DrawCurvesSurfaces (); See the notes there for what is required.
//
// One note: you only need to generate the samples on your curve/surface ONCE -
// before you start sending them to OpenGL. unless you have changed somthing on
// the surface, or you have changed the sampling rate (more or fewer samples),
// you do NOT need to repeat step 2 above - OpenGL will keep redrawing them
// by calling DrawCuresSurfaces as it needs to.
//
//
// Building:
// on CS machines, compile with:
//
// g++ -I /usr/include/GL -I /usr/include -L /usr/local/lib -lglut -lGL -lGLU
// -lm trackball.cpp display_bspline.cpp -o display_spline
/*
// uncomment this on the mac
#define MAC
#ifdef MAC
#include <GLUT/glut.h>
#else
#include <gl.h>
#include <glu.h>
#include <glut.h>
#endif
*/
#ifdef __APPLE__ //to make in both Mac OS and linux. Thi
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include<GL/glu.h>
#include<GL/glut.h>
#endif
#include <math.h>
#include <stdio.h>
#include "trackball.h"
#include <sys/time.h>
#include"Mesh.h"
vector<Mesh> myMesh; //vector of indexed triangle data structure
int currentMesh=0; //current Mesh index number
int mode=0; //normal mode, 0 is flat, 1 is smooth
//
// The next 2 functions are just for (rough) timing of how many
// frames-per-second you are displaying.
//
struct timeval frameStartTime, frameEndTime;
#define FRAME_AVG_COUNT 5
int frameCount = 0; // count 5 frames at a time and average...
float elapsedTime = 100.0;
void frameStart(void) {
if (frameCount == 0)
gettimeofday(&frameStartTime, NULL);
}
void frameEnd(void *font, GLclampf r, GLclampf g, GLclampf b,
GLfloat x, GLfloat y) {
/* font: font to use, e.g., GLUT_BITMAP_HELVETICA_10
r, g, b: text colour
x, y: text position in window: range [0,0] (bottom left of window)
to [1,1] (top right of window). */
frameCount++;
char str[30];
char *ch;
GLint matrixMode;
GLboolean lightingOn;
if (frameCount == FRAME_AVG_COUNT) {
gettimeofday(&frameEndTime, NULL);
elapsedTime= frameEndTime.tv_sec - frameStartTime.tv_sec +
((frameEndTime.tv_usec - frameStartTime.tv_usec)/1.0E6);
elapsedTime /= FRAME_AVG_COUNT;
frameCount = 0;
}
sprintf(str, "Frames per second: %2.0f", 1.0/elapsedTime);
lightingOn= glIsEnabled(GL_LIGHTING); /* lighting on? */
if (lightingOn) glDisable(GL_LIGHTING);
glGetIntegerv(GL_MATRIX_MODE, &matrixMode); /* matrix mode? */
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_COLOR_BUFFER_BIT); /* save current colour */
glColor3f(r, g, b);
glRasterPos3f(x, y, 0.0);
for(ch= str; *ch; ch++) {
glutBitmapCharacter(font, (int)*ch);
}
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(matrixMode);
if (lightingOn) glEnable(GL_LIGHTING);
}
#define kRotationStep 10.0f
#define kTranslationStep 0.1f
#define BUFFER_LENGTH 64
bool activeshift = false;
// a default bezier surface:
GLfloat ctrlpoints[4][4][3] =
{
{
{-1.5, -1.5, 4.0},
{-0.5, -1.5, 2.0},
{0.5, -1.5, -1.0},
{1.5, -1.5, 2.0}},
{
{-1.5, -0.5, 1.0},
{-0.5, -0.5, 3.0},
{0.5, -0.5, 0.0},
{1.5, -0.5, -1.0}},
{
{-1.5, 0.5, 4.0},
{-0.5, 0.5, 0.0},
{0.5, 0.5, 3.0},
{1.5, 0.5, 4.0}},
{
{-1.5, 1.5, -2.0},
{-0.5, 1.5, -2.0},
{0.5, 1.5, 0.0},
{1.5, 1.5, -1.0}}
};
GLint pointNumU = 4;
GLint pointNumV = 4;
GLfloat baseplane[4][3] =
{
{-50, -50, -100},
{-50, 50, -100},
{ 50, -50, -100},
{ 50, 50, -100}
};
// Lights & Materials
GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat position[] = {0.0, 0.0, 2.0, 1.0};
GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0};
GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat mat_shininess[] = {50.0};
// Parameters
GLfloat camRotX, camRotY, camPosX, camPosY, camPosZ;
GLboolean isSmooth;
GLboolean showLine;
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLuint pickedObj = -1;
char titleString[150];
void initLights(void)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
}
void SetCamera(void)
{
glTranslatef(0, 0, camPosZ);
glRotatef(camRotX, 1, 0, 0);
glRotatef(camRotY, 0, 1, 0);
}
void SetupRC()
{
tbInit(GLUT_RIGHT_BUTTON);
tbAnimate(GL_TRUE);
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
initLights();
// Place Camera
camRotX = 350.0f;
camRotY = 680.0f;
camPosX = 0.0f;
camPosY = 0.0f;
camPosZ = -10.5f;
isSmooth = true;
}
// If we have the user selecting and moving control points, here is where we
// name them so we can find them in the selection buffer:
//
void DrawPoints(void)
{
// Initialize the names stack
glInitNames();
glPushName(0);
for (int u = 0; u < pointNumU; u++)
{
for (int v = 0; v < pointNumV; v++)
{
// Set name
int count = u * pointNumU + v;
glLoadName(count);
// Set Color
GLfloat diffuse[] = {(float)u/pointNumU, (float)v/pointNumV, 0.0, 1.0};
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
// Draw the point
glPushMatrix();
{
glTranslatef( ctrlpoints[u][v][0], ctrlpoints[u][v][1], ctrlpoints[u][v][2] );
glutSolidSphere(0.05, 32, 32);
}
glPopMatrix();
}
}
}
// Draw the curve(s) and/or surface(s): THIS IS WHERE YOUR DRAW CODE GOES, but
// do not do your surface sampling here - it's not necessary to resample the
// surface on every redraw. Just use the same points you sampled before.
//
// This fucntion is called from RenderScene(), which is the display function.
//
// In this function, you need to go through the arrays of sampled points
// (from the curves or surfaces) and draw the appropriate lines or triangles.
//
// For each curve - you will previously have sampled the curve into a set
// of points. You will draw a series of line segments between this samples
// using somthing like:
//
// glBegin( GL_LINE_STRIP); // start giving vertices to connect w lines
//
// for( i = 0; i < numberOfSamples; ++i)
// glVertex3f( sample[i].x, sample[i].y, sample[i].z);
//
// glEnd(); // finished giving vertices to be connceted
//
// The glBegin and glEnd calls tell OpenGL you are drawing a bunch of line
// segments - if your curve samples are close together (say, 4 times as many
// as there are control points) it will look smooth.
//
//
// For each surface - you will have previously sampled the surface (in u and
// v) into a rectangular array of surface points. You will now output those
// points as triangles using something like this:
//
// glBegin( GL_TRIANGLES ); // start providing triangle vertices
//
// for (int i = 0; i < numUSamples - 1; ++i) {
// for (int j = 0; j < numVSamples - 1; ++j {
//
// // draw two triangles in the mesh:
// glVertex3f (surfacePts(i,j).x, surfacePts(i,j).y, surfacePts(i,j).z);
// glVertex3f (surfacePts(i+1,j).x, surfacePts(i+1,j).y, surfacePts(i+1,j).z);
// glVertex3f (surfacePts(i+1,j+1).x, surfacePts(i+1,j+1).y, surfacePts(i+1,j+1).z);
//
// glVertex3f (surfacePts(i,j).x, surfacePts(i,j).y, surfacePts(i,j).z);
// glVertex3f (surfacePts(i+1,j+1).x, surfacePts(i+1,j+1).y, surfacePts(i+1,j+1).z);
// glVertex3f (surfacePts(i,j+1).x, surfacePts(i,j+1).y, surfacePts(i,j+1).z);
//
// glEnd(); // finished providing triangle vertices
//
// Remember you will need to do these for each piece of geometry you have read
// in, so there may be multiple curves and surfaces.
//
void DrawCurvesSurfaces(void)
{
// Set the color to display the surface with:
GLfloat grey_diffuse[] = {0.6, 0.6, 0.6, 1.0};
glMaterialfv(GL_FRONT, GL_DIFFUSE, grey_diffuse);
//
// this sets up a demo bezier surface:
// everthing after this in this function should be replaced
// with your code:
//
glMap2f(
GL_MAP2_VERTEX_3, // target
0, 1, 3, 4, // u1, u2, uStride, uOrder
0, 1, 12, 4, // v1, v2, vStride, vOrder
&ctrlpoints[0][0][0] // points
);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glMapGrid2f(
60, 0.0, 1.0, // un, u1, u2
60, 0.0, 1.0 // vn, v1, v2
);
// If you want to draw things as a mesh grid, vs. an opaque surface, you
// can do so - though not in quite the same way as here.
if (showLine) {
glEvalMesh2(GL_LINE, 0, 60, 0, 60);
}
else {
glEvalMesh2(GL_FILL, 0, 60, 0, 60);
}
}
void displayMesh()
{
Mesh mesh;
mesh=myMesh[currentMesh];
switch (mode)
{
case 0:
for(unsigned int i=0; i<mesh.faces.size(); ++i)
{
if(mesh.type==0)
glBegin(GL_TRIANGLES);
else
{
if(currentMesh==0)
glBegin(GL_POLYGON);
else
glBegin(GL_QUADS);
}
glNormal3f(mesh.faces[i].faceNormal.x,mesh.faces[i].faceNormal.y,mesh.faces[i].faceNormal.z);
for(unsigned int j=0; j<mesh.faces[i].ver_id.size();++j)
{
glVertex3f(mesh.vertices[mesh.faces[i].ver_id[j]].point.x,mesh.vertices[mesh.faces[i].ver_id[j]].point.y,mesh.vertices[mesh.faces[i].ver_id[j]].point.z);
}
glEnd();
}
break;
case 1:
for(unsigned int i=0; i<mesh.faces.size(); ++i)
{
if(mesh.type==0)
glBegin(GL_TRIANGLES);
else
{
if(currentMesh==0)
glBegin(GL_POLYGON);
else
glBegin(GL_QUADS);
}
for(unsigned int j=0; j<mesh.faces[i].ver_id.size();++j)
{
glNormal3f(mesh.vertices[mesh.faces[i].ver_id[j]].normal.x,mesh.vertices[mesh.faces[i].ver_id[j]].normal.y,mesh.vertices[mesh.faces[i].ver_id[j]].normal.z);
glVertex3f(mesh.vertices[mesh.faces[i].ver_id[j]].point.x,mesh.vertices[mesh.faces[i].ver_id[j]].point.y,mesh.vertices[mesh.faces[i].ver_id[j]].point.z);
}
glEnd();
}
}
}
void updateMesh()
{
Mesh newMesh;
if(currentMesh==(int)myMesh.size())
{
if(myMesh[currentMesh-1].type==0)
newMesh=getLoopSub(myMesh[currentMesh-1]);
else
{
newMesh=getCCSub(myMesh[currentMesh-1]);
}
setVertexNormal(newMesh);
myMesh.push_back(newMesh);
}
}
void RenderScene(void)
{
frameStart();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
{
SetCamera();
tbMatrix();
glRotatef(85.0, 1.0, 1.0, 1.0);
//
// This function is where your code goes:
//
// DrawCurvesSurfaces();
displayMesh();
// uncomment this if you want to allow the user to select and move
// control points, shaping the surface. at the moment it's buggy -
// it looks like the plane in which the points can be moved is not
// calculated correctly
//
// DrawPoints();
// Retrieve current matrice before they popped.
glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); // Retrieve The Modelview Matrix
glGetDoublev( GL_PROJECTION_MATRIX, projection ); // Retrieve The Projection Matrix
glGetIntegerv( GL_VIEWPORT, viewport ); // Retrieves The Viewport Values (X, Y, Width, Height)
}
glPopMatrix();
frameEnd(GLUT_BITMAP_HELVETICA_10, 1.0, 1.0, 1.0, 0.05, 0.95);
glFlush();
}
// If the user is selecting control points, you need "DrawPoints()" above
// uncommented.
//
// Here is where we we figure out what was clicked on:
//
void ProcessSelection(int xPos, int yPos)
{
GLfloat fAspect;
// Space for selection buffer
static GLuint selectBuff[BUFFER_LENGTH];
// Hit counter and viewport storage
GLint hits, viewport[4];
// Setup selection buffer
glSelectBuffer(BUFFER_LENGTH, selectBuff);
// Get the viewport
glGetIntegerv(GL_VIEWPORT, viewport);
// Switch to projection and save the matrix
glMatrixMode(GL_PROJECTION);
glPushMatrix();
{
// Change render mode
glRenderMode(GL_SELECT);
// Establish new clipping volume to be unit cube around
// mouse cursor point (xPos, yPos) and extending two pixels
// in the vertical and horizontal direction
glLoadIdentity();
gluPickMatrix(xPos, viewport[3] - yPos + viewport[1], 0.1,0.1, viewport);
// Apply perspective matrix
fAspect = (float)viewport[2] / (float)viewport[3];
gluPerspective(45.0f, fAspect, 1.0, 425.0);
// Render only those needed for selection
glPushMatrix();
{
SetCamera();
tbMatrixForSelection();
glRotatef(85.0, 1.0, 1.0, 1.0);
DrawPoints();
}
glPopMatrix();
// Collect the hits
hits = glRenderMode(GL_RENDER);
// If a single hit occurred, display the info.
if(hits == 1)
{
// Save current picked object.
pickedObj = selectBuff[3];
glPushMatrix();
{
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
winX = (float)xPos;
winY = (float)viewport[3] - (float)yPos;
glReadPixels( xPos, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
float k = -(float)1 / ( (float)1 - winZ );
baseplane[0][2] = k;
baseplane[1][2] = k;
baseplane[2][2] = k;
baseplane[3][2] = k;
sprintf (titleString, "You clicked on %d win:( %d , %d , %f ) / pos:( %f, %f, %f)", pickedObj, (int)winX, (int)winY, winZ, posX, posY, posZ);
glutSetWindowTitle(titleString);
}
glPopMatrix();
}
else
glutSetWindowTitle("Nothing was clicked on!");
// Restore the projection matrix
glMatrixMode(GL_PROJECTION);
}
glPopMatrix();
// Go back to modelview for normal rendering
glMatrixMode(GL_MODELVIEW);
glutPostRedisplay();
}
// Keyboard handling:
//
void SpecialKeys(int key, int x, int y)
{
if(key == GLUT_KEY_UP) {
camRotX += kRotationStep;
}
if(key == GLUT_KEY_DOWN) {
camRotX -= kRotationStep;
}
if(key == GLUT_KEY_LEFT) {
camRotY += kRotationStep;
}
if(key == GLUT_KEY_RIGHT) {
camRotY -= kRotationStep;
}
if(key=='1')
mode=0;
if(key=='2')
mode=1;
if(key=='<')
{
if(currentMesh>=1)
currentMesh--;
}
if(key=='>')
currentMesh++;
if(key == 'z') {
camPosZ += kTranslationStep;
}
if(key == 'x') {
camPosZ -= kTranslationStep;
}
if(key== 27) //Escape key
exit(0);
if(key == 'l')
{
showLine = !showLine;
}
if(key == 's')
{
isSmooth = !isSmooth;
if (isSmooth)
{
glShadeModel(GL_SMOOTH);
}
else
{
glShadeModel(GL_FLAT);
}
}
//update myMesh[]
updateMesh();
// Refresh the Window
glutPostRedisplay();
}
// Mouse handling:
//
void MouseCallback(int button, int state, int x, int y)
{
tbMouse(button, state, x, y);
int mymod;
mymod = glutGetModifiers();
if ((activeshift == true) && (mymod != GLUT_ACTIVE_SHIFT)) {
glutSetWindowTitle("NO shift key!");
activeshift = false;
}
if ((activeshift == false) && (mymod == GLUT_ACTIVE_SHIFT)) {
glutSetWindowTitle("YES shift key!");
activeshift = true;
}
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
ProcessSelection(x, y);
if(button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
pickedObj = -1;
baseplane[0][2] = -100;
baseplane[1][2] = -100;
baseplane[2][2] = -100;
baseplane[3][2] = -100;
glutPostRedisplay();
}
}
// If the veiwport is resized:
void ChangeSize(int w, int h)
{
tbReshape(w, h);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the clipping volume
gluPerspective(45.0f, (GLfloat)w / (GLfloat)h, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//
// Mouse handling:
//
void motion(int x, int y)
{
tbMotion(x, y);
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
winX = (float)x;
winY = (float)viewport[3] - (float)y;
glReadPixels( x, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
int u = pickedObj/pointNumU;
int v = pickedObj - u*pointNumU;
if (pickedObj != -1)
{
ctrlpoints[u][v][0] = posX;
ctrlpoints[u][v][1] = posY;
ctrlpoints[u][v][2] = posZ;
}
glutPostRedisplay();
sprintf (titleString, "win:( %d , %d , %f ) / pos:( %f, %f, %f)", (int)winX, (int)winY, winZ, posX, posY, posZ);
glutSetWindowTitle(titleString);
}
//
int main(int argc, char **argv)
{
// you should probably call a function to read in and parse the scene here
// you should probably call a function to process the curves/surfaces into
// arrays of sample points here
// Now everything goes to OpenGL. You should have written some code in
// DrawCurvesSurfaces which OpenGL will call when it needs to redraw the
// screen, and you're done!
//
Mesh mesh1;
mesh1.loadFile(argv[1]);
myMesh.push_back(mesh1);
setVertexNormal(myMesh[0]);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800, 600);
glutCreateWindow("Display and simplify Mesh");
SetupRC();
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);
glutSpecialFunc(SpecialKeys);
glutMouseFunc(MouseCallback);
glutMotionFunc(motion);
glutMainLoop();
return 0;
}