-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.cpp
609 lines (500 loc) · 16.6 KB
/
graphics.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
/************************************************************
Grafika OpenGL
*************************************************************/
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <iterator>
#include <map>
#include <time.h>
#include "graphics.h"
//#include "vector3D.h"
//#include "quaternion.h"
#ifndef _OBJECTS__H
#include "objects.h"
#endif
using namespace std;
extern FILE *f;
extern MovableObject *my_vehicle; // obiekt przypisany do tej aplikacji
extern map<int, MovableObject*> network_vehicles;
extern CRITICAL_SECTION m_cs;
extern Terrain terrain;
extern long group_existing_time;
extern long start_time;
int g_GLPixelIndex = 0;
HGLRC g_hGLContext = NULL;
unsigned int font_base;
ViewParameters par_view;
extern void TworzListyWyswietlania(); // definiujemy listy tworzące labirynt
extern void DrawGlobalCoordinateSystem();
void StandardViewParametersSetting(ViewParameters *p)
{
p->initial_camera_direction = Vector3(0, -3, -11); // direction patrzenia
p->initial_camera_position = Vector3(30, 3, 0); // po³o¿enie kamery
p->initial_camera_vertical = Vector3(0, 1, 0); // direction pionu kamery
// Zmienne - ustawiane przez użytkownika
p->tracking = 1; // tryb œledzenia obiektu przez kamerê
p->top_view = 0; // tryb widoku z gory
p->distance = 20.0; // distance lub przybli¿enie kamery
p->zoom = 1.0; // zmiana kąta widzenia
p->cam_angle_z = 0; // obrót kamery góra-dół
p->shift_to_right = 0; // przesunięcie kamery w prawo (w lewo o wart. ujemnej) - chodzi głównie o tryb edycji
p->shift_to_bottom = 0; // przesunięcie do dołu (w górę o wart. ujemnej) i widok z góry (klawisz Q)
}
int GraphicsInitialization(HDC g_context)
{
if (SetWindowPixelFormat(g_context) == FALSE)
return FALSE;
if (CreateViewGLContext(g_context) == FALSE)
return 0;
BuildFont(g_context);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
StandardViewParametersSetting(&par_view);
TworzListyWyswietlania(); // definiujemy listy tworzące różne elementy sceny
terrain.GraphicsInitialization();
}
// Ustwienia kamery w zależności od wartości początkowych (w interakcji), wartości ustawianych
// przez użytkowika oraz stanu obiektu (np. gdy tryb śledzenia)
void CameraSettings(Vector3 *position, Vector3 *direction, Vector3 *vertical, ViewParameters pw)
{
if (pw.tracking) // kamera ruchoma - porusza się wraz z obiektem
{
(*direction) = my_vehicle->state.qOrient.obroc_wektor(Vector3(1, 0, 0));
(*vertical) = my_vehicle->state.qOrient.obroc_wektor(Vector3(0, 1, 0));
Vector3 prawo_kamery = my_vehicle->state.qOrient.obroc_wektor(Vector3(0, 0, 1));
(*vertical) = (*vertical).obrot(pw.cam_angle_z, prawo_kamery.x, prawo_kamery.y, prawo_kamery.z);
(*direction) = (*direction).obrot(pw.cam_angle_z, prawo_kamery.x, prawo_kamery.y, prawo_kamery.z);
(*position) = my_vehicle->state.vPos - (*direction)*my_vehicle->length * 0 +
(*vertical).znorm()*my_vehicle->height * 5;
if (pw.top_view)
{
(*vertical) = (*direction);
(*direction) = Vector3(0, -1, 0);
(*position) = (*position) + Vector3(0, 100, 0) + (*vertical)*pw.shift_to_bottom + (*vertical)*(*direction)*pw.shift_to_right;
}
}
else // bez śledzenia - kamera nie podąża wraz z pojazdem
{
(*vertical) = pw.initial_camera_vertical;
(*direction) = pw.initial_camera_direction;
(*position) = pw.initial_camera_position;
Vector3 prawo_kamery = ((*direction)*(*vertical)).znorm();
(*vertical) = (*vertical).obrot(pw.cam_angle_z / 20, prawo_kamery.x, prawo_kamery.y, prawo_kamery.z);
(*direction) = (*direction).obrot(pw.cam_angle_z / 20, prawo_kamery.x, prawo_kamery.y, prawo_kamery.z);
if (pw.top_view)
{
(*vertical) = Vector3(0, 0, -1);
(*direction) = Vector3(0, -1, 0.02);
(*position) = pw.initial_camera_position + Vector3(0, 100, 0) + (*vertical)*pw.shift_to_bottom + (*vertical)*(*direction)*pw.shift_to_right;
}
}
}
void DrawScene()
{
float czas = (float)(group_existing_time + clock() - start_time) / CLOCKS_PER_SEC; // czas od uruchomienia w [s]
GLfloat OwnObjectColor[] = { 0.0f, 0.0f, 0.9f, 0.7f };
GLfloat BlueSurfaceTr[] = { 0.6f, 0.0f, 0.9f, 0.3f };
GLfloat NetworkVehiclesColor[] = { 0.2f, 0.5f, 0.4f, 0.5f };
GLfloat RedSurface[] = { 0.8f, 0.2f, 0.1f, 0.5f };
GLfloat OrangeSurface[] = { 1.0f, 0.8f, 0.0f, 0.7f };
GLfloat GreenSurface[] = { 0.15f, 0.62f, 0.3f, 1.0f };
GLfloat YellowSurface[] = { 0.75f, 0.75f, 0.0f, 1.0f };
GLfloat YellowLight[] = { 2.0f, 2.0f, 1.0f, 1.0f };
GLfloat LightAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };
GLfloat LightDiffuse[] = { 0.7f, 0.7f, 0.7f, 0.7f };
GLfloat LightPosition[] = { 10.0*cos(czas / 5), 5.0f, 10.0*sin(czas / 5), 0.0f };
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); //1 składowa: światło otaczające (bezkierunkowe)
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); //2 składowa: światło rozproszone (kierunkowe)
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
glEnable(GL_LIGHT0);
//glPushMatrix();
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, YellowLight);
glLoadIdentity();
glClearColor(0.1, 0.1, 0.4, 0.7); // ustawienie nieczarnego koloru tła
glTranslatef(-24, 24, -40);
glRasterPos2f(4.0, -4.0);
glPrint("%s", par_view.inscription1);
glPrint("%s", par_view.inscription2);
glLoadIdentity();
Vector3 pol_k, kierunek_k, pion_k;
CameraSettings(&pol_k, &kierunek_k, &pion_k, par_view);
gluLookAt(pol_k.x - par_view.distance*kierunek_k.x,
pol_k.y - par_view.distance*kierunek_k.y, pol_k.z - par_view.distance*kierunek_k.z,
pol_k.x + kierunek_k.x, pol_k.y + kierunek_k.y, pol_k.z + kierunek_k.z,
pion_k.x, pion_k.y, pion_k.z);
//glRasterPos2f(0.30,-0.27);
//glPrint("MojObiekt->iID = %d",my_vehicle->iID );
DrawGlobalCoordinateSystem();
int dw = 0, dk = 0;
if (terrain.if_toroidal_world)
{
if (terrain.border_x > 0) dk = 1;
if (terrain.border_z > 0) dw = 1;
}
for (int w = -dw; w < 1 + dw; w++)
for (int k = -dk; k < 1 + dk; k++)
{
glPushMatrix();
glTranslatef(terrain.border_x*k, 0, terrain.border_z*w);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, OwnObjectColor);
glEnable(GL_BLEND);
my_vehicle->DrawObject();
// Lock the Critical section
EnterCriticalSection(&m_cs);
for (map<int, MovableObject*>::iterator it = network_vehicles.begin(); it != network_vehicles.end(); ++it)
{
if (it->second)
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, NetworkVehiclesColor);
it->second->DrawObject();
}
}
//Release the Critical section
LeaveCriticalSection(&m_cs);
glDisable(GL_BLEND);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, GreenSurface);
terrain.DrawObject();
glPopMatrix();
}
//glPopMatrix();
glFlush();
}
void WindowSizeChange(int cx, int cy)
{
GLsizei width, height;
GLdouble aspect;
width = cx;
height = cy;
if (cy == 0)
aspect = (GLdouble)width;
else
aspect = (GLdouble)width / (GLdouble)height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(55 * par_view.zoom, aspect, 1, 1000000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDrawBuffer(GL_BACK);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
}
Vector3 Cursor3dCoordinates(int x, int y) // współrzędne 3D punktu na obrazie 2D
{
// pobranie macierz modelowania
GLdouble model[16];
glGetDoublev(GL_MODELVIEW_MATRIX, model);
// pobranie macierzy rzutowania
GLdouble proj[16];
glGetDoublev(GL_PROJECTION_MATRIX, proj);
// pobranie obszaru renderingu
GLint view[4];
glGetIntegerv(GL_VIEWPORT, view);
// tablice ze odczytanymi współrzędnymi w przestrzeni widoku
GLdouble wsp[3];
//RECT rc;
//GetClientRect (main_window, &rc);
GLdouble wsp_z;
int wynik = gluProject(0, 0, 0, model, proj, view, wsp + 0, wsp + 1, &wsp_z);
gluUnProject(x, y, wsp_z, model, proj, view, wsp + 0, wsp + 1, wsp + 2);
//gluUnProject (x,rc.bottom - y,wsp_z ,model,proj,view,wsp+0,wsp+1,wsp+2);
return Vector3(wsp[0], wsp[1], wsp[2]);
}
Vector3 Cursor3dCoordinates(int x, int y, float height) // współrzędne 3D punktu na obrazie 2D
{
glTranslatef(0, height, 0);
// pobranie macierz modelowania
GLdouble model[16];
glGetDoublev(GL_MODELVIEW_MATRIX, model);
// pobranie macierzy rzutowania
GLdouble proj[16];
glGetDoublev(GL_PROJECTION_MATRIX, proj);
// pobranie obszaru renderingu
GLint view[4];
glGetIntegerv(GL_VIEWPORT, view);
// tablice ze odczytanymi współrzędnymi w przestrzeni widoku
GLdouble wsp[3];
//RECT rc;
//GetClientRect (main_window, &rc);
GLdouble wsp_z;
int wynik = gluProject(0, 0, 0, model, proj, view, wsp + 0, wsp + 1, &wsp_z);
gluUnProject(x, y, wsp_z, model, proj, view, wsp + 0, wsp + 1, wsp + 2);
glTranslatef(0, -height, 0);
//gluUnProject (x,rc.bottom - y,wsp_z ,model,proj,view,wsp+0,wsp+1,wsp+2);
return Vector3(wsp[0], wsp[1], wsp[2]);
}
void ScreenCoordinates(float *xx, float *yy, float *zz, Vector3 Point3D) // współrzędne punktu na ekranie na podstawie wsp 3D
{
// pobranie macierz modelowania
GLdouble model[16];
glGetDoublev(GL_MODELVIEW_MATRIX, model);
// pobranie macierzy rzutowania
GLdouble proj[16];
glGetDoublev(GL_PROJECTION_MATRIX, proj);
// pobranie obszaru renderingu
GLint view[4];
glGetIntegerv(GL_VIEWPORT, view);
// tablice ze odczytanymi współrzędnymi w przestrzeni widoku
GLdouble wsp[3], wsp_okn[3];
GLdouble liczba;
int wynik = gluProject(Point3D.x, Point3D.y, Point3D.z, model, proj, view, wsp_okn + 0, wsp_okn + 1, wsp_okn + 2);
gluUnProject(wsp_okn[0], wsp_okn[1], wsp_okn[2], model, proj, view, wsp + 0, wsp + 1, wsp + 2);
//fprintf(f," Wsp. punktu 3D = (%f, %f, %f), wspolrzedne w oknie = (%f, %f, %f), wsp. punktu = (%f, %f, %f)\n",
// Point3D.x,Point3D.y,Point3D.z, wsp_okn[0],wsp_okn[1],wsp_okn[2], wsp[0],wsp[1],wsp[2]);
(*xx) = wsp_okn[0]; (*yy) = wsp_okn[1]; (*zz) = wsp_okn[2];
}
void EndOfGraphics()
{
if (wglGetCurrentContext() != NULL)
{
// dezaktualizacja kontekstu renderującego
wglMakeCurrent(NULL, NULL);
}
if (g_hGLContext != NULL)
{
wglDeleteContext(g_hGLContext);
g_hGLContext = NULL;
}
glDeleteLists(font_base, 96);
}
BOOL SetWindowPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pixelDesc;
pixelDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pixelDesc.nVersion = 1;
pixelDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_STEREO_DONTCARE;
pixelDesc.iPixelType = PFD_TYPE_RGBA;
pixelDesc.cColorBits = 32;
pixelDesc.cRedBits = 8;
pixelDesc.cRedShift = 16;
pixelDesc.cGreenBits = 8;
pixelDesc.cGreenShift = 8;
pixelDesc.cBlueBits = 8;
pixelDesc.cBlueShift = 0;
pixelDesc.cAlphaBits = 0;
pixelDesc.cAlphaShift = 0;
pixelDesc.cAccumBits = 64;
pixelDesc.cAccumRedBits = 16;
pixelDesc.cAccumGreenBits = 16;
pixelDesc.cAccumBlueBits = 16;
pixelDesc.cAccumAlphaBits = 0;
pixelDesc.cDepthBits = 32;
pixelDesc.cStencilBits = 8;
pixelDesc.cAuxBuffers = 0;
pixelDesc.iLayerType = PFD_MAIN_PLANE;
pixelDesc.bReserved = 0;
pixelDesc.dwLayerMask = 0;
pixelDesc.dwVisibleMask = 0;
pixelDesc.dwDamageMask = 0;
g_GLPixelIndex = ChoosePixelFormat(hDC, &pixelDesc);
if (g_GLPixelIndex == 0)
{
g_GLPixelIndex = 1;
if (DescribePixelFormat(hDC, g_GLPixelIndex, sizeof(PIXELFORMATDESCRIPTOR), &pixelDesc) == 0)
{
return FALSE;
}
}
if (SetPixelFormat(hDC, g_GLPixelIndex, &pixelDesc) == FALSE)
{
return FALSE;
}
return TRUE;
}
BOOL CreateViewGLContext(HDC hDC)
{
g_hGLContext = wglCreateContext(hDC);
if (g_hGLContext == NULL)
{
return FALSE;
}
if (wglMakeCurrent(hDC, g_hGLContext) == FALSE)
{
return FALSE;
}
return TRUE;
}
GLvoid BuildFont(HDC hDC) // Build Our Bitmap Font
{
HFONT font; // Windows Font ID
HFONT oldfont; // Used For Good House Keeping
font_base = glGenLists(96); // Storage For 96 Characters
font = CreateFont(-13, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_NORMAL, // Font Weight
TRUE, // Italic
FALSE, // Underline
FALSE, // Strikeout
ANSI_CHARSET, // Character Set Identifier
OUT_TT_PRECIS, // Output Precision
CLIP_DEFAULT_PRECIS, // Clipping Precision
ANTIALIASED_QUALITY, // Output Quality
FF_DONTCARE | DEFAULT_PITCH, // Family And Pitch
"Courier New"); // Font Name
oldfont = (HFONT)SelectObject(hDC, font); // Selects The Font We Want
wglUseFontBitmaps(hDC, 31, 96, font_base); // Builds 96 Characters Starting At Character 32
SelectObject(hDC, oldfont); // Selects The Font We Want
DeleteObject(font); // Delete The Font
}
// Napisy w OpenGL
GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" Routine
{
char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments
if (fmt == NULL) // If There's No Text
return; // Do Nothing
va_start(ap, fmt); // Parses The String For Variables
vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap); // Results Are Stored In Text
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(font_base - 31); // Sets The Base Character to 32
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
glPopAttrib(); // Pops The Display List Bits
}
void TworzListyWyswietlania()
{
glNewList(Wall1, GL_COMPILE); // GL_COMPILE - lista jest kompilowana, ale nie wykonywana
glBegin(GL_QUADS); // inne opcje: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP
// GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUAD_STRIP, GL_POLYGON
glNormal3f(-1.0, 0.0, 0.0);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glEnd();
glEndList();
glNewList(Wall2, GL_COMPILE);
glBegin(GL_QUADS);
glNormal3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
glEndList();
/*glNewList(Floor,GL_COMPILE);
glBegin(GL_POLYGON);
glNormal3f( 0.0, 1.0, 0.0);
glVertex3f( -100, 0, -300.0);
glVertex3f( -100, 0, 100.0);
glVertex3f( 100, 0, 100.0);
glVertex3f( 100, 0, -300.0);
glEnd();
glEndList();*/
glNewList(Cube, GL_COMPILE);
glBegin(GL_QUADS);
// przod
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(0, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 1);
glVertex3f(1, 0, 1);
// tyl
glNormal3f(0.0, 0.0, -1.0);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(1, 1, 0);
glVertex3f(0, 1, 0);
// gora
glNormal3f(0.0, 1.0, 0.0);
glVertex3f(0, 1, 0);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
// dol
glNormal3f(0.0, -1.0, 0.0);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(1, 0, 1);
glVertex3f(0, 0, 1);
// prawo
glNormal3f(1.0, 0.0, 0.0);
glVertex3f(1, 0, 0);
glVertex3f(1, 0, 1);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
// lewo
glNormal3f(-1.0, 0.0, 0.0);
glVertex3f(0, 0, 0);
glVertex3f(0, 1, 0);
glVertex3f(0, 1, 1);
glVertex3f(0, 0, 1);
glEnd();
glEndList();
glNewList(Cube_skel, GL_COMPILE);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(0, 0, 1);
glVertex3f(1, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 1);
glVertex3f(0, 0, 0);
glVertex3f(0, 1, 0);
glVertex3f(1, 0, 0);
glVertex3f(1, 1, 0);
glVertex3f(0, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(1, 0, 1);
glVertex3f(1, 1, 1);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
glVertex3f(1, 0, 0);
glVertex3f(1, 0, 1);
glVertex3f(0, 1, 0);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(0, 0, 1);
glVertex3f(1, 0, 1);
glVertex3f(0, 1, 1);
glVertex3f(1, 1, 1);
glEnd();
glEndList();
}
void DrawGlobalCoordinateSystem(void)
{
glColor3f(1, 0, 0);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(2, 0, 0);
glVertex3f(2, -0.25, 0.25);
glVertex3f(2, 0.25, -0.25);
glVertex3f(2, -0.25, -0.25);
glVertex3f(2, 0.25, 0.25);
glEnd();
glColor3f(0, 1, 0);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(0, 2, 0);
glVertex3f(0, 2, 0);
glVertex3f(0.25, 2, 0);
glVertex3f(0, 2, 0);
glVertex3f(-0.25, 2, 0.25);
glVertex3f(0, 2, 0);
glVertex3f(-0.25, 2, -0.25);
glEnd();
glColor3f(0, 0, 1);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 2);
glVertex3f(-0.25, -0.25, 2);
glVertex3f(0.25, 0.25, 2);
glVertex3f(-0.25, -0.25, 2);
glVertex3f(0.25, -0.25, 2);
glVertex3f(-0.25, 0.25, 2);
glVertex3f(0.25, 0.25, 2);
glEnd();
glColor3f(1, 1, 1);
}