1 | #include "GeoMeshView.h"
|
---|
2 | #include <VertexData.h>
|
---|
3 |
|
---|
4 | using namespace Geometry;
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | //---------------------------------------------------------------------------
|
---|
8 | // Hanle events.
|
---|
9 | //---------------------------------------------------------------------------
|
---|
10 | int GeoMeshView::handle(int event)
|
---|
11 | {
|
---|
12 | int key;
|
---|
13 | int button;
|
---|
14 | int x;
|
---|
15 | int y;
|
---|
16 |
|
---|
17 | if (geoMesh != NULL)
|
---|
18 | {
|
---|
19 | draw();
|
---|
20 | }
|
---|
21 |
|
---|
22 | switch(event)
|
---|
23 | {
|
---|
24 | case fltk::KEY:
|
---|
25 | case fltk::PUSH:
|
---|
26 |
|
---|
27 | button = fltk::event_key();
|
---|
28 | mMouseX = fltk::event_x();
|
---|
29 | mMouseY = fltk::event_y();
|
---|
30 |
|
---|
31 | return 1;
|
---|
32 |
|
---|
33 | case fltk::DRAG:
|
---|
34 |
|
---|
35 | button = fltk::event_state();
|
---|
36 | x = fltk::event_x();
|
---|
37 | y = fltk::event_y();
|
---|
38 |
|
---|
39 | switch (button)
|
---|
40 | {
|
---|
41 | // Button 1 Pushed.
|
---|
42 | case 0x01100000:
|
---|
43 |
|
---|
44 | if (x > mMouseX)
|
---|
45 | {
|
---|
46 | if (mPan)
|
---|
47 | {
|
---|
48 | xshift = xshift + (x - mMouseX);
|
---|
49 | }
|
---|
50 | else
|
---|
51 | {
|
---|
52 | hAng = hAng + (x - mMouseX);
|
---|
53 | }
|
---|
54 | }
|
---|
55 | else
|
---|
56 | {
|
---|
57 | if (x < mMouseX)
|
---|
58 | {
|
---|
59 | if (mPan)
|
---|
60 | {
|
---|
61 | xshift = xshift - (mMouseX - x);
|
---|
62 | }
|
---|
63 | else
|
---|
64 | {
|
---|
65 | hAng = hAng - (mMouseX - x);
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | if (y > mMouseY)
|
---|
71 | {
|
---|
72 | if (mPan)
|
---|
73 | {
|
---|
74 | yshift = yshift - (y - mMouseY);
|
---|
75 | }
|
---|
76 | else
|
---|
77 | {
|
---|
78 | vAng = vAng + (y - mMouseY);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | else
|
---|
82 | {
|
---|
83 | if (y < mMouseY)
|
---|
84 | {
|
---|
85 | if (mPan)
|
---|
86 | {
|
---|
87 | yshift = yshift + (mMouseY - y);
|
---|
88 | }
|
---|
89 | else
|
---|
90 | {
|
---|
91 | vAng = vAng - (mMouseY - y);
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | hAng = float(int(hAng) % 360);
|
---|
97 | vAng = float(int(vAng) % 360);
|
---|
98 |
|
---|
99 | mMouseX = x;
|
---|
100 | mMouseY = y;
|
---|
101 |
|
---|
102 | draw();
|
---|
103 |
|
---|
104 | return 1;
|
---|
105 |
|
---|
106 | case 0x04100000:
|
---|
107 |
|
---|
108 | if (y > mSizeY)
|
---|
109 | {
|
---|
110 | size++;
|
---|
111 | }
|
---|
112 | else
|
---|
113 | {
|
---|
114 | if (y < mSizeY)
|
---|
115 | {
|
---|
116 | size--;
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | mSizeY = y;
|
---|
121 |
|
---|
122 | draw();
|
---|
123 |
|
---|
124 | return 1;
|
---|
125 |
|
---|
126 | }
|
---|
127 |
|
---|
128 | case fltk::MOUSEWHEEL:
|
---|
129 |
|
---|
130 | size = size + fltk::event_dy();
|
---|
131 | draw();
|
---|
132 | return 1;
|
---|
133 | }
|
---|
134 |
|
---|
135 | return fltk::GlWindow::handle(event);
|
---|
136 | }
|
---|
137 |
|
---|
138 | //---------------------------------------------------------------------------
|
---|
139 | // Get the number of frames per second.
|
---|
140 | //---------------------------------------------------------------------------
|
---|
141 | size_t GeoMeshView::getFPS()
|
---|
142 | {
|
---|
143 | return mFPS;
|
---|
144 | }
|
---|
145 |
|
---|
146 | //---------------------------------------------------------------------------
|
---|
147 | // Calculate the number of frames per second.
|
---|
148 | //---------------------------------------------------------------------------
|
---|
149 | void GeoMeshView::calcFPS()
|
---|
150 | {
|
---|
151 | double duration;
|
---|
152 | clock_t finish_time;
|
---|
153 |
|
---|
154 | // Gets the time.
|
---|
155 | finish_time = clock();
|
---|
156 |
|
---|
157 | // Calc the duration respect the start time.
|
---|
158 | duration = (double)((finish_time - mStartTime) / CLOCKS_PER_SEC);
|
---|
159 |
|
---|
160 | // Increments the number of frames per second.
|
---|
161 | mFPS++;
|
---|
162 |
|
---|
163 | // If a second have passed.
|
---|
164 | if (duration >= 1.0)
|
---|
165 | {
|
---|
166 | // Repaint the FPS.
|
---|
167 | mGeoMeshViewUI->refreshFPS(mFPS);
|
---|
168 |
|
---|
169 | mFPS = 0;
|
---|
170 | mStartTime = clock();
|
---|
171 | }
|
---|
172 | }
|
---|
173 |
|
---|
174 | //---------------------------------------------------------------------------
|
---|
175 | // Enable color strips.
|
---|
176 | //---------------------------------------------------------------------------
|
---|
177 | void GeoMeshView::enableColorStrips()
|
---|
178 | {
|
---|
179 | colorStripsFlag = true;
|
---|
180 | }
|
---|
181 |
|
---|
182 | //---------------------------------------------------------------------------
|
---|
183 | // Disable color strips.
|
---|
184 | //---------------------------------------------------------------------------
|
---|
185 | void GeoMeshView::disableColorStrips()
|
---|
186 | {
|
---|
187 | colorStripsFlag = false;
|
---|
188 | }
|
---|
189 |
|
---|
190 | //---------------------------------------------------------------------------
|
---|
191 | // Gets the color strips state.
|
---|
192 | //---------------------------------------------------------------------------
|
---|
193 | bool GeoMeshView::getColorStrips()
|
---|
194 | {
|
---|
195 | return colorStripsFlag;
|
---|
196 | }
|
---|
197 |
|
---|
198 | //---------------------------------------------------------------------------
|
---|
199 | // Set the color to the submesh sumbmeshIndex
|
---|
200 | //---------------------------------------------------------------------------
|
---|
201 | void GeoMeshView::setSubMeshSelected(int submeshIndex)
|
---|
202 | {
|
---|
203 | mSubMeshSelected = submeshIndex;
|
---|
204 | }
|
---|
205 |
|
---|
206 | //---------------------------------------------------------------------------
|
---|
207 | // Sets the leaves submesh index.
|
---|
208 | //---------------------------------------------------------------------------
|
---|
209 | void GeoMeshView::setLeavesSubMesh(int submeshIndex)
|
---|
210 | {
|
---|
211 | leavesSubMesh = submeshIndex;
|
---|
212 | }
|
---|
213 |
|
---|
214 | //---------------------------------------------------------------------------
|
---|
215 | // Gets the leaves submesh index.
|
---|
216 | //---------------------------------------------------------------------------
|
---|
217 | int GeoMeshView::getLeavesSubMesh()
|
---|
218 | {
|
---|
219 | return leavesSubMesh;
|
---|
220 | }
|
---|
221 |
|
---|
222 | //---------------------------------------------------------------------------
|
---|
223 | // Set the list of strip colors.
|
---|
224 | //---------------------------------------------------------------------------
|
---|
225 | void GeoMeshView::setStripColors()
|
---|
226 | {
|
---|
227 | SubMesh *geosubmesh;
|
---|
228 |
|
---|
229 | // Free memory of the strip colors array.
|
---|
230 | for (int submesh = 0; submesh < mStripColorsCount; submesh++)
|
---|
231 | {
|
---|
232 | delete []mStripColors[submesh];
|
---|
233 | }
|
---|
234 |
|
---|
235 | delete []mStripColors;
|
---|
236 |
|
---|
237 | // Initialize the Colors array.
|
---|
238 | mStripColors = new ColorElement*[geoMesh->mSubMeshCount];
|
---|
239 |
|
---|
240 | // Count the total number of strips y the submeshes.
|
---|
241 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
242 | {
|
---|
243 | // Gets the actual submesh.
|
---|
244 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
245 |
|
---|
246 | if (geosubmesh->mType == GEO_TRIANGLE_STRIPS)
|
---|
247 | {
|
---|
248 | mStripColors[submesh] = new ColorElement[geosubmesh->mStripCount];
|
---|
249 | }
|
---|
250 | else
|
---|
251 | {
|
---|
252 | mStripColors[submesh] = NULL;
|
---|
253 | }
|
---|
254 | }
|
---|
255 |
|
---|
256 |
|
---|
257 | // Sets random colors to each strip.
|
---|
258 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
259 | {
|
---|
260 | // Gets the actual submesh.
|
---|
261 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
262 |
|
---|
263 | if (geosubmesh->mType == GEO_TRIANGLE_STRIPS)
|
---|
264 | {
|
---|
265 | for (int strip = 0; strip < geosubmesh->mStripCount; strip++)
|
---|
266 | {
|
---|
267 | mStripColors[submesh][strip].r = rand()/((float)RAND_MAX);
|
---|
268 | mStripColors[submesh][strip].g = rand()/((float)RAND_MAX);
|
---|
269 | mStripColors[submesh][strip].b = rand()/((float)RAND_MAX);
|
---|
270 | }
|
---|
271 | }
|
---|
272 | }
|
---|
273 |
|
---|
274 | // Sets the submesh count.
|
---|
275 | mStripColorsCount = geoMesh->mSubMeshCount;
|
---|
276 | }
|
---|
277 |
|
---|
278 | /*
|
---|
279 | //---------------------------------------------------------------------------
|
---|
280 | // Get the bounding box of the object.
|
---|
281 | //---------------------------------------------------------------------------
|
---|
282 | GeometryBounds GeoMeshView::getBoundingBox()
|
---|
283 | {
|
---|
284 | SubMesh *geosubmesh;
|
---|
285 | Index position;
|
---|
286 | Vector3 vector3;
|
---|
287 | GeometryBounds bounds;
|
---|
288 | float x,y,z;
|
---|
289 | float xMin,yMin,zMin;
|
---|
290 | float xMax,yMax,zMax;
|
---|
291 |
|
---|
292 | // For each submesh.
|
---|
293 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
294 | {
|
---|
295 | // Gets the actual submesh.
|
---|
296 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
297 |
|
---|
298 | // For each index of the strip.
|
---|
299 | for (int index = 0; index < geosubmesh->mIndexCount; index++)
|
---|
300 | {
|
---|
301 | position = geosubmesh->mIndex[index];
|
---|
302 |
|
---|
303 | // Gets the vertex coordinates.
|
---|
304 | vector3 = geosubmesh->mVertexBuffer->mPosition[position];
|
---|
305 |
|
---|
306 | x = vector3[0];
|
---|
307 | y = vector3[1];
|
---|
308 | z = vector3[2];
|
---|
309 |
|
---|
310 | // If is the first iteation.
|
---|
311 | if ((submesh == 0) && (index == 0))
|
---|
312 | {
|
---|
313 | xMin = xMax = x;
|
---|
314 | yMin = yMax = y;
|
---|
315 | zMin = zMax = z;
|
---|
316 | }
|
---|
317 | else
|
---|
318 | {
|
---|
319 | if (x < xMin)
|
---|
320 | {
|
---|
321 | xMin = x;
|
---|
322 | }
|
---|
323 | else if (x > xMax)
|
---|
324 | {
|
---|
325 | xMax = x;
|
---|
326 | }
|
---|
327 |
|
---|
328 | if (y < yMin)
|
---|
329 | {
|
---|
330 | yMin = y;
|
---|
331 | }
|
---|
332 | else if (y > yMax)
|
---|
333 | {
|
---|
334 | yMax = y;
|
---|
335 | }
|
---|
336 |
|
---|
337 | if (z < zMin)
|
---|
338 | {
|
---|
339 | zMin = z;
|
---|
340 | }
|
---|
341 | else if (z > zMax)
|
---|
342 | {
|
---|
343 | zMax = z;
|
---|
344 | }
|
---|
345 | }
|
---|
346 | }
|
---|
347 | }
|
---|
348 |
|
---|
349 | xMed = (xMax + xMin) / 2;
|
---|
350 | yMed = (yMax + yMin) / 2;
|
---|
351 | zMed = (zMax + zMin) / 2;
|
---|
352 |
|
---|
353 |
|
---|
354 | if ((xMax - xMin) > (yMax - yMin))
|
---|
355 | {
|
---|
356 | if ((xMax - xMin) > (zMax - zMin))
|
---|
357 | {
|
---|
358 | mScaleFactor = xMax - xMin;
|
---|
359 | }
|
---|
360 | else
|
---|
361 | {
|
---|
362 | mScaleFactor = zMax - zMin;
|
---|
363 | }
|
---|
364 | }
|
---|
365 | else
|
---|
366 | {
|
---|
367 | if ((yMax - yMin) > (zMax - zMin))
|
---|
368 | {
|
---|
369 | mScaleFactor = yMax - yMin;
|
---|
370 | }
|
---|
371 | else
|
---|
372 | {
|
---|
373 | mScaleFactor = zMax - zMin;
|
---|
374 | }
|
---|
375 | }
|
---|
376 |
|
---|
377 | // Set the bounds.
|
---|
378 | bounds.minx = xMin;
|
---|
379 | bounds.miny = yMin;
|
---|
380 | bounds.minz = zMin;
|
---|
381 | bounds.maxx = xMax;
|
---|
382 | bounds.maxy = yMax;
|
---|
383 | bounds.maxz = zMax;
|
---|
384 | bounds.radius = mScaleFactor;
|
---|
385 |
|
---|
386 | return bounds;
|
---|
387 | }
|
---|
388 | */
|
---|
389 |
|
---|
390 | //---------------------------------------------------------------------------
|
---|
391 | // Constructor.
|
---|
392 | //---------------------------------------------------------------------------
|
---|
393 | GeoMeshView::GeoMeshView( int x,
|
---|
394 | int y,
|
---|
395 | int w,
|
---|
396 | int h,
|
---|
397 | const char *l,
|
---|
398 | GeoMeshViewUI *geoMeshViewUI)
|
---|
399 | : fltk::GlWindow(x,y,w,h,l)
|
---|
400 | {
|
---|
401 | mStripColors = NULL;
|
---|
402 | mSharedPosArray = NULL;
|
---|
403 | mSharedNorArray = NULL;
|
---|
404 | mPosArray = NULL;
|
---|
405 | mNorArray = NULL;
|
---|
406 | mIndexArray = NULL;
|
---|
407 | vAng = 0.0;
|
---|
408 | hAng = 0.0;
|
---|
409 | size = 0.0;
|
---|
410 | mSizeY = 0;
|
---|
411 | xshift = 0.0;
|
---|
412 | yshift = 0.0;
|
---|
413 | geoMesh = 0;
|
---|
414 | mRotate = true;
|
---|
415 | mPan = false;
|
---|
416 | mLodStrip = false;
|
---|
417 | mLodTree = false;
|
---|
418 | mIdVisualList = 0;
|
---|
419 | mSubMeshCount = 0;
|
---|
420 | mStripColorsCount = 0;
|
---|
421 |
|
---|
422 | // Initialize the model view.
|
---|
423 | deactiveWire();
|
---|
424 | deactiveSolid();
|
---|
425 | activeRotate();
|
---|
426 | deactiveCW();
|
---|
427 | activeCCW();
|
---|
428 |
|
---|
429 | // Initialize start time for FPS.
|
---|
430 | mStartTime = clock();
|
---|
431 |
|
---|
432 | // Cross Reference.
|
---|
433 | mGeoMeshViewUI = geoMeshViewUI;
|
---|
434 | }
|
---|
435 |
|
---|
436 | // The color used for the edges of the bounding cube.
|
---|
437 | #define CUBECOLOR 255,255,255,255
|
---|
438 |
|
---|
439 | /* Draw a colored cube */
|
---|
440 | #define ALPHA 0.5
|
---|
441 |
|
---|
442 | //---------------------------------------------------------------------------
|
---|
443 | // Sets the Mesh to display.
|
---|
444 | //---------------------------------------------------------------------------
|
---|
445 | void GeoMeshView::setMesh(Mesh *geomesh)
|
---|
446 | {
|
---|
447 | GLfloat color_blanco[] = {1.0f,1.0f,1.0f,1.0f};
|
---|
448 |
|
---|
449 | this->geoMesh = geomesh;
|
---|
450 | mSubMeshSelected = -1;
|
---|
451 | leavesSubMesh = -1;
|
---|
452 | mScaleFactor = geomesh->mMeshBounds.scaleFactor;
|
---|
453 |
|
---|
454 | // Refresh vertices to the vertex array.
|
---|
455 | refreshVertices(geomesh);
|
---|
456 |
|
---|
457 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco);
|
---|
458 | }
|
---|
459 |
|
---|
460 | //---------------------------------------------------------------------------
|
---|
461 | // Refresh vertices to the vertex array.
|
---|
462 | //---------------------------------------------------------------------------
|
---|
463 | void GeoMeshView::refreshVertices(Mesh *geomesh)
|
---|
464 | {
|
---|
465 | SubMesh *geosubmesh;
|
---|
466 | VertexBuffer *vertex_buffer;
|
---|
467 |
|
---|
468 | // If the vertex array exists.
|
---|
469 | if (mSubMeshCount > 0)
|
---|
470 | {
|
---|
471 | for (int submesh = 0; submesh < mSubMeshCount; submesh++)
|
---|
472 | {
|
---|
473 | delete [] mPosArray[submesh];
|
---|
474 | delete [] mNorArray[submesh];
|
---|
475 | delete [] mIndexArray[submesh];
|
---|
476 | }
|
---|
477 |
|
---|
478 | delete [] mSharedPosArray;
|
---|
479 | delete [] mSharedNorArray;
|
---|
480 | delete [] mPosArray;
|
---|
481 | delete [] mNorArray;
|
---|
482 | delete [] mIndexArray;
|
---|
483 | }
|
---|
484 |
|
---|
485 | // If there is shared vertex.
|
---|
486 | if (geomesh->mVertexBuffer != NULL)
|
---|
487 | {
|
---|
488 | vertex_buffer = geomesh->mVertexBuffer;
|
---|
489 |
|
---|
490 | // Allocate memory.
|
---|
491 | mSharedPosArray = new GLfloat[vertex_buffer->mVertexCount * 3];
|
---|
492 | mSharedNorArray = new GLfloat[vertex_buffer->mVertexCount * 3];
|
---|
493 |
|
---|
494 | for (int vertex = 0; vertex < vertex_buffer->mVertexCount; vertex++)
|
---|
495 | {
|
---|
496 | mSharedPosArray[3 * vertex] = vertex_buffer->mPosition[vertex].x;
|
---|
497 | mSharedPosArray[(3 * vertex) + 1] = vertex_buffer->mPosition[vertex].y;
|
---|
498 | mSharedPosArray[(3 * vertex) + 2] = vertex_buffer->mPosition[vertex].z;
|
---|
499 |
|
---|
500 | mSharedNorArray[3 * vertex] = vertex_buffer->mNormal[vertex].x;
|
---|
501 | mSharedNorArray[(3 * vertex) + 1] = vertex_buffer->mNormal[vertex].y;
|
---|
502 | mSharedNorArray[(3 * vertex) + 2] = vertex_buffer->mNormal[vertex].z;
|
---|
503 | }
|
---|
504 | }
|
---|
505 |
|
---|
506 | // Build the arrays of vertices and indices.
|
---|
507 | mPosArray = new GLfloat*[geomesh->mSubMeshCount];
|
---|
508 | mNorArray = new GLfloat*[geomesh->mSubMeshCount];
|
---|
509 | mIndexArray = new GLuint*[geomesh->mSubMeshCount];
|
---|
510 |
|
---|
511 | // For each submesh.
|
---|
512 | for (int submesh = 0; submesh < geomesh->mSubMeshCount; submesh++)
|
---|
513 | {
|
---|
514 | // Gets the actual submesh.
|
---|
515 | geosubmesh = &geomesh->mSubMesh[submesh];
|
---|
516 |
|
---|
517 | // Allocate memory for index array of the actual submesh.
|
---|
518 | mIndexArray[submesh] = new GLuint[geosubmesh->mIndexCount];
|
---|
519 |
|
---|
520 | // Gets the indices of the actual submesh.
|
---|
521 | for (int index = 0; index < geosubmesh->mIndexCount; index++)
|
---|
522 | {
|
---|
523 | mIndexArray[submesh][index] = geosubmesh->mIndex[index];
|
---|
524 | }
|
---|
525 |
|
---|
526 | // If the submesh is NOT shared vertex.
|
---|
527 | if (!geosubmesh->mSharedVertexBuffer)
|
---|
528 | {
|
---|
529 | vertex_buffer = geosubmesh->mVertexBuffer;
|
---|
530 |
|
---|
531 | // Allocate memory for vertices of the actual submesh.
|
---|
532 | mPosArray[submesh] = new GLfloat[vertex_buffer->mVertexCount * 3];
|
---|
533 | mNorArray[submesh] = new GLfloat[vertex_buffer->mVertexCount * 3];
|
---|
534 |
|
---|
535 | // For each one of the vertex.
|
---|
536 | for (int vertex = 0; vertex < vertex_buffer->mVertexCount; vertex++)
|
---|
537 | {
|
---|
538 | mPosArray[submesh][3 * vertex] = vertex_buffer->mPosition[vertex].x;
|
---|
539 | mPosArray[submesh][(3 * vertex) + 1] = vertex_buffer->mPosition[vertex].y;
|
---|
540 | mPosArray[submesh][(3 * vertex) + 2] = vertex_buffer->mPosition[vertex].z;
|
---|
541 |
|
---|
542 | mNorArray[submesh][3 * vertex] = vertex_buffer->mNormal[vertex].x;
|
---|
543 | mNorArray[submesh][(3 * vertex) + 1] = vertex_buffer->mNormal[vertex].y;
|
---|
544 | mNorArray[submesh][(3 * vertex) + 2] = vertex_buffer->mNormal[vertex].z;
|
---|
545 | }// End for each vertex.
|
---|
546 | }
|
---|
547 | // If the submesh is shared vertex.
|
---|
548 | else
|
---|
549 | {
|
---|
550 | mPosArray[submesh] = NULL;
|
---|
551 | mNorArray[submesh] = NULL;
|
---|
552 | }
|
---|
553 |
|
---|
554 | }// End for each submesh.
|
---|
555 |
|
---|
556 | mSubMeshCount = geoMesh->mSubMeshCount;
|
---|
557 | }
|
---|
558 |
|
---|
559 | //---------------------------------------------------------------------------
|
---|
560 | // Gets the triangle count of the current lod.
|
---|
561 | //---------------------------------------------------------------------------
|
---|
562 | size_t GeoMeshView::getLodStripsTriangleCount()
|
---|
563 | {
|
---|
564 | size_t triangle_count;
|
---|
565 |
|
---|
566 | // Initialize triangle count.
|
---|
567 | triangle_count = 0;
|
---|
568 |
|
---|
569 | // For each strip.
|
---|
570 | for (int strip = 0; strip < lodStripsLib->GetStripCount(); strip++)
|
---|
571 | {
|
---|
572 | triangle_count += lodStripsLib->mStrips[strip].size() - 2;
|
---|
573 | }
|
---|
574 |
|
---|
575 | return triangle_count;
|
---|
576 | }
|
---|
577 |
|
---|
578 | //---------------------------------------------------------------------------
|
---|
579 | // Repaint the Mesh.
|
---|
580 | //---------------------------------------------------------------------------
|
---|
581 | void GeoMeshView::drawGeoMesh(bool paintWire)
|
---|
582 | {
|
---|
583 | SubMesh *geosubmesh;
|
---|
584 | bool submesh_selected;
|
---|
585 |
|
---|
586 | if (geoMesh)
|
---|
587 | {
|
---|
588 | if (mLodStrip)
|
---|
589 | {
|
---|
590 | drawLodStrip();
|
---|
591 | }
|
---|
592 | else if (mLodTree)
|
---|
593 | {
|
---|
594 | drawLodTree();
|
---|
595 | }
|
---|
596 | else
|
---|
597 | {
|
---|
598 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
599 | {
|
---|
600 | // Gets the actual submesh.
|
---|
601 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
602 |
|
---|
603 | if (geosubmesh->mType == GEO_TRIANGLE_LIST)
|
---|
604 | {
|
---|
605 | if (mSubMeshSelected == submesh)
|
---|
606 | {
|
---|
607 | submesh_selected = true;
|
---|
608 | }
|
---|
609 | else
|
---|
610 | {
|
---|
611 | submesh_selected = false;
|
---|
612 | }
|
---|
613 |
|
---|
614 | // Draw the actual submesh in triangle list.
|
---|
615 | drawTriangleList(submesh,submesh_selected,paintWire);
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | // Draw the actual submesh in triangle strip.
|
---|
620 | drawTriangleStrip(submesh);
|
---|
621 | }
|
---|
622 | }
|
---|
623 | }
|
---|
624 | }
|
---|
625 | }// End drawGeoMesh.
|
---|
626 |
|
---|
627 | //---------------------------------------------------------------------------
|
---|
628 | // Paint eah strip separately.
|
---|
629 | //---------------------------------------------------------------------------
|
---|
630 | void GeoMeshView::drawTriangleStrip(int submesh)
|
---|
631 | {
|
---|
632 | SubMesh *geosubmesh;
|
---|
633 | Index position;
|
---|
634 | Vector3 vector3;
|
---|
635 | float x,y,z;
|
---|
636 | float r,g,b;
|
---|
637 | Index *index;
|
---|
638 | Index *indexBegin;
|
---|
639 | Index *indexEnd;
|
---|
640 | int color_index;
|
---|
641 |
|
---|
642 | color_index = 0;
|
---|
643 |
|
---|
644 | // Gets the actual submesh.
|
---|
645 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
646 |
|
---|
647 | // For each one of the strips.
|
---|
648 | for (int strip = 0; strip < geosubmesh->mStripCount; strip++)
|
---|
649 | {
|
---|
650 | // Paint the current strip.
|
---|
651 | glBegin(GL_TRIANGLE_STRIP);
|
---|
652 |
|
---|
653 | // First index of the strip.
|
---|
654 | indexBegin = geosubmesh->mStrip[strip];
|
---|
655 |
|
---|
656 | // If the strips is not the first.
|
---|
657 | //if (strip != 0)
|
---|
658 | //{
|
---|
659 | // indexBegin++;
|
---|
660 | //}
|
---|
661 |
|
---|
662 | // If is the final strip
|
---|
663 | if (strip == (geosubmesh->mStripCount - 1))
|
---|
664 | {
|
---|
665 | // The end of the index array.
|
---|
666 | indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount];
|
---|
667 | }
|
---|
668 | else
|
---|
669 | {
|
---|
670 | // The beginning of the next strip.
|
---|
671 | indexEnd = geosubmesh->mStrip[strip + 1];
|
---|
672 |
|
---|
673 | // Remove degenerated
|
---|
674 | //indexEnd--;
|
---|
675 | }
|
---|
676 |
|
---|
677 | int i;
|
---|
678 | i = 0;
|
---|
679 |
|
---|
680 | if (getColorStrips())
|
---|
681 | {
|
---|
682 | // Gets the color of the strip.
|
---|
683 | r = mStripColors[submesh][color_index].r;
|
---|
684 | g = mStripColors[submesh][color_index].g;
|
---|
685 | b = mStripColors[submesh][color_index].b;
|
---|
686 |
|
---|
687 | // Change to the next color.
|
---|
688 | color_index++;
|
---|
689 |
|
---|
690 | // Paint a new color.
|
---|
691 | glColor3f(r,g,b);
|
---|
692 | }
|
---|
693 |
|
---|
694 | // For each index of the strip.
|
---|
695 | for (index = indexBegin; index < indexEnd; index++)
|
---|
696 | {
|
---|
697 | position = indexBegin[i];
|
---|
698 |
|
---|
699 | // Gets the vertex normal.
|
---|
700 | vector3 = geosubmesh->mVertexBuffer->mNormal[position];
|
---|
701 |
|
---|
702 | x = vector3[0];
|
---|
703 | y = vector3[1];
|
---|
704 | z = vector3[2];
|
---|
705 |
|
---|
706 | // Sets the vertex normal.
|
---|
707 | glNormal3f(x,y,z);
|
---|
708 |
|
---|
709 | // Gets the vertex coordinates.
|
---|
710 | vector3 = geosubmesh->mVertexBuffer->mPosition[position];
|
---|
711 |
|
---|
712 | x = vector3[0];
|
---|
713 | y = vector3[1];
|
---|
714 | z = vector3[2];
|
---|
715 |
|
---|
716 |
|
---|
717 | // Sets the vertex position.
|
---|
718 | glVertex3f(x,y,z);
|
---|
719 |
|
---|
720 | // Increments i.
|
---|
721 | i++;
|
---|
722 | }
|
---|
723 |
|
---|
724 | glEnd();
|
---|
725 |
|
---|
726 | }
|
---|
727 |
|
---|
728 | }//End drawTriangleStrip.
|
---|
729 |
|
---|
730 | //---------------------------------------------------------------------------
|
---|
731 | // Paint the array of idices.
|
---|
732 | //---------------------------------------------------------------------------
|
---|
733 | void GeoMeshView::drawTriangleList( int submesh,
|
---|
734 | bool selectedSubMesh,
|
---|
735 | bool paintWire)
|
---|
736 | {
|
---|
737 | SubMesh *geosubmesh;
|
---|
738 | Index position;
|
---|
739 | Vector3 vector3;
|
---|
740 | float x,y,z;
|
---|
741 | int idx_offset;
|
---|
742 | int vrt_offset;
|
---|
743 |
|
---|
744 | // Index offset.
|
---|
745 | idx_offset = 0;
|
---|
746 |
|
---|
747 | // Vertex offset.
|
---|
748 | vrt_offset = 0;
|
---|
749 |
|
---|
750 | // Gets the actual submesh.
|
---|
751 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
752 |
|
---|
753 | // If wire is not selected.
|
---|
754 | if (!paintWire)
|
---|
755 | {
|
---|
756 | // If a mesh is selected.
|
---|
757 | if (selectedSubMesh)
|
---|
758 | {
|
---|
759 | glColor3d(1.0,0.0,0.0);
|
---|
760 | GLfloat red[] = {1.0f,0.0f,0.0f,1.0f};
|
---|
761 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red);
|
---|
762 | }
|
---|
763 | // If is a tree.
|
---|
764 | else if (leavesSubMesh >= 0)
|
---|
765 | {
|
---|
766 | glColor3d(1.0, 0.5, 0.5);
|
---|
767 | GLfloat brown[] = {1.0f,0.5f,0.5f,1.0f};
|
---|
768 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown);
|
---|
769 |
|
---|
770 | // For each index of the strip.
|
---|
771 | if (submesh == leavesSubMesh)
|
---|
772 | {
|
---|
773 | glColor3d(0.0,1.0,0.0);
|
---|
774 | GLfloat green[] = {0.0f,1.0f,0.0f,1.0f};
|
---|
775 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green);
|
---|
776 | }
|
---|
777 | }
|
---|
778 | // If is NOT a tree.
|
---|
779 | else
|
---|
780 | {
|
---|
781 | // Set white color to the object.
|
---|
782 | glColor3d(1.0, 1.0, 1.0);
|
---|
783 | GLfloat white[] = {1.0f,1.0f,1.0f,1.0f};
|
---|
784 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white);
|
---|
785 | }
|
---|
786 | }
|
---|
787 |
|
---|
788 | // Enable arrays.
|
---|
789 | glEnableClientState(GL_VERTEX_ARRAY);
|
---|
790 | glEnableClientState(GL_NORMAL_ARRAY);
|
---|
791 |
|
---|
792 | // If the submesh is shared vertex.
|
---|
793 | if (geosubmesh->mSharedVertexBuffer)
|
---|
794 | {
|
---|
795 | glVertexPointer(3, GL_FLOAT, 0, mSharedPosArray);
|
---|
796 | glNormalPointer(GL_FLOAT, 0, mSharedNorArray);
|
---|
797 | }
|
---|
798 | else
|
---|
799 | {
|
---|
800 | glVertexPointer(3, GL_FLOAT, 0, mPosArray[submesh]);
|
---|
801 | glNormalPointer(GL_FLOAT, 0, mNorArray[submesh]);
|
---|
802 | }
|
---|
803 |
|
---|
804 | glDrawElements( GL_TRIANGLES,
|
---|
805 | geosubmesh->mIndexCount,
|
---|
806 | GL_UNSIGNED_INT,
|
---|
807 | mIndexArray[submesh]);
|
---|
808 |
|
---|
809 | }//End drawTriangleList
|
---|
810 |
|
---|
811 | //---------------------------------------------------------------------------
|
---|
812 | // Paint lodstrip object.
|
---|
813 | //---------------------------------------------------------------------------
|
---|
814 | void GeoMeshView::drawLodStrip()
|
---|
815 | {
|
---|
816 | SubMesh *geosubmesh;
|
---|
817 | Index position;
|
---|
818 | Vector3 vector3;
|
---|
819 | float x,y,z;
|
---|
820 | float r,g,b;
|
---|
821 | int color_index;
|
---|
822 | int current_strip;
|
---|
823 |
|
---|
824 | // Initialize current strip.
|
---|
825 | current_strip = 0;
|
---|
826 |
|
---|
827 | // For each submesh.
|
---|
828 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
829 | {
|
---|
830 |
|
---|
831 | color_index = 0;
|
---|
832 |
|
---|
833 | // Gets the actual submesh.
|
---|
834 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
835 |
|
---|
836 | // For each one of the strips.
|
---|
837 | for (int strip = 0; strip < geosubmesh->mStripCount; strip++)
|
---|
838 | {
|
---|
839 | // Paint the current strip.
|
---|
840 | glBegin(GL_TRIANGLE_STRIP);
|
---|
841 |
|
---|
842 | if (getColorStrips())
|
---|
843 | {
|
---|
844 | // Gets the color of the strip.
|
---|
845 | r = mStripColors[submesh][color_index].r;
|
---|
846 | g = mStripColors[submesh][color_index].g;
|
---|
847 | b = mStripColors[submesh][color_index].b;
|
---|
848 |
|
---|
849 | // Change to the next color.
|
---|
850 | color_index++;
|
---|
851 |
|
---|
852 | // Paint a new color.
|
---|
853 | glColor3f(r,g,b);
|
---|
854 | }
|
---|
855 |
|
---|
856 | // For each index of the strip.
|
---|
857 | for (int index = 0; index < lodStripsLib->mStrips[current_strip].size(); index++)
|
---|
858 | {
|
---|
859 | position = lodStripsLib->mStrips[current_strip][index];
|
---|
860 |
|
---|
861 | // Gets the vertex normal.
|
---|
862 | vector3 = geosubmesh->mVertexBuffer->mNormal[position];
|
---|
863 |
|
---|
864 | x = vector3[0];
|
---|
865 | y = vector3[1];
|
---|
866 | z = vector3[2];
|
---|
867 |
|
---|
868 | // Sets the vertex normal.
|
---|
869 | glNormal3f(x,y,z);
|
---|
870 |
|
---|
871 | // Gets the vertex coordinates.
|
---|
872 | vector3 = geosubmesh->mVertexBuffer->mPosition[position];
|
---|
873 |
|
---|
874 | x = vector3[0];
|
---|
875 | y = vector3[1];
|
---|
876 | z = vector3[2];
|
---|
877 |
|
---|
878 | // Sets the vertex position.
|
---|
879 | glVertex3f(x,y,z);
|
---|
880 | }
|
---|
881 |
|
---|
882 | // Increments current strip.
|
---|
883 | current_strip++;
|
---|
884 |
|
---|
885 | // A strip is generated.
|
---|
886 | glEnd();
|
---|
887 |
|
---|
888 | }
|
---|
889 | }
|
---|
890 |
|
---|
891 | }//End drawTriangleStrip.
|
---|
892 |
|
---|
893 |
|
---|
894 | //---------------------------------------------------------------------------
|
---|
895 | // Paint lodtree object.
|
---|
896 | //---------------------------------------------------------------------------
|
---|
897 | void GeoMeshView::drawLodTree()
|
---|
898 | {
|
---|
899 | SubMesh *geosubmesh;
|
---|
900 | Index position;
|
---|
901 | Vector3 vector3;
|
---|
902 | float x,y,z;
|
---|
903 | float r,g,b;
|
---|
904 | int color_index;
|
---|
905 | int current_strip;
|
---|
906 |
|
---|
907 | // Initialize current strip.
|
---|
908 | current_strip = 0;
|
---|
909 |
|
---|
910 |
|
---|
911 | // DRAW THE TRUNK AS A LODSTRIP OBJECT
|
---|
912 |
|
---|
913 | // For each submesh.
|
---|
914 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++)
|
---|
915 | {
|
---|
916 |
|
---|
917 | color_index = 0;
|
---|
918 |
|
---|
919 | // Gets the actual submesh.
|
---|
920 | geosubmesh = &geoMesh->mSubMesh[submesh];
|
---|
921 |
|
---|
922 | // For each one of the strips.
|
---|
923 | for (int strip = 0; strip < geosubmesh->mStripCount; strip++)
|
---|
924 | {
|
---|
925 | // Paint the current strip.
|
---|
926 | glBegin(GL_TRIANGLE_STRIP);
|
---|
927 |
|
---|
928 | if (getColorStrips())
|
---|
929 | {
|
---|
930 | // Gets the color of the strip.
|
---|
931 | r = mStripColors[submesh][color_index].r;
|
---|
932 | g = mStripColors[submesh][color_index].g;
|
---|
933 | b = mStripColors[submesh][color_index].b;
|
---|
934 |
|
---|
935 | // Change to the next color.
|
---|
936 | color_index++;
|
---|
937 |
|
---|
938 | // Paint a new color.
|
---|
939 | glColor3f(r,g,b);
|
---|
940 | }
|
---|
941 |
|
---|
942 | // For each index of the strip.
|
---|
943 | for (int index = 0; index < lodTreeLib->GetStrip(current_strip).size(); index++)
|
---|
944 | {
|
---|
945 | position = lodTreeLib->GetStrip(current_strip)[index];
|
---|
946 |
|
---|
947 | // Gets the vertex normal.
|
---|
948 | vector3 = geosubmesh->mVertexBuffer->mNormal[position];
|
---|
949 |
|
---|
950 | x = vector3[0];
|
---|
951 | y = vector3[1];
|
---|
952 | z = vector3[2];
|
---|
953 |
|
---|
954 | // Sets the vertex normal.
|
---|
955 | glNormal3f(x,y,z);
|
---|
956 |
|
---|
957 | // Gets the vertex coordinates.
|
---|
958 | vector3 = geosubmesh->mVertexBuffer->mPosition[position];
|
---|
959 |
|
---|
960 | x = vector3[0];
|
---|
961 | y = vector3[1];
|
---|
962 | z = vector3[2];
|
---|
963 |
|
---|
964 | // Sets the vertex position.
|
---|
965 | glVertex3f(x,y,z);
|
---|
966 | }
|
---|
967 |
|
---|
968 | // Increments current strip.
|
---|
969 | current_strip++;
|
---|
970 |
|
---|
971 | // A strip is generated.
|
---|
972 | glEnd();
|
---|
973 |
|
---|
974 | }
|
---|
975 | }
|
---|
976 |
|
---|
977 | // DRAW THE LEAVES AS A TRIANGLE SOUP
|
---|
978 | glColor3f(0,1,1);
|
---|
979 | glDisable(GL_LIGHTING);
|
---|
980 | glBegin(GL_TRIANGLES);
|
---|
981 | const Geometry::VertexData *foliage_verts = lodTreeLib->Get_Foliage_VertexData();
|
---|
982 | const Geometry::IndexData *foliage_inds = lodTreeLib->CurrentLOD_Foliage_Indices();
|
---|
983 | for (int j=0; j<lodTreeLib->CurrentLOD_Foliage_IndexCount(); j++)
|
---|
984 | {
|
---|
985 | float vx,vy,vz;
|
---|
986 | foliage_verts->GetVertexCoord(foliage_inds->GetIndex(j),vx,vy,vz);
|
---|
987 | glVertex3f(vx,vy,vz);
|
---|
988 | }
|
---|
989 | glEnd();
|
---|
990 |
|
---|
991 | glEnable(GL_LIGHTING);
|
---|
992 | glColor3f(1,1,1);
|
---|
993 |
|
---|
994 | }//End drawTriangleStrip.
|
---|
995 |
|
---|
996 |
|
---|
997 |
|
---|
998 | //---------------------------------------------------------------------------
|
---|
999 | // Sets the lodstripslibrary object.
|
---|
1000 | //---------------------------------------------------------------------------
|
---|
1001 | void GeoMeshView::setLodStripsLibrary(LodStripsLibrary *lodstrips)
|
---|
1002 | {
|
---|
1003 | lodStripsLib = lodstrips;
|
---|
1004 | activeLodStrip();
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | //---------------------------------------------------------------------------
|
---|
1008 | // Sets the lodtreeslibrary object.
|
---|
1009 | //---------------------------------------------------------------------------
|
---|
1010 | void GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees)
|
---|
1011 | {
|
---|
1012 | lodTreeLib = lodtrees;
|
---|
1013 | activeLodTree();
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | //---------------------------------------------------------------------------
|
---|
1017 | // Change de Level of detail of the object.
|
---|
1018 | //---------------------------------------------------------------------------
|
---|
1019 | void GeoMeshView::GoToLod_LodStrip(unsigned int lod)
|
---|
1020 | {
|
---|
1021 | if (mLodStrip)
|
---|
1022 | lodStripsLib->GoToLod(lod);
|
---|
1023 | if (mLodTree)
|
---|
1024 | lodTreeLib->GoToTrunkLod(lod);
|
---|
1025 | draw();
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | //---------------------------------------------------------------------------
|
---|
1029 | // Change de Level of detail of the object.
|
---|
1030 | //---------------------------------------------------------------------------
|
---|
1031 | void GeoMeshView::GoToLod_LodTree(unsigned int lod)
|
---|
1032 | {
|
---|
1033 | if (mLodTree)
|
---|
1034 | lodTreeLib->GoToFoliageLod(lod);
|
---|
1035 | draw();
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 |
|
---|
1039 | //---------------------------------------------------------------------------
|
---|
1040 | // Draw the object in the window.
|
---|
1041 | //---------------------------------------------------------------------------
|
---|
1042 | void GeoMeshView::draw()
|
---|
1043 | {
|
---|
1044 | glMatrixMode(GL_PROJECTION);
|
---|
1045 | glLoadIdentity();
|
---|
1046 |
|
---|
1047 | glEnable(GL_LIGHTING);
|
---|
1048 |
|
---|
1049 | // Frustrum.
|
---|
1050 | glViewport(0,0,w(),h());
|
---|
1051 | gluPerspective(60,(float)w()/(float)h(),0.1,1000);
|
---|
1052 |
|
---|
1053 | glMatrixMode(GL_MODELVIEW);
|
---|
1054 | glLoadIdentity();
|
---|
1055 |
|
---|
1056 | glEnable(GL_BLEND);
|
---|
1057 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
---|
1058 |
|
---|
1059 | GLfloat light_ambient[] = {0.3,0.3,0.3,1.0};
|
---|
1060 | GLfloat luzpos[] = {0.0,0.0,1.0,0.0};
|
---|
1061 | GLfloat luzcolor[] = {1.0,1.0,1.0,1.0};
|
---|
1062 |
|
---|
1063 | // glLightModelfv(GL_LIGHT_MODEL_AMBIENT, light_ambient);
|
---|
1064 | glEnable(GL_LIGHT0);
|
---|
1065 | glLightfv(GL_LIGHT0, GL_POSITION, luzpos);
|
---|
1066 | glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
---|
1067 | glLightfv(GL_LIGHT0, GL_DIFFUSE, luzcolor);
|
---|
1068 | glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1);
|
---|
1069 | glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0);
|
---|
1070 | glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0);
|
---|
1071 |
|
---|
1072 | glEnable (GL_POLYGON_OFFSET_LINE);
|
---|
1073 | glPolygonOffset(-1,-1);
|
---|
1074 | glEnable(GL_DEPTH_TEST);
|
---|
1075 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
---|
1076 |
|
---|
1077 | gluLookAt(0,0,2/*mScaleFactor*/ + size * 0.25, 0,0,0, 0,1,0);
|
---|
1078 |
|
---|
1079 | glTranslatef(xshift,yshift,0);
|
---|
1080 | glRotatef(hAng,0,1,0);
|
---|
1081 | glRotatef(vAng,1,0,0);
|
---|
1082 | //glTranslatef(-xMed,-yMed,-zMed);
|
---|
1083 |
|
---|
1084 | // Set white color to the object.
|
---|
1085 | glColor3d(1.0, 1.0, 1.0);
|
---|
1086 | GLfloat color_blanco[] = {1.0f,1.0f,1.0f,1.0f};
|
---|
1087 | glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco);
|
---|
1088 |
|
---|
1089 | glClearColor(0,0,0,0);
|
---|
1090 |
|
---|
1091 | if (mCW)
|
---|
1092 | {
|
---|
1093 | glFrontFace(GL_CW);
|
---|
1094 | glEnable(GL_CULL_FACE);
|
---|
1095 | }
|
---|
1096 | else
|
---|
1097 | {
|
---|
1098 | if (mCCW)
|
---|
1099 | {
|
---|
1100 | glFrontFace(GL_CCW);
|
---|
1101 | glEnable(GL_CULL_FACE);
|
---|
1102 | }
|
---|
1103 | else
|
---|
1104 | {
|
---|
1105 | glDisable(GL_CULL_FACE);
|
---|
1106 | }
|
---|
1107 | }
|
---|
1108 |
|
---|
1109 | if (mSolid)
|
---|
1110 | {
|
---|
1111 | enableColorStrips();
|
---|
1112 | glDisable(GL_LIGHTING);
|
---|
1113 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
---|
1114 | drawGeoMesh(false);
|
---|
1115 | }
|
---|
1116 | else
|
---|
1117 | {
|
---|
1118 | glEnable(GL_LIGHTING);
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | if (mWire)
|
---|
1122 | {
|
---|
1123 | disableColorStrips();
|
---|
1124 | glDisable(GL_LIGHTING);
|
---|
1125 | glColor3d(0.0, 0.0, 1.0);
|
---|
1126 | glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
---|
1127 | drawGeoMesh(true);
|
---|
1128 | }
|
---|
1129 | else
|
---|
1130 | {
|
---|
1131 | if (!mSolid)
|
---|
1132 | {
|
---|
1133 | enableColorStrips();
|
---|
1134 | glEnable(GL_LIGHTING);
|
---|
1135 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
---|
1136 | drawGeoMesh(false);
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | swap_buffers();
|
---|
1141 |
|
---|
1142 | // Calculate the FPS.
|
---|
1143 | calcFPS();
|
---|
1144 | }
|
---|
1145 |
|
---|