1 | // generated by Fast Light User Interface Designer (fluid) version 2.0100 |
---|
2 | |
---|
3 | #include "GeoMeshViewUI.h" |
---|
4 | #include "resource.h" |
---|
5 | #include "GeoLodTreeConstructor.h" |
---|
6 | #include <string.h> |
---|
7 | |
---|
8 | using namespace Geometry; |
---|
9 | using namespace std; |
---|
10 | |
---|
11 | //------------------------------------------------------------------------- |
---|
12 | // Menu File Open Callback |
---|
13 | //------------------------------------------------------------------------- |
---|
14 | inline void GeoMeshViewUI::cb_menuFileOpen_i(fltk::Item*, void*) |
---|
15 | { |
---|
16 | // Sets menus application state to NONE. |
---|
17 | mApplicationState = NONE; |
---|
18 | |
---|
19 | // Loads a mesh file. |
---|
20 | openMeshFile(); |
---|
21 | |
---|
22 | // Deactive Lod strip visualization. |
---|
23 | geoMeshView->deactiveLodStrip(); |
---|
24 | |
---|
25 | // Deactive Lod tree visualization. |
---|
26 | geoMeshView->deactiveLodTree(); |
---|
27 | |
---|
28 | //BuildLoadTextureSubMeshMenu(); |
---|
29 | |
---|
30 | // Repaint the window. |
---|
31 | mMainWindow->redraw(); |
---|
32 | } |
---|
33 | |
---|
34 | inline void GeoMeshViewUI::cb_menuFileLoadTexture_i(fltk::Item*, void*) |
---|
35 | { |
---|
36 | static char pattern[] = "*.{jpg|tga|png|bmp}"; |
---|
37 | |
---|
38 | fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); |
---|
39 | fcho->exec(); |
---|
40 | char filename[256]=""; |
---|
41 | if (fcho->value()) |
---|
42 | { |
---|
43 | strcpy(filename,fcho->value()); |
---|
44 | geoMeshView->LoadTexture(filename); |
---|
45 | |
---|
46 | // For each submesh. |
---|
47 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
48 | { |
---|
49 | geoMeshView->changeTexFile(i,filename); |
---|
50 | } |
---|
51 | |
---|
52 | // Refresh mesh. |
---|
53 | geoMeshView->setMesh(mGeoMesh); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | void GeoMeshViewUI::cb_menuFileLoadTexture(fltk::Item *o, void *v) |
---|
58 | { |
---|
59 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) |
---|
60 | -> |
---|
61 | cb_menuFileLoadTexture_i(o,v); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | inline void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh_i( fltk::Item *item, |
---|
66 | void *) |
---|
67 | { |
---|
68 | fltk::FileChooser *fcho; |
---|
69 | |
---|
70 | static char pattern[] = "*.{jpg|tga|png|bmp}"; |
---|
71 | |
---|
72 | const char *label = item->label(); |
---|
73 | int isubmesh = label[strlen(label)-1]-48; |
---|
74 | |
---|
75 | fcho = new fltk::FileChooser("", |
---|
76 | pattern, |
---|
77 | fltk::FileChooser::CREATE, |
---|
78 | "Open image file"); |
---|
79 | fcho->exec(); |
---|
80 | |
---|
81 | char filename[256] = ""; |
---|
82 | |
---|
83 | if (fcho->value()) |
---|
84 | { |
---|
85 | strcpy(filename,fcho->value()); |
---|
86 | |
---|
87 | geoMeshView->changeTexFile(isubmesh,filename); |
---|
88 | |
---|
89 | // Refresh mesh. |
---|
90 | geoMeshView->setMesh(mGeoMesh); |
---|
91 | } |
---|
92 | |
---|
93 | } |
---|
94 | |
---|
95 | void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh(fltk::Item *o, void *v) |
---|
96 | { |
---|
97 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) |
---|
98 | -> |
---|
99 | cb_menuFileLoadTextureSubMesh_i(o,v); |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | //------------------------------------------------------------------------- |
---|
105 | // Repaint the FPS label. |
---|
106 | //------------------------------------------------------------------------- |
---|
107 | void GeoMeshViewUI::refreshFPS(int fps) |
---|
108 | { |
---|
109 | static char char_value[10]; |
---|
110 | |
---|
111 | // Translate the FPS count to a char value. |
---|
112 | sprintf(char_value,"FPS %d",fps); |
---|
113 | |
---|
114 | mFPS->label(char_value); |
---|
115 | |
---|
116 | // Repaint the window. |
---|
117 | mMainWindow->redraw(); |
---|
118 | } |
---|
119 | |
---|
120 | void GeoMeshViewUI::cb_menuFileOpen(fltk::Item* o, void* v) |
---|
121 | { |
---|
122 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
123 | -> |
---|
124 | cb_menuFileOpen_i(o,v); |
---|
125 | } |
---|
126 | |
---|
127 | //------------------------------------------------------------------------- |
---|
128 | // Save callback |
---|
129 | //------------------------------------------------------------------------- |
---|
130 | inline void GeoMeshViewUI::cb_menuFileSave_i(fltk::Item*, void*) |
---|
131 | { |
---|
132 | GeoMeshSaver *mesh_saver; |
---|
133 | |
---|
134 | // If there is a mesh object created. |
---|
135 | if (mGeoMesh != NULL) |
---|
136 | { |
---|
137 | // Create a mesh saver with mesh bounds. |
---|
138 | mesh_saver = new GeoMeshSaver(); |
---|
139 | |
---|
140 | // Save the file mesh. |
---|
141 | mesh_saver->save(mGeoMesh, mFileName); |
---|
142 | |
---|
143 | // Free memory. |
---|
144 | delete mesh_saver; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | void GeoMeshViewUI::cb_menuFileSave(fltk::Item* o, void* v) |
---|
149 | { |
---|
150 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
151 | -> |
---|
152 | cb_menuFileSave_i(o,v); |
---|
153 | } |
---|
154 | |
---|
155 | //------------------------------------------------------------------------- |
---|
156 | // Save As Callback |
---|
157 | //------------------------------------------------------------------------- |
---|
158 | inline void GeoMeshViewUI::cb_menuFileSaveAs_i(fltk::Item*, void*) |
---|
159 | { |
---|
160 | fltk::FileChooser *fcho; |
---|
161 | GeoMeshSaver *mesh_saver; |
---|
162 | char file_name[255]; |
---|
163 | char message[255]; |
---|
164 | char *ptr; |
---|
165 | int answer_yes; |
---|
166 | |
---|
167 | // Initialize answer to yes. |
---|
168 | answer_yes = 1; |
---|
169 | |
---|
170 | if (mGeoMesh != NULL) |
---|
171 | { |
---|
172 | fcho = new fltk::FileChooser("", |
---|
173 | "*.mesh", |
---|
174 | fltk::FileChooser::CREATE, |
---|
175 | "Save Mesh as"); |
---|
176 | |
---|
177 | fcho->exec(); |
---|
178 | |
---|
179 | if (fcho->value()) |
---|
180 | { |
---|
181 | // Gets file name. |
---|
182 | strcpy(file_name,fcho->value()); |
---|
183 | |
---|
184 | // Cut extension. |
---|
185 | ptr = strtok(file_name,"."); |
---|
186 | |
---|
187 | // If has extension. |
---|
188 | if (ptr) |
---|
189 | { |
---|
190 | strcpy(file_name,ptr); |
---|
191 | } |
---|
192 | |
---|
193 | // Adds mesh extension. |
---|
194 | strcat(file_name,".mesh"); |
---|
195 | |
---|
196 | // If File Exists. |
---|
197 | if (fileExists(file_name)) |
---|
198 | { |
---|
199 | // Compose message. |
---|
200 | strcpy(message,"Do you want to replace "); |
---|
201 | strcat(message,filename_name(file_name)); |
---|
202 | strcat(message,"?"); |
---|
203 | |
---|
204 | // Question. |
---|
205 | answer_yes = fltk::ask(message); |
---|
206 | } |
---|
207 | |
---|
208 | // If answer yes to replace question |
---|
209 | // or if file not exists. |
---|
210 | if (answer_yes) |
---|
211 | { |
---|
212 | mesh_saver = new GeoMeshSaver(); |
---|
213 | |
---|
214 | // Debug. |
---|
215 | mGeoMesh = mGeoMesh->toSharedVertex(); |
---|
216 | //------------------------------------- |
---|
217 | |
---|
218 | mesh_saver->save(mGeoMesh,file_name); |
---|
219 | |
---|
220 | delete mesh_saver; |
---|
221 | } |
---|
222 | } |
---|
223 | // Repaint the window. |
---|
224 | mMainWindow->redraw(); |
---|
225 | |
---|
226 | delete fcho; |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | void GeoMeshViewUI::cb_menuFileSaveAs(fltk::Item* o, void* v) |
---|
231 | { |
---|
232 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
233 | -> |
---|
234 | cb_menuFileSaveAs_i(o,v); |
---|
235 | } |
---|
236 | |
---|
237 | //------------------------------------------------------------------------- |
---|
238 | // Mesh info callback |
---|
239 | //------------------------------------------------------------------------- |
---|
240 | inline void GeoMeshViewUI::cb_menuMeshInfo_i(fltk::Item*, void*) |
---|
241 | { |
---|
242 | // Show title. |
---|
243 | mProcessTitle->label("Mesh Info"); |
---|
244 | |
---|
245 | showMeshInfo(); |
---|
246 | mMainWindow->redraw(); |
---|
247 | } |
---|
248 | |
---|
249 | void GeoMeshViewUI::cb_menuMeshInfo(fltk::Item* o, void* v) |
---|
250 | { |
---|
251 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
252 | -> |
---|
253 | cb_menuMeshInfo_i(o,v); |
---|
254 | } |
---|
255 | |
---|
256 | //------------------------------------------------------------------------- |
---|
257 | // Mesh Export to OBJ callback |
---|
258 | //------------------------------------------------------------------------- |
---|
259 | inline void GeoMeshViewUI::cb_menuMeshExportOBJ_i(fltk::Item*, void*) |
---|
260 | { |
---|
261 | char *p; |
---|
262 | |
---|
263 | // Sets menus application state to NONE. |
---|
264 | mApplicationState = NONE; |
---|
265 | |
---|
266 | // Open file chooser dialog. |
---|
267 | p = fltk::file_chooser("Export to OBJ","*.obj",""); |
---|
268 | if (p && mGeoMesh) |
---|
269 | { |
---|
270 | mGeoMesh->exportToOBJ(p); |
---|
271 | } |
---|
272 | } |
---|
273 | |
---|
274 | void GeoMeshViewUI::cb_menuMeshExportOBJ(fltk::Item* o, void* v) |
---|
275 | { |
---|
276 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
277 | -> |
---|
278 | cb_menuMeshExportOBJ_i(o,v); |
---|
279 | } |
---|
280 | |
---|
281 | //------------------------------------------------------------------------- |
---|
282 | // Transform to Shared Vertex callback |
---|
283 | //------------------------------------------------------------------------- |
---|
284 | inline void GeoMeshViewUI::cb_menuTransformSharedVertex_i(fltk::Item *, |
---|
285 | void *) |
---|
286 | { |
---|
287 | Mesh *mesh_aux; |
---|
288 | |
---|
289 | // if the undo mesh is not initialized. |
---|
290 | if (mGeoMesh != NULL) |
---|
291 | { |
---|
292 | // Deletes the actual mesh. |
---|
293 | delete mUndoMesh; |
---|
294 | |
---|
295 | mUndoMesh = new Mesh(); |
---|
296 | |
---|
297 | // Restore the previous mesh. |
---|
298 | *mUndoMesh = *mGeoMesh; |
---|
299 | |
---|
300 | // Transform NoSV Mesh to a SV Mesh. |
---|
301 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
302 | |
---|
303 | // Deletes the mesh No Shared Vertex. |
---|
304 | delete mGeoMesh; |
---|
305 | |
---|
306 | // Gets the mesh Shared Vertex. |
---|
307 | mGeoMesh = mesh_aux; |
---|
308 | |
---|
309 | // Visualize the mesh stripified. |
---|
310 | geoMeshView->setMesh(mGeoMesh); |
---|
311 | |
---|
312 | // Refresh mesh information. |
---|
313 | showMeshInfo(); |
---|
314 | |
---|
315 | // Repaint the window. |
---|
316 | mMainWindow->redraw(); |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | void GeoMeshViewUI::cb_menuFileTransformSharedVertex(fltk::Item* o, void* v) |
---|
321 | { |
---|
322 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
323 | -> |
---|
324 | cb_menuTransformSharedVertex_i(o,v); |
---|
325 | } |
---|
326 | |
---|
327 | //------------------------------------------------------------------------- |
---|
328 | // Quit Callback |
---|
329 | //------------------------------------------------------------------------- |
---|
330 | inline void GeoMeshViewUI::cb_menuFileQuit_i(fltk::Item*, void*) |
---|
331 | { |
---|
332 | delete this; |
---|
333 | } |
---|
334 | |
---|
335 | void GeoMeshViewUI::cb_menuFileQuit(fltk::Item* o, void* v) |
---|
336 | { |
---|
337 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
338 | -> |
---|
339 | cb_menuFileQuit_i(o,v); |
---|
340 | } |
---|
341 | |
---|
342 | //------------------------------------------------------------------------- |
---|
343 | // Undo Callback |
---|
344 | //------------------------------------------------------------------------- |
---|
345 | inline void GeoMeshViewUI::cb_menuEditUndo_i(fltk::Item*, void*) |
---|
346 | { |
---|
347 | // Undo the mesh changes. |
---|
348 | undo(); |
---|
349 | } |
---|
350 | |
---|
351 | void GeoMeshViewUI::cb_menuEditUndo(fltk::Item* o, void* v) |
---|
352 | { |
---|
353 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
354 | -> |
---|
355 | cb_menuEditUndo_i(o,v); |
---|
356 | } |
---|
357 | |
---|
358 | //------------------------------------------------------------------------- |
---|
359 | // Fit Callback |
---|
360 | //------------------------------------------------------------------------- |
---|
361 | inline void GeoMeshViewUI::cb_menuEditFit_i(fltk::Item*, void*) |
---|
362 | { |
---|
363 | geoMeshView->fit(); |
---|
364 | mMainWindow->redraw(); |
---|
365 | } |
---|
366 | |
---|
367 | void GeoMeshViewUI::cb_menuEditFit(fltk::Item* o, void* v) |
---|
368 | { |
---|
369 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
370 | -> |
---|
371 | cb_menuEditFit_i(o,v); |
---|
372 | } |
---|
373 | |
---|
374 | //------------------------------------------------------------------------- |
---|
375 | // Rotate Callback |
---|
376 | //------------------------------------------------------------------------- |
---|
377 | inline void GeoMeshViewUI::cb_menuEditRotate_i(fltk::Item *item, void*) |
---|
378 | { |
---|
379 | // If the item is activated. |
---|
380 | if (item->value()) |
---|
381 | { |
---|
382 | menuEditPan->clear_value(); |
---|
383 | geoMeshView->deactivePan(); |
---|
384 | |
---|
385 | geoMeshView->activeRotate(); |
---|
386 | } |
---|
387 | else |
---|
388 | { |
---|
389 | menuEditPan->set_value(); |
---|
390 | geoMeshView->activePan(); |
---|
391 | |
---|
392 | geoMeshView->deactiveRotate(); |
---|
393 | } |
---|
394 | |
---|
395 | // Repaint the main window. |
---|
396 | mMainWindow->redraw(); |
---|
397 | } |
---|
398 | |
---|
399 | void GeoMeshViewUI::cb_menuEditRotate(fltk::Item* o, void* v) |
---|
400 | { |
---|
401 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
402 | -> |
---|
403 | cb_menuEditRotate_i(o,v); |
---|
404 | } |
---|
405 | |
---|
406 | //------------------------------------------------------------------------- |
---|
407 | // Pan Callback |
---|
408 | //------------------------------------------------------------------------- |
---|
409 | inline void GeoMeshViewUI::cb_menuEditPan_i(fltk::Item *item, void*) |
---|
410 | { |
---|
411 | // If the item is activated. |
---|
412 | if (item->value()) |
---|
413 | { |
---|
414 | geoMeshView->activePan(); |
---|
415 | |
---|
416 | menuEditRotate->clear_value(); |
---|
417 | geoMeshView->deactiveRotate(); |
---|
418 | } |
---|
419 | else |
---|
420 | { |
---|
421 | geoMeshView->deactivePan(); |
---|
422 | |
---|
423 | menuEditRotate->set_value(); |
---|
424 | geoMeshView->activeRotate(); |
---|
425 | } |
---|
426 | |
---|
427 | // Repaint the main window. |
---|
428 | mMainWindow->redraw(); |
---|
429 | } |
---|
430 | |
---|
431 | void GeoMeshViewUI::cb_menuEditPan(fltk::Item* o, void* v) |
---|
432 | { |
---|
433 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
434 | -> |
---|
435 | cb_menuEditPan_i(o,v); |
---|
436 | } |
---|
437 | |
---|
438 | //------------------------------------------------------------------------- |
---|
439 | // Zoom Callback |
---|
440 | //------------------------------------------------------------------------- |
---|
441 | inline void GeoMeshViewUI::cb_menuEditZoom_i(fltk::Item*, void*) |
---|
442 | { |
---|
443 | } |
---|
444 | |
---|
445 | void GeoMeshViewUI::cb_menuEditZoom(fltk::Item* o, void* v) |
---|
446 | { |
---|
447 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
448 | -> |
---|
449 | cb_menuEditZoom_i(o,v); |
---|
450 | } |
---|
451 | |
---|
452 | //------------------------------------------------------------------------- |
---|
453 | // Wire Callback |
---|
454 | //------------------------------------------------------------------------- |
---|
455 | inline void GeoMeshViewUI::cb_menuRenderWire_i(fltk::Item *item, void*) |
---|
456 | { |
---|
457 | if (item->value()) |
---|
458 | { |
---|
459 | geoMeshView->activeWire(); |
---|
460 | } |
---|
461 | else |
---|
462 | { |
---|
463 | geoMeshView->deactiveWire(); |
---|
464 | } |
---|
465 | |
---|
466 | // Repaint the canvas. |
---|
467 | //geoMeshView->redraw(); |
---|
468 | |
---|
469 | // Repaint the main window. |
---|
470 | mMainWindow->redraw(); |
---|
471 | } |
---|
472 | |
---|
473 | void GeoMeshViewUI::cb_menuRenderWire(fltk::Item* o, void* v) |
---|
474 | { |
---|
475 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
476 | -> |
---|
477 | cb_menuRenderWire_i(o,v); |
---|
478 | } |
---|
479 | |
---|
480 | //------------------------------------------------------------------------- |
---|
481 | // Solid Callback |
---|
482 | //------------------------------------------------------------------------- |
---|
483 | inline void GeoMeshViewUI::cb_menuRenderSolid_i(fltk::Item *item, void*) |
---|
484 | { |
---|
485 | if (item->value()) |
---|
486 | { |
---|
487 | geoMeshView->activeSolid(); |
---|
488 | } |
---|
489 | else |
---|
490 | { |
---|
491 | geoMeshView->deactiveSolid(); |
---|
492 | } |
---|
493 | |
---|
494 | // Repaint the canvas. |
---|
495 | //geoMeshView->redraw(); |
---|
496 | |
---|
497 | // Repaint the main window. |
---|
498 | mMainWindow->redraw(); |
---|
499 | } |
---|
500 | |
---|
501 | void GeoMeshViewUI::cb_menuRenderSolid(fltk::Item* o, void* v) |
---|
502 | { |
---|
503 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
504 | -> |
---|
505 | cb_menuRenderSolid_i(o,v); |
---|
506 | } |
---|
507 | |
---|
508 | //------------------------------------------------------------------------- |
---|
509 | // Lighting Callback |
---|
510 | //------------------------------------------------------------------------- |
---|
511 | inline void GeoMeshViewUI::cb_menuRenderLighting_i(fltk::Item *item, void*) |
---|
512 | { |
---|
513 | if (item->value()) |
---|
514 | { |
---|
515 | geoMeshView->activeLighting(); |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | geoMeshView->deactiveLighting(); |
---|
520 | } |
---|
521 | |
---|
522 | // Repaint the main window. |
---|
523 | mMainWindow->redraw(); |
---|
524 | } |
---|
525 | |
---|
526 | void GeoMeshViewUI::cb_menuRenderLighting(fltk::Item* o, void* v) |
---|
527 | { |
---|
528 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
529 | -> |
---|
530 | cb_menuRenderLighting_i(o,v); |
---|
531 | } |
---|
532 | |
---|
533 | //------------------------------------------------------------------------- |
---|
534 | // CW callback |
---|
535 | //------------------------------------------------------------------------- |
---|
536 | inline void GeoMeshViewUI::cb_menuRenderCW_i(fltk::Item *item, void*) |
---|
537 | { |
---|
538 | // Clear the CCW state. |
---|
539 | menuRenderCCW->clear_value(); |
---|
540 | geoMeshView->deactiveCCW(); |
---|
541 | |
---|
542 | // If the item is activated. |
---|
543 | if (item->value()) |
---|
544 | { |
---|
545 | geoMeshView->activeCW(); |
---|
546 | } |
---|
547 | else |
---|
548 | { |
---|
549 | geoMeshView->deactiveCW(); |
---|
550 | } |
---|
551 | |
---|
552 | // Repaint the main window. |
---|
553 | mMainWindow->redraw(); |
---|
554 | } |
---|
555 | |
---|
556 | void GeoMeshViewUI::cb_menuRenderCW(fltk::Item* o, void* v) |
---|
557 | { |
---|
558 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
559 | -> |
---|
560 | cb_menuRenderCW_i(o,v); |
---|
561 | } |
---|
562 | |
---|
563 | //------------------------------------------------------------------------- |
---|
564 | // CCW callback |
---|
565 | //------------------------------------------------------------------------- |
---|
566 | inline void GeoMeshViewUI::cb_menuRenderCCW_i(fltk::Item *item, void*) |
---|
567 | { |
---|
568 | // Clear the CW state. |
---|
569 | menuRenderCW->clear_value(); |
---|
570 | geoMeshView->deactiveCW(); |
---|
571 | |
---|
572 | // If the item is activated. |
---|
573 | if (item->value()) |
---|
574 | { |
---|
575 | geoMeshView->activeCCW(); |
---|
576 | } |
---|
577 | else |
---|
578 | { |
---|
579 | geoMeshView->deactiveCCW(); |
---|
580 | } |
---|
581 | |
---|
582 | // Repaint the main window. |
---|
583 | mMainWindow->redraw(); |
---|
584 | } |
---|
585 | |
---|
586 | void GeoMeshViewUI::cb_menuRenderCCW(fltk::Item* o, void* v) |
---|
587 | { |
---|
588 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
589 | -> |
---|
590 | cb_menuRenderCCW_i(o,v); |
---|
591 | } |
---|
592 | |
---|
593 | //------------------------------------------------------------------------- |
---|
594 | // Flat callback |
---|
595 | //------------------------------------------------------------------------- |
---|
596 | inline void GeoMeshViewUI::cb_menuRenderFlat_i(fltk::Item*, void*) |
---|
597 | { |
---|
598 | // Deactive smooth flag. |
---|
599 | menuRenderSmooth->clear_value(); |
---|
600 | |
---|
601 | // Sets flat lighting. |
---|
602 | geoMeshView->flat(); |
---|
603 | |
---|
604 | // Repaint the main window. |
---|
605 | mMainWindow->redraw(); |
---|
606 | } |
---|
607 | |
---|
608 | void GeoMeshViewUI::cb_menuRenderFlat(fltk::Item* o, void* v) |
---|
609 | { |
---|
610 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
611 | -> |
---|
612 | cb_menuRenderFlat_i(o,v); |
---|
613 | } |
---|
614 | |
---|
615 | //------------------------------------------------------------------------- |
---|
616 | // Smooth Callback |
---|
617 | //------------------------------------------------------------------------- |
---|
618 | inline void GeoMeshViewUI::cb_menuRenderSmooth_i(fltk::Item*, void*) |
---|
619 | { |
---|
620 | // Deactive flat flag. |
---|
621 | menuRenderFlat->clear_value(); |
---|
622 | |
---|
623 | // Sets smooth lighting. |
---|
624 | geoMeshView->smooth(); |
---|
625 | |
---|
626 | // Repaint the main window. |
---|
627 | mMainWindow->redraw(); |
---|
628 | } |
---|
629 | |
---|
630 | void GeoMeshViewUI::cb_menuRenderSmooth(fltk::Item* o, void* v) |
---|
631 | { |
---|
632 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
633 | -> |
---|
634 | cb_menuRenderSmooth_i(o,v); |
---|
635 | } |
---|
636 | |
---|
637 | //------------------------------------------------------------------------- |
---|
638 | // Textures callback |
---|
639 | //------------------------------------------------------------------------- |
---|
640 | inline void GeoMeshViewUI::cb_menuRenderTextures_i(fltk::Item*, void*) |
---|
641 | { |
---|
642 | // Repaint the main window. |
---|
643 | mMainWindow->redraw(); |
---|
644 | if (geoMeshView->isTextureMappingEnabled()) |
---|
645 | geoMeshView->disableTextureMapping(); |
---|
646 | else |
---|
647 | geoMeshView->enableTextureMapping(); |
---|
648 | } |
---|
649 | |
---|
650 | void GeoMeshViewUI::cb_menuRenderTextures(fltk::Item* o, void* v) |
---|
651 | { |
---|
652 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
653 | -> |
---|
654 | cb_menuRenderTextures_i(o,v); |
---|
655 | } |
---|
656 | |
---|
657 | //------------------------------------------------------------------------- |
---|
658 | // Bounding Box callback |
---|
659 | //------------------------------------------------------------------------- |
---|
660 | inline void GeoMeshViewUI::cb_menuRenderBoundingBox_i(fltk::Item *item, |
---|
661 | void *v) |
---|
662 | { |
---|
663 | // If the item is activated. |
---|
664 | if (item->value()) |
---|
665 | { |
---|
666 | geoMeshView->activeBoundingBox(); |
---|
667 | } |
---|
668 | else |
---|
669 | { |
---|
670 | geoMeshView->deactiveBoundingBox(); |
---|
671 | } |
---|
672 | |
---|
673 | // Repaint the main window. |
---|
674 | mMainWindow->redraw(); |
---|
675 | } |
---|
676 | |
---|
677 | void GeoMeshViewUI::cb_menuRenderBoundingBox(fltk::Item* o, void* v) |
---|
678 | { |
---|
679 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
680 | -> |
---|
681 | cb_menuRenderBoundingBox_i(o,v); |
---|
682 | } |
---|
683 | |
---|
684 | //------------------------------------------------------------------------- |
---|
685 | // Axes callback |
---|
686 | //------------------------------------------------------------------------- |
---|
687 | inline void GeoMeshViewUI::cb_menuRenderAxes_i(fltk::Item *item, |
---|
688 | void *v) |
---|
689 | { |
---|
690 | // If the item is activated. |
---|
691 | if (item->value()) |
---|
692 | { |
---|
693 | geoMeshView->activeAxes(); |
---|
694 | } |
---|
695 | else |
---|
696 | { |
---|
697 | geoMeshView->deactiveAxes(); |
---|
698 | } |
---|
699 | |
---|
700 | // Repaint the main window. |
---|
701 | mMainWindow->redraw(); |
---|
702 | } |
---|
703 | |
---|
704 | void GeoMeshViewUI::cb_menuRenderAxes(fltk::Item* o, void* v) |
---|
705 | { |
---|
706 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
707 | -> |
---|
708 | cb_menuRenderAxes_i(o,v); |
---|
709 | } |
---|
710 | |
---|
711 | //------------------------------------------------------------------------- |
---|
712 | // Stripify Callback |
---|
713 | //------------------------------------------------------------------------- |
---|
714 | inline void GeoMeshViewUI::cb_menuStripify_i(fltk::Item*, void*) |
---|
715 | { |
---|
716 | // Show title. |
---|
717 | mProcessTitle->label("Stripify"); |
---|
718 | mProcessBar->position(0); |
---|
719 | |
---|
720 | // Hide the right panel. |
---|
721 | hideRightPanel(); |
---|
722 | |
---|
723 | // Show the stripify panel. |
---|
724 | showStripify(); |
---|
725 | |
---|
726 | // Sets menus application state to STRIPIFY. |
---|
727 | mApplicationState = STRIPIFY; |
---|
728 | |
---|
729 | // Repaint the window. |
---|
730 | mMainWindow->redraw(); |
---|
731 | } |
---|
732 | |
---|
733 | void GeoMeshViewUI::cb_menuStripify(fltk::Item* o, void* v) |
---|
734 | { |
---|
735 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
736 | -> |
---|
737 | cb_menuStripify_i(o,v); |
---|
738 | } |
---|
739 | |
---|
740 | //------------------------------------------------------------------------- |
---|
741 | // Simplify Callback |
---|
742 | //------------------------------------------------------------------------- |
---|
743 | inline void GeoMeshViewUI::cb_menuSimplify_i(fltk::ItemGroup*, void*) |
---|
744 | { |
---|
745 | } |
---|
746 | |
---|
747 | void GeoMeshViewUI::cb_menuSimplify(fltk::ItemGroup* o, void* v) |
---|
748 | { |
---|
749 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
750 | -> |
---|
751 | cb_menuSimplify_i(o,v); |
---|
752 | } |
---|
753 | |
---|
754 | //------------------------------------------------------------------------- |
---|
755 | // Edge collapse Callback |
---|
756 | //------------------------------------------------------------------------- |
---|
757 | inline void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*) |
---|
758 | { |
---|
759 | // Show title. |
---|
760 | mProcessTitle->label("Mesh Simplification"); |
---|
761 | mProcessBar->position(0); |
---|
762 | |
---|
763 | // Hide the right panel. |
---|
764 | hideRightPanel(); |
---|
765 | |
---|
766 | // Show the edge collapse panel. |
---|
767 | showEdgeCollapse(); |
---|
768 | |
---|
769 | // Sets menus application state to EDGE_COLLAPSE. |
---|
770 | mApplicationState = EDGE_COLLAPSE; |
---|
771 | |
---|
772 | // Repaint the window. |
---|
773 | mMainWindow->redraw(); |
---|
774 | |
---|
775 | } |
---|
776 | |
---|
777 | void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse(fltk::Item* o, void* v) |
---|
778 | { |
---|
779 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
780 | -> |
---|
781 | cb_menuSimplifyEdgeCollapse_i(o,v); |
---|
782 | } |
---|
783 | |
---|
784 | //------------------------------------------------------------------------- |
---|
785 | // Leaves collapse Callback |
---|
786 | //------------------------------------------------------------------------- |
---|
787 | inline void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*) |
---|
788 | { |
---|
789 | // Show title. |
---|
790 | mProcessTitle->label("Leaves Simplification"); |
---|
791 | mProcessBar->position(0); |
---|
792 | |
---|
793 | // Hide the right panel. |
---|
794 | hideRightPanel(); |
---|
795 | |
---|
796 | // Show the leaves collapse panel. |
---|
797 | showLeavesCollapse(); |
---|
798 | |
---|
799 | // Sets menus application state to LEAVES_COLLAPSE. |
---|
800 | mApplicationState = LEAVES_COLLAPSE; |
---|
801 | |
---|
802 | // Repaint the window. |
---|
803 | mMainWindow->redraw(); |
---|
804 | } |
---|
805 | |
---|
806 | void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse(fltk::Item* o, void* v) |
---|
807 | { |
---|
808 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
809 | -> |
---|
810 | cb_menuSimplifyLeavesCollapse_i(o,v); |
---|
811 | } |
---|
812 | |
---|
813 | //------------------------------------------------------------------------- |
---|
814 | // Tree select leaves simplification Callback |
---|
815 | //------------------------------------------------------------------------- |
---|
816 | inline void GeoMeshViewUI::cb_menuSelectLeaves_i(fltk::Item*, void*) |
---|
817 | { |
---|
818 | // Show title. |
---|
819 | mProcessTitle->label("Select Leaves"); |
---|
820 | |
---|
821 | showMeshInfo(); |
---|
822 | mButtonProcess->show(); |
---|
823 | mButtonProcess->activate(); |
---|
824 | mApplicationState = SELECT_LEAVES; |
---|
825 | } |
---|
826 | |
---|
827 | void GeoMeshViewUI::cb_menuSelectLeaves(fltk::Item* o, void* v) |
---|
828 | { |
---|
829 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
830 | -> |
---|
831 | cb_menuSelectLeaves_i(o,v); |
---|
832 | } |
---|
833 | |
---|
834 | //------------------------------------------------------------------------- |
---|
835 | // Auto Generate LodStrips Callback |
---|
836 | //------------------------------------------------------------------------- |
---|
837 | inline void GeoMeshViewUI::cb_menuLodStripsGenerate_i(fltk::Item*, void*) |
---|
838 | { |
---|
839 | // Show title. |
---|
840 | mProcessTitle->label("Generate LodStrips"); |
---|
841 | mProcessBar->position(0); |
---|
842 | mBuildBar->position(0); |
---|
843 | |
---|
844 | // Hide the right panel. |
---|
845 | hideRightPanel(); |
---|
846 | |
---|
847 | // Show the LodStrips panel. |
---|
848 | showAutoGenerateLodStrips(); |
---|
849 | |
---|
850 | // Sets menus application state to LODSTRIPS_AUTO. |
---|
851 | mApplicationState = LODSTRIPS_AUTO; |
---|
852 | |
---|
853 | // Repaint the window. |
---|
854 | mMainWindow->redraw(); |
---|
855 | } |
---|
856 | |
---|
857 | void GeoMeshViewUI::cb_menuLodStripsGenerate(fltk::Item* o, void* v) |
---|
858 | { |
---|
859 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
860 | -> |
---|
861 | cb_menuLodStripsGenerate_i(o,v); |
---|
862 | } |
---|
863 | |
---|
864 | //------------------------------------------------------------------------- |
---|
865 | // Auto Generate LodStrips Callback |
---|
866 | //------------------------------------------------------------------------- |
---|
867 | inline void GeoMeshViewUI::cb_menuLodTreesGenerate_i(fltk::Item*, void*) |
---|
868 | { |
---|
869 | // Show title. |
---|
870 | mProcessTitle->label("Generate LodTree"); |
---|
871 | mProcessBar->position(0); |
---|
872 | mBuildBar->position(0); |
---|
873 | |
---|
874 | // Hide the right panel. |
---|
875 | hideRightPanel(); |
---|
876 | |
---|
877 | // Show the LodStrips panel. |
---|
878 | showAutoGenerateLodTrees(); |
---|
879 | |
---|
880 | // Sets menus application state to LODSTRIPS_AUTO. |
---|
881 | mApplicationState = LODTREES_AUTO; |
---|
882 | |
---|
883 | // Repaint the window. |
---|
884 | mMainWindow->redraw(); |
---|
885 | } |
---|
886 | |
---|
887 | void GeoMeshViewUI::cb_menuLodTreesGenerate(fltk::Item* o, void* v) |
---|
888 | { |
---|
889 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
890 | -> |
---|
891 | cb_menuLodTreesGenerate_i(o,v); |
---|
892 | } |
---|
893 | |
---|
894 | |
---|
895 | //------------------------------------------------------------------------- |
---|
896 | // Visualize LodStrips Callback |
---|
897 | //------------------------------------------------------------------------- |
---|
898 | inline void GeoMeshViewUI::cb_menuLodStripsVisualize_i(fltk::Item*, void*) |
---|
899 | { |
---|
900 | // Sets menus application state to NONE. |
---|
901 | mApplicationState = NONE; |
---|
902 | |
---|
903 | // Deactive Lod strip visualization. |
---|
904 | geoMeshView->deactiveLodStrip(); |
---|
905 | geoMeshView->deactiveLodTree(); |
---|
906 | |
---|
907 | // Loads a mesh file. |
---|
908 | openMeshFile(); |
---|
909 | |
---|
910 | // If an object is loaded. |
---|
911 | if (mGeoMesh != NULL) |
---|
912 | { |
---|
913 | if (geoMeshLoader->GetLodStripsData()) |
---|
914 | { |
---|
915 | // Build lod strips library. |
---|
916 | setLodStripsLibrary(geoMeshLoader->GetLodStripsData(), mGeoMesh); |
---|
917 | |
---|
918 | // Sets the aplication mode. |
---|
919 | mApplicationState = VISUALIZE_LODSTRIPS; |
---|
920 | |
---|
921 | // Hide the right panel. |
---|
922 | hideRightPanel(); |
---|
923 | |
---|
924 | // Show title. |
---|
925 | mProcessTitle->label("Visualize LodStrips"); |
---|
926 | |
---|
927 | // Show the Visulize LodStrips panel. |
---|
928 | showLodStripSlider(); |
---|
929 | |
---|
930 | // Repaint the window. |
---|
931 | mMainWindow->redraw(); |
---|
932 | } |
---|
933 | else |
---|
934 | { |
---|
935 | fltk::alert("The loaded mesh does not contain LOD information.\nNothing will be done."); |
---|
936 | } |
---|
937 | } |
---|
938 | } |
---|
939 | |
---|
940 | inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) |
---|
941 | { |
---|
942 | // Sets menus application state to NONE. |
---|
943 | mApplicationState = NONE; |
---|
944 | |
---|
945 | // Deactive Lod strip visualization. |
---|
946 | geoMeshView->deactiveLodTree(); |
---|
947 | geoMeshView->deactiveLodStrip(); |
---|
948 | |
---|
949 | // Loads a mesh file. |
---|
950 | openMeshFile(); |
---|
951 | |
---|
952 | // If an object is loaded. |
---|
953 | if (mGeoMesh != NULL) |
---|
954 | { |
---|
955 | if (geoMeshLoader->GetTreeSimpSeq() && geoMeshLoader->GetLodStripsData()) |
---|
956 | { |
---|
957 | setLodTreesLibrary( geoMeshLoader->GetLodStripsData(), |
---|
958 | geoMeshLoader->GetTreeSimpSeq(), |
---|
959 | mGeoMesh); |
---|
960 | |
---|
961 | // Sets the aplication mode. |
---|
962 | mApplicationState = VISUALIZE_LODTREES; |
---|
963 | |
---|
964 | // Hide the right panel. |
---|
965 | hideRightPanel(); |
---|
966 | |
---|
967 | // Show title. |
---|
968 | mProcessTitle->label("Visualize LodTrees"); |
---|
969 | |
---|
970 | // Show the Visulize LodTree panel. |
---|
971 | showLodStripSlider(); |
---|
972 | showLodTreeSlider(); |
---|
973 | |
---|
974 | // Repaint the window. |
---|
975 | mMainWindow->redraw(); |
---|
976 | } |
---|
977 | else |
---|
978 | fltk::alert("The loaded mesh does not contain LOD information.\nNothing will be done."); |
---|
979 | } |
---|
980 | } |
---|
981 | |
---|
982 | void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) |
---|
983 | { |
---|
984 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
985 | -> |
---|
986 | cb_menuLodTreesVisualize_i(o,v); |
---|
987 | } |
---|
988 | |
---|
989 | void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) |
---|
990 | { |
---|
991 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
992 | -> |
---|
993 | cb_menuLodStripsVisualize_i(o,v); |
---|
994 | } |
---|
995 | |
---|
996 | //------------------------------------------------------------------------- |
---|
997 | // Open LodStrip trunk Callback |
---|
998 | //------------------------------------------------------------------------- |
---|
999 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) |
---|
1000 | { |
---|
1001 | } |
---|
1002 | |
---|
1003 | void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) |
---|
1004 | { |
---|
1005 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1006 | -> |
---|
1007 | cb_menuLodTreesOpenLodStripTrunk_i(o,v); |
---|
1008 | } |
---|
1009 | |
---|
1010 | //------------------------------------------------------------------------- |
---|
1011 | // Open leaves simplification Callback |
---|
1012 | //------------------------------------------------------------------------- |
---|
1013 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) |
---|
1014 | { |
---|
1015 | // Hide the right panel. |
---|
1016 | hideRightPanel(); |
---|
1017 | |
---|
1018 | // Show the LodTrees panel. |
---|
1019 | showOpenLeavesSimplification(); |
---|
1020 | |
---|
1021 | // Sets menus application state to LODTREES. |
---|
1022 | mApplicationState = LODTREES; |
---|
1023 | |
---|
1024 | // Repaint the window. |
---|
1025 | mMainWindow->redraw(); |
---|
1026 | } |
---|
1027 | |
---|
1028 | void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification(fltk::Item* o, void* v) |
---|
1029 | { |
---|
1030 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1031 | -> |
---|
1032 | cb_menuLodTreesOpenLeavesSimplification_i(o,v); |
---|
1033 | } |
---|
1034 | |
---|
1035 | |
---|
1036 | |
---|
1037 | //------------------------------------------------------------------------- |
---|
1038 | // About Callback |
---|
1039 | //------------------------------------------------------------------------- |
---|
1040 | inline void GeoMeshViewUI::cb_menuHelpAbout_i(fltk::Item*, void*) |
---|
1041 | { |
---|
1042 | new GTAboutDialog(); |
---|
1043 | } |
---|
1044 | |
---|
1045 | void GeoMeshViewUI::cb_menuHelpAbout(fltk::Item* o, void* v) |
---|
1046 | { |
---|
1047 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1048 | -> |
---|
1049 | cb_menuHelpAbout_i(o,v); |
---|
1050 | } |
---|
1051 | |
---|
1052 | VertexBuffer *origSubMeshVB = NULL; |
---|
1053 | int orig_numindices = 0; |
---|
1054 | Index *orig_indices = NULL; |
---|
1055 | |
---|
1056 | //------------------------------------------------------------------------- |
---|
1057 | // Button Process Callback |
---|
1058 | //------------------------------------------------------------------------- |
---|
1059 | inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) |
---|
1060 | { |
---|
1061 | bool error; |
---|
1062 | Mesh *mesh_aux; |
---|
1063 | |
---|
1064 | // Sets the progress bar to process bar. |
---|
1065 | progressBarType = PROCESS; |
---|
1066 | mProcessBar->position(0); |
---|
1067 | |
---|
1068 | origSubMeshVB = NULL; |
---|
1069 | |
---|
1070 | // Initialize error flag. |
---|
1071 | error = false; |
---|
1072 | |
---|
1073 | // If there is a mesh object. |
---|
1074 | if (mGeoMesh != NULL) |
---|
1075 | { |
---|
1076 | // Choose between aplication state. |
---|
1077 | switch (mApplicationState) |
---|
1078 | { |
---|
1079 | // Stripify state. |
---|
1080 | case STRIPIFY: |
---|
1081 | |
---|
1082 | // Stripify the mesh object. |
---|
1083 | stripify(); |
---|
1084 | |
---|
1085 | break; |
---|
1086 | |
---|
1087 | // Simplify edge collapse state. |
---|
1088 | case EDGE_COLLAPSE: |
---|
1089 | |
---|
1090 | // Check submeshes for triangles strips. |
---|
1091 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
1092 | { |
---|
1093 | // If current submesh is in triangle strips. |
---|
1094 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
1095 | { |
---|
1096 | error = true; |
---|
1097 | } |
---|
1098 | } |
---|
1099 | |
---|
1100 | // if the mesh is stripified. |
---|
1101 | if (error) |
---|
1102 | { |
---|
1103 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
1104 | } |
---|
1105 | else |
---|
1106 | { |
---|
1107 | // Transform NoSV Mesh to a SV Mesh. |
---|
1108 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
1109 | |
---|
1110 | // Deletes the mesh No Shared Vertex. |
---|
1111 | delete mGeoMesh; |
---|
1112 | |
---|
1113 | // Gets the mesh Shared Vertex. |
---|
1114 | mGeoMesh = mesh_aux; |
---|
1115 | |
---|
1116 | // Simplify the mesh object. |
---|
1117 | if(simplifyEdgeCollapse()) |
---|
1118 | { |
---|
1119 | geoMeshView->restoreContext(); |
---|
1120 | } |
---|
1121 | |
---|
1122 | // Visualize mesh. |
---|
1123 | geoMeshView->setMesh(mGeoMesh); |
---|
1124 | |
---|
1125 | } |
---|
1126 | break; |
---|
1127 | |
---|
1128 | // Simplify leaves |
---|
1129 | case LEAVES_COLLAPSE: |
---|
1130 | |
---|
1131 | // Simplify the mesh object. |
---|
1132 | simplifyLeavesCollapse(); |
---|
1133 | |
---|
1134 | // Create the leaves simplification sequence. |
---|
1135 | createLeavesSequence("leavesSimplification.txt"); |
---|
1136 | |
---|
1137 | break; |
---|
1138 | |
---|
1139 | // Simplify and generate simplification sequence. |
---|
1140 | case LODTREES_AUTO: |
---|
1141 | |
---|
1142 | if (idMeshLeaves == (unsigned short)-1) |
---|
1143 | { |
---|
1144 | fltk::alert("Leaves submesh not selected!"); |
---|
1145 | } |
---|
1146 | else |
---|
1147 | { |
---|
1148 | origSubMeshVB = mGeoMesh-> |
---|
1149 | mSubMesh[idMeshLeaves].mVertexBuffer->Clone(); |
---|
1150 | |
---|
1151 | orig_numindices = mGeoMesh->mSubMesh[idMeshLeaves].mIndexCount; |
---|
1152 | orig_indices = new Index[orig_numindices]; |
---|
1153 | |
---|
1154 | for (int i = 0; i < orig_numindices; i++) |
---|
1155 | { |
---|
1156 | orig_indices[i]=mGeoMesh->mSubMesh[idMeshLeaves].mIndex[i]; |
---|
1157 | } |
---|
1158 | |
---|
1159 | std::cout << "Simplificando hojas..."; |
---|
1160 | simplifyLeavesCollapse(); |
---|
1161 | std::cout << "OK!" << std::endl; |
---|
1162 | |
---|
1163 | // std::cout << "Creando secuencia de simplificacion de hojas..."; |
---|
1164 | // createLeavesSequence("leavesSimplification.txt"); |
---|
1165 | // std::cout << "OK!" << std::endl; |
---|
1166 | |
---|
1167 | undo(); |
---|
1168 | |
---|
1169 | |
---|
1170 | std::cout << "Simplificando tronco..."; |
---|
1171 | std::cout << "OK!" << std::endl; |
---|
1172 | |
---|
1173 | // Transform NoSV Mesh to a SV Mesh. |
---|
1174 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
1175 | |
---|
1176 | // Deletes the mesh No Shared Vertex. |
---|
1177 | delete mGeoMesh; |
---|
1178 | |
---|
1179 | // Gets the mesh Shared Vertex. |
---|
1180 | mGeoMesh = mesh_aux; |
---|
1181 | |
---|
1182 | // Simplify the mesh object. |
---|
1183 | if (simplifyEdgeCollapse()) |
---|
1184 | { |
---|
1185 | // Create the simplification sequence. |
---|
1186 | //createSimplificationSequence(); |
---|
1187 | |
---|
1188 | // Show build process. |
---|
1189 | activeBuildProcess(); |
---|
1190 | } |
---|
1191 | |
---|
1192 | geoMeshView->setMesh(mGeoMesh); |
---|
1193 | } |
---|
1194 | |
---|
1195 | break; |
---|
1196 | |
---|
1197 | case LODSTRIPS_AUTO: |
---|
1198 | |
---|
1199 | // Check submeshes for triangles strips. |
---|
1200 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
1201 | { |
---|
1202 | // If current submesh is in triangle strips. |
---|
1203 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
1204 | { |
---|
1205 | error = true; |
---|
1206 | } |
---|
1207 | } |
---|
1208 | |
---|
1209 | // if the mesh is stripified. |
---|
1210 | if (error) |
---|
1211 | { |
---|
1212 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
1213 | } |
---|
1214 | else |
---|
1215 | { |
---|
1216 | // Transform NoSV Mesh to a SV Mesh. |
---|
1217 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
1218 | |
---|
1219 | // Deletes the mesh No Shared Vertex. |
---|
1220 | delete mGeoMesh; |
---|
1221 | |
---|
1222 | // Gets the mesh Shared Vertex. |
---|
1223 | mGeoMesh = mesh_aux; |
---|
1224 | |
---|
1225 | // Simplify the mesh object. |
---|
1226 | if (simplifyEdgeCollapse()) |
---|
1227 | { |
---|
1228 | geoMeshView->restoreContext(); |
---|
1229 | |
---|
1230 | // Show build process. |
---|
1231 | activeBuildProcess(); |
---|
1232 | } |
---|
1233 | |
---|
1234 | // Visualize mesh. |
---|
1235 | geoMeshView->setMesh(mGeoMesh); |
---|
1236 | } |
---|
1237 | |
---|
1238 | break; |
---|
1239 | |
---|
1240 | // A?adido 23-12-2005 |
---|
1241 | case SELECT_LEAVES: |
---|
1242 | |
---|
1243 | idMeshLeaves = paintMesh(); |
---|
1244 | |
---|
1245 | // Set the leaves submesh. |
---|
1246 | geoMeshView->setLeavesSubMesh(idMeshLeaves); |
---|
1247 | |
---|
1248 | // Refresh mesh info. |
---|
1249 | showMeshInfo(); |
---|
1250 | |
---|
1251 | break; |
---|
1252 | } |
---|
1253 | |
---|
1254 | // Refresh geometry attributes. |
---|
1255 | refreshApplicationBar(); |
---|
1256 | } |
---|
1257 | |
---|
1258 | // Repaint the GL Window. |
---|
1259 | mMainWindow->redraw(); |
---|
1260 | } |
---|
1261 | |
---|
1262 | void GeoMeshViewUI::cb_mButtonProcess(fltk::Button* o, void* v) |
---|
1263 | { |
---|
1264 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1265 | -> |
---|
1266 | cb_mButtonProcess_i(o,v); |
---|
1267 | } |
---|
1268 | |
---|
1269 | //------------------------------------------------------------------------- |
---|
1270 | // Button Sort Callback |
---|
1271 | //------------------------------------------------------------------------- |
---|
1272 | inline void GeoMeshViewUI::cb_mButtonSort_i(fltk::Button*, void*) |
---|
1273 | { |
---|
1274 | } |
---|
1275 | |
---|
1276 | void GeoMeshViewUI::cb_mButtonSort(fltk::Button* o, void* v) |
---|
1277 | { |
---|
1278 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1279 | -> |
---|
1280 | cb_mButtonSort_i(o,v); |
---|
1281 | } |
---|
1282 | |
---|
1283 | //------------------------------------------------------------------------- |
---|
1284 | // Button Build Callback |
---|
1285 | //------------------------------------------------------------------------- |
---|
1286 | inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) |
---|
1287 | { |
---|
1288 | char *file_name = NULL; |
---|
1289 | GeoMeshSaver *mesh_saver; |
---|
1290 | Serializer *oSerializer; |
---|
1291 | |
---|
1292 | // Sets the progress bar to process bar. |
---|
1293 | progressBarType = BUILD; |
---|
1294 | |
---|
1295 | // Reset the build bar. |
---|
1296 | mBuildBar->position(0); |
---|
1297 | |
---|
1298 | // If there is a mesh object. |
---|
1299 | if (mGeoMesh != NULL) |
---|
1300 | { |
---|
1301 | // Choose between aplication state. |
---|
1302 | if (mApplicationState == LODSTRIPS_AUTO |
---|
1303 | || |
---|
1304 | mApplicationState == LODTREES_AUTO) |
---|
1305 | { |
---|
1306 | file_name = fltk::file_chooser("Build LOD","*.mesh",""); |
---|
1307 | |
---|
1308 | // If a file was selected. |
---|
1309 | if (file_name) |
---|
1310 | { |
---|
1311 | // Undo the simplification changes. |
---|
1312 | undo(); |
---|
1313 | |
---|
1314 | // Stripify the mesh object. |
---|
1315 | stripify(); |
---|
1316 | |
---|
1317 | // Reset the build bar. |
---|
1318 | mBuildBar->position(0); |
---|
1319 | |
---|
1320 | // Simplification sequence. |
---|
1321 | oMeshSimpSequence = mMeshSimplifier->GetSimplificationSequence(); |
---|
1322 | |
---|
1323 | // If the simplification sequence and the mesh exist. |
---|
1324 | if (oMeshSimpSequence && mGeoMesh) |
---|
1325 | { |
---|
1326 | oLodStrip = new LodStripsConstructor( mGeoMesh, |
---|
1327 | oMeshSimpSequence, |
---|
1328 | idMeshLeaves, |
---|
1329 | progress_function); |
---|
1330 | |
---|
1331 | oLodStrip->UpdateMesh(); |
---|
1332 | |
---|
1333 | // Deletes the previous mesh. |
---|
1334 | delete mUndoMesh; |
---|
1335 | |
---|
1336 | |
---|
1337 | mUndoMesh = new Mesh(); |
---|
1338 | |
---|
1339 | // Sets the undo mesh. |
---|
1340 | *mUndoMesh = *mGeoMesh; |
---|
1341 | |
---|
1342 | delete mGeoMesh; |
---|
1343 | |
---|
1344 | mGeoMesh = oLodStrip->GetMesh(); |
---|
1345 | |
---|
1346 | geoMeshView->setMesh(mGeoMesh); |
---|
1347 | |
---|
1348 | mesh_saver = new GeoMeshSaver(); |
---|
1349 | |
---|
1350 | mesh_saver->leavesSubMesh = idMeshLeaves; |
---|
1351 | mesh_saver->leavesVB = origSubMeshVB; |
---|
1352 | mesh_saver->numindices = orig_numindices; |
---|
1353 | mesh_saver->indices = orig_indices; |
---|
1354 | |
---|
1355 | mesh_saver->save(mGeoMesh,file_name); |
---|
1356 | |
---|
1357 | delete mesh_saver; |
---|
1358 | |
---|
1359 | oLodStrip->Save(file_name); |
---|
1360 | } |
---|
1361 | else |
---|
1362 | { |
---|
1363 | // Error message. |
---|
1364 | fltk::alert("There is no simplification sequence."); |
---|
1365 | } |
---|
1366 | |
---|
1367 | if (mApplicationState == LODTREES_AUTO) |
---|
1368 | { |
---|
1369 | createLeavesSequence(file_name); |
---|
1370 | } |
---|
1371 | } |
---|
1372 | } |
---|
1373 | |
---|
1374 | // Refresh data aplication. |
---|
1375 | refreshApplicationBar(); |
---|
1376 | } |
---|
1377 | } |
---|
1378 | |
---|
1379 | void GeoMeshViewUI::cb_mButtonBuild(fltk::Button *o, void *v) |
---|
1380 | { |
---|
1381 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1382 | -> |
---|
1383 | cb_mButtonBuild_i(o,v); |
---|
1384 | } |
---|
1385 | |
---|
1386 | //------------------------------------------------------------------------- |
---|
1387 | // Lod Slider Callback |
---|
1388 | //------------------------------------------------------------------------- |
---|
1389 | inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider *o, void *) |
---|
1390 | { |
---|
1391 | // Change the lod. |
---|
1392 | geoMeshView->GoToLod_LodStrip((float)o->value()); |
---|
1393 | |
---|
1394 | // Refresh data aplication. |
---|
1395 | refreshApplicationBar(); |
---|
1396 | |
---|
1397 | mMainWindow->flush(); |
---|
1398 | } |
---|
1399 | |
---|
1400 | void GeoMeshViewUI::cb_mLodStripSlider(fltk::Slider *o, void *v) |
---|
1401 | { |
---|
1402 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1403 | -> |
---|
1404 | cb_mLodStripSlider_i(o,v); |
---|
1405 | } |
---|
1406 | |
---|
1407 | //------------------------------------------------------------------------- |
---|
1408 | // Lod Slider Callback for the foliage |
---|
1409 | //------------------------------------------------------------------------- |
---|
1410 | inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider *o, void *) |
---|
1411 | { |
---|
1412 | // Change the lod. |
---|
1413 | geoMeshView->GoToLod_LodTree((float)o->value()); |
---|
1414 | |
---|
1415 | // Refresh data aplication. |
---|
1416 | refreshApplicationBar(); |
---|
1417 | |
---|
1418 | mMainWindow->flush(); |
---|
1419 | } |
---|
1420 | |
---|
1421 | void GeoMeshViewUI::cb_mLodTreeSlider(fltk::Slider *o, void *v) |
---|
1422 | { |
---|
1423 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1424 | -> |
---|
1425 | cb_mLodTreeSlider_i(o,v); |
---|
1426 | } |
---|
1427 | |
---|
1428 | //------------------------------------------------------------------------- |
---|
1429 | // Mesh Info Callback |
---|
1430 | //------------------------------------------------------------------------- |
---|
1431 | inline void GeoMeshViewUI::cb_mMeshInfo_i(fltk::Browser *, void *) |
---|
1432 | { |
---|
1433 | paintMesh(); |
---|
1434 | } |
---|
1435 | |
---|
1436 | void GeoMeshViewUI::cb_mMeshInfo(fltk::Browser* o, void* v) |
---|
1437 | { |
---|
1438 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1439 | -> |
---|
1440 | cb_mMeshInfo_i(o,v); |
---|
1441 | } |
---|
1442 | |
---|
1443 | //------------------------------------------------------------------------- |
---|
1444 | // Logo Callback. |
---|
1445 | //------------------------------------------------------------------------- |
---|
1446 | inline void GeoMeshViewUI::cb_mLogo_i(fltk::InvisibleBox*, void*) |
---|
1447 | { |
---|
1448 | } |
---|
1449 | |
---|
1450 | void GeoMeshViewUI::cb_mLogo(fltk::InvisibleBox* o, void* v) |
---|
1451 | { |
---|
1452 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
1453 | -> |
---|
1454 | cb_mLogo_i(o,v); |
---|
1455 | } |
---|
1456 | |
---|
1457 | //------------------------------------------------------------------------- |
---|
1458 | // Active Build process. |
---|
1459 | //------------------------------------------------------------------------- |
---|
1460 | void GeoMeshViewUI::activeBuildProcess() |
---|
1461 | { |
---|
1462 | //mButtonBuild->set_visible(); |
---|
1463 | mButtonBuild->activate(); |
---|
1464 | |
---|
1465 | //mBuildBar->set_visible(); |
---|
1466 | mBuildBar->activate(); |
---|
1467 | } |
---|
1468 | |
---|
1469 | //------------------------------------------------------------------------- |
---|
1470 | // Show the stripify panel. |
---|
1471 | //------------------------------------------------------------------------- |
---|
1472 | void GeoMeshViewUI::showStripify() |
---|
1473 | { |
---|
1474 | /* |
---|
1475 | mTypeLabel->set_visible(); |
---|
1476 | mTypeLabel->activate(); |
---|
1477 | |
---|
1478 | mOneCacheStrip->set_visible(); |
---|
1479 | mOneCacheStrip->activate(); |
---|
1480 | |
---|
1481 | mQualityStrips->set_visible(); |
---|
1482 | mQualityStrips->activate(); |
---|
1483 | */ |
---|
1484 | |
---|
1485 | mButtonProcess->set_visible(); |
---|
1486 | mButtonProcess->activate(); |
---|
1487 | |
---|
1488 | mProcessBar->set_visible(); |
---|
1489 | mProcessBar->activate(); |
---|
1490 | } |
---|
1491 | |
---|
1492 | //------------------------------------------------------------------------- |
---|
1493 | // Hide the stripify panel. |
---|
1494 | //------------------------------------------------------------------------- |
---|
1495 | void GeoMeshViewUI::hideStripify() |
---|
1496 | { |
---|
1497 | /* |
---|
1498 | mTypeLabel->hide(); |
---|
1499 | mTypeLabel->deactivate(); |
---|
1500 | */ |
---|
1501 | |
---|
1502 | mOneCacheStrip->hide(); |
---|
1503 | mOneCacheStrip->deactivate(); |
---|
1504 | |
---|
1505 | mQualityStrips->hide(); |
---|
1506 | mQualityStrips->deactivate(); |
---|
1507 | |
---|
1508 | mButtonProcess->hide(); |
---|
1509 | mButtonProcess->deactivate(); |
---|
1510 | |
---|
1511 | mProcessBar->hide(); |
---|
1512 | mProcessBar->deactivate(); |
---|
1513 | } |
---|
1514 | |
---|
1515 | //------------------------------------------------------------------------- |
---|
1516 | // Show the Simplify Edge Collapse panel. |
---|
1517 | //------------------------------------------------------------------------- |
---|
1518 | void GeoMeshViewUI::showEdgeCollapse() |
---|
1519 | { |
---|
1520 | mMetricLabel->set_visible(); |
---|
1521 | mMetricLabel->activate(); |
---|
1522 | |
---|
1523 | mGeometryBased->set_visible(); |
---|
1524 | mGeometryBased->activate(); |
---|
1525 | mGeometryBased->set(); |
---|
1526 | |
---|
1527 | mViewPointDriven->set_visible(); |
---|
1528 | mViewPointDriven->activate(); |
---|
1529 | mViewPointDriven->clear(); |
---|
1530 | |
---|
1531 | /* |
---|
1532 | mTypeLabel->set_visible(); |
---|
1533 | mTypeLabel->activate(); |
---|
1534 | |
---|
1535 | mChangeVertices->set_visible(); |
---|
1536 | mChangeVertices->activate(); |
---|
1537 | */ |
---|
1538 | |
---|
1539 | mMeshReductionLabel->set_visible(); |
---|
1540 | mMeshReductionLabel->activate(); |
---|
1541 | |
---|
1542 | mPercent->set_visible(); |
---|
1543 | mPercent->activate(); |
---|
1544 | mPercent->set(); |
---|
1545 | |
---|
1546 | mVerticesNumber->set_visible(); |
---|
1547 | mVerticesNumber->activate(); |
---|
1548 | mVerticesNumber->clear(); |
---|
1549 | |
---|
1550 | mMeshReduction->set_visible(); |
---|
1551 | mMeshReduction->value(100); |
---|
1552 | |
---|
1553 | // Allows floating point. |
---|
1554 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
1555 | |
---|
1556 | mMeshReduction->activate(); |
---|
1557 | |
---|
1558 | mButtonProcess->set_visible(); |
---|
1559 | mButtonProcess->activate(); |
---|
1560 | |
---|
1561 | mProcessBar->set_visible(); |
---|
1562 | mProcessBar->activate(); |
---|
1563 | } |
---|
1564 | |
---|
1565 | //------------------------------------------------------------------------- |
---|
1566 | // Hide the Simplify Edge Collapse |
---|
1567 | //------------------------------------------------------------------------- |
---|
1568 | void GeoMeshViewUI::hideEdgeCollapse() |
---|
1569 | { |
---|
1570 | mMetricLabel->hide(); |
---|
1571 | mMetricLabel->deactivate(); |
---|
1572 | |
---|
1573 | mGeometryBased->hide(); |
---|
1574 | mGeometryBased->deactivate(); |
---|
1575 | |
---|
1576 | mViewPointDriven->hide(); |
---|
1577 | mViewPointDriven->deactivate(); |
---|
1578 | |
---|
1579 | /* |
---|
1580 | mTypeLabel->hide(); |
---|
1581 | mTypeLabel->deactivate(); |
---|
1582 | |
---|
1583 | mChangeVertices->hide(); |
---|
1584 | mChangeVertices->deactivate(); |
---|
1585 | */ |
---|
1586 | |
---|
1587 | mMeshReductionLabel->hide(); |
---|
1588 | mMeshReductionLabel->deactivate(); |
---|
1589 | |
---|
1590 | mPercent->hide(); |
---|
1591 | mPercent->deactivate(); |
---|
1592 | |
---|
1593 | mVerticesNumber->hide(); |
---|
1594 | mVerticesNumber->deactivate(); |
---|
1595 | |
---|
1596 | mMeshReduction->hide(); |
---|
1597 | mMeshReduction->deactivate(); |
---|
1598 | |
---|
1599 | mButtonProcess->hide(); |
---|
1600 | mButtonProcess->deactivate(); |
---|
1601 | |
---|
1602 | mProcessBar->hide(); |
---|
1603 | mProcessBar->deactivate(); |
---|
1604 | } |
---|
1605 | |
---|
1606 | //--------------------------------------------------------------------------- |
---|
1607 | // Show the Simlify Leaves Collapse. |
---|
1608 | //--------------------------------------------------------------------------- |
---|
1609 | void GeoMeshViewUI::showLeavesCollapse() |
---|
1610 | { |
---|
1611 | mMetricLabel->set_visible(); |
---|
1612 | mMetricLabel->activate(); |
---|
1613 | |
---|
1614 | mGeometryBased->set_visible(); |
---|
1615 | mGeometryBased->activate(); |
---|
1616 | mGeometryBased->set(); |
---|
1617 | |
---|
1618 | mViewPointDriven->set_visible(); |
---|
1619 | mViewPointDriven->activate(); |
---|
1620 | |
---|
1621 | /* |
---|
1622 | mTypeLabel->set_visible(); |
---|
1623 | mTypeLabel->activate(); |
---|
1624 | |
---|
1625 | mChangeTexture->set_visible(); |
---|
1626 | mChangeTexture->activate(); |
---|
1627 | */ |
---|
1628 | |
---|
1629 | mMeshReductionLabel->set_visible(); |
---|
1630 | mMeshReductionLabel->activate(); |
---|
1631 | |
---|
1632 | mPercent->set_visible(); |
---|
1633 | mPercent->activate(); |
---|
1634 | mPercent->set(); |
---|
1635 | |
---|
1636 | mVerticesNumber->set_visible(); |
---|
1637 | mVerticesNumber->activate(); |
---|
1638 | |
---|
1639 | mMeshReduction->set_visible(); |
---|
1640 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
1641 | mMeshReduction->activate(); |
---|
1642 | |
---|
1643 | mButtonProcess->set_visible(); |
---|
1644 | mButtonProcess->activate(); |
---|
1645 | |
---|
1646 | mProcessBar->set_visible(); |
---|
1647 | mProcessBar->activate(); |
---|
1648 | } |
---|
1649 | |
---|
1650 | //------------------------------------------------------------------------- |
---|
1651 | // Hide the Simplify Leaves Collapse. |
---|
1652 | //------------------------------------------------------------------------- |
---|
1653 | void GeoMeshViewUI::hideLeavesCollapse() |
---|
1654 | { |
---|
1655 | mMetricLabel->hide(); |
---|
1656 | mMetricLabel->deactivate(); |
---|
1657 | |
---|
1658 | mGeometryBased->hide(); |
---|
1659 | mGeometryBased->deactivate(); |
---|
1660 | |
---|
1661 | mViewPointDriven->hide(); |
---|
1662 | mViewPointDriven->deactivate(); |
---|
1663 | |
---|
1664 | /* |
---|
1665 | mTypeLabel->hide(); |
---|
1666 | mTypeLabel->deactivate(); |
---|
1667 | |
---|
1668 | mChangeTexture->hide(); |
---|
1669 | mChangeTexture->deactivate(); |
---|
1670 | */ |
---|
1671 | |
---|
1672 | mMeshReductionLabel->hide(); |
---|
1673 | mMeshReductionLabel->deactivate(); |
---|
1674 | |
---|
1675 | mPercent->hide(); |
---|
1676 | mPercent->deactivate(); |
---|
1677 | |
---|
1678 | mVerticesNumber->hide(); |
---|
1679 | mVerticesNumber->deactivate(); |
---|
1680 | |
---|
1681 | mMeshReduction->hide(); |
---|
1682 | mMeshReduction->deactivate(); |
---|
1683 | |
---|
1684 | mButtonProcess->hide(); |
---|
1685 | mButtonProcess->deactivate(); |
---|
1686 | |
---|
1687 | mProcessBar->hide(); |
---|
1688 | mProcessBar->deactivate(); |
---|
1689 | } |
---|
1690 | |
---|
1691 | //------------------------------------------------------------------------- |
---|
1692 | // Show the LodStrips Panel. |
---|
1693 | //------------------------------------------------------------------------- |
---|
1694 | void GeoMeshViewUI::showOpenMeshSimplification() |
---|
1695 | { |
---|
1696 | mButtonProcess->set_visible(); |
---|
1697 | mButtonProcess->activate(); |
---|
1698 | |
---|
1699 | mProcessBar->set_visible(); |
---|
1700 | mProcessBar->activate(); |
---|
1701 | |
---|
1702 | mButtonBuild->set_visible(); |
---|
1703 | mButtonBuild->activate(); |
---|
1704 | |
---|
1705 | mBuildBar->set_visible(); |
---|
1706 | mBuildBar->activate(); |
---|
1707 | } |
---|
1708 | |
---|
1709 | //------------------------------------------------------------------------- |
---|
1710 | // Hide the LodStrips Panel. |
---|
1711 | //------------------------------------------------------------------------- |
---|
1712 | void GeoMeshViewUI::hideOpenMeshSimplification() |
---|
1713 | { |
---|
1714 | mButtonProcess->hide(); |
---|
1715 | mButtonProcess->deactivate(); |
---|
1716 | |
---|
1717 | mProcessBar->hide(); |
---|
1718 | mProcessBar->deactivate(); |
---|
1719 | |
---|
1720 | mButtonBuild->hide(); |
---|
1721 | mButtonBuild->deactivate(); |
---|
1722 | |
---|
1723 | mBuildBar->hide(); |
---|
1724 | mBuildBar->deactivate(); |
---|
1725 | } |
---|
1726 | |
---|
1727 | //------------------------------------------------------------------------- |
---|
1728 | // Shows the auto generate LodStrips panel. |
---|
1729 | //------------------------------------------------------------------------- |
---|
1730 | void GeoMeshViewUI::showAutoGenerateLodStrips() |
---|
1731 | { |
---|
1732 | // Shows the simplify panel. |
---|
1733 | showEdgeCollapse(); |
---|
1734 | |
---|
1735 | // Deactive VMI option. |
---|
1736 | //mViewPointDriven->deactivate(); |
---|
1737 | |
---|
1738 | mButtonBuild->set_visible(); |
---|
1739 | //mButtonBuild->activate(); |
---|
1740 | |
---|
1741 | mBuildBar->set_visible(); |
---|
1742 | //mBuildBar->activate(); |
---|
1743 | } |
---|
1744 | |
---|
1745 | //------------------------------------------------------------------------- |
---|
1746 | // Shows the auto generate LodStrips panel. |
---|
1747 | //------------------------------------------------------------------------- |
---|
1748 | void GeoMeshViewUI::showAutoGenerateLodTrees() |
---|
1749 | { |
---|
1750 | // Shows the simplify panel. |
---|
1751 | showEdgeCollapse(); |
---|
1752 | |
---|
1753 | // Deactive VMI option. |
---|
1754 | mViewPointDriven->deactivate(); |
---|
1755 | |
---|
1756 | mButtonBuild->set_visible(); |
---|
1757 | //mButtonBuild->activate(); |
---|
1758 | |
---|
1759 | mBuildBar->set_visible(); |
---|
1760 | //mBuildBar->activate(); |
---|
1761 | } |
---|
1762 | |
---|
1763 | //------------------------------------------------------------------------- |
---|
1764 | // Show the LodStrips visulization panel. |
---|
1765 | //------------------------------------------------------------------------- |
---|
1766 | void GeoMeshViewUI::showLodStripSlider() |
---|
1767 | { |
---|
1768 | mLodStripSlider->set_visible(); |
---|
1769 | mLodStripSlider->activate(); |
---|
1770 | } |
---|
1771 | |
---|
1772 | //------------------------------------------------------------------------- |
---|
1773 | // Hide the LodStrips visualization panel. |
---|
1774 | //------------------------------------------------------------------------- |
---|
1775 | void GeoMeshViewUI::hideLodStripSlider() |
---|
1776 | { |
---|
1777 | mLodStripSlider->hide(); |
---|
1778 | mLodStripSlider->deactivate(); |
---|
1779 | } |
---|
1780 | |
---|
1781 | //------------------------------------------------------------------------- |
---|
1782 | // Show the LodTree visulization panel. |
---|
1783 | //------------------------------------------------------------------------- |
---|
1784 | void GeoMeshViewUI::showLodTreeSlider() |
---|
1785 | { |
---|
1786 | mLodTreeSlider->set_visible(); |
---|
1787 | mLodTreeSlider->activate(); |
---|
1788 | } |
---|
1789 | |
---|
1790 | //------------------------------------------------------------------------- |
---|
1791 | // Hide the LodTree visualization panel. |
---|
1792 | //------------------------------------------------------------------------- |
---|
1793 | void GeoMeshViewUI::hideLodTreeSlider() |
---|
1794 | { |
---|
1795 | mLodTreeSlider->hide(); |
---|
1796 | mLodTreeSlider->deactivate(); |
---|
1797 | } |
---|
1798 | |
---|
1799 | //------------------------------------------------------------------------- |
---|
1800 | // Show the LodTrees Panel. |
---|
1801 | //------------------------------------------------------------------------- |
---|
1802 | void GeoMeshViewUI::showOpenLeavesSimplification() |
---|
1803 | { |
---|
1804 | mButtonBuild->set_visible(); |
---|
1805 | mButtonBuild->activate(); |
---|
1806 | |
---|
1807 | mBuildBar->set_visible(); |
---|
1808 | mBuildBar->activate(); |
---|
1809 | } |
---|
1810 | |
---|
1811 | //------------------------------------------------------------------------- |
---|
1812 | // Hide the LodTrees Panel. |
---|
1813 | //------------------------------------------------------------------------- |
---|
1814 | void GeoMeshViewUI::hideOpenLeavesSimplification() |
---|
1815 | { |
---|
1816 | mButtonBuild->hide(); |
---|
1817 | mButtonBuild->deactivate(); |
---|
1818 | |
---|
1819 | mBuildBar->hide(); |
---|
1820 | mBuildBar->deactivate(); |
---|
1821 | } |
---|
1822 | |
---|
1823 | //------------------------------------------------------------------------- |
---|
1824 | // Show the mesh info browser. |
---|
1825 | //------------------------------------------------------------------------- |
---|
1826 | void GeoMeshViewUI::showMeshInfo() |
---|
1827 | { |
---|
1828 | char type[10]; |
---|
1829 | unsigned int group_index; |
---|
1830 | unsigned int group_count; |
---|
1831 | unsigned int bone_count; |
---|
1832 | fltk::ItemGroup **info_group; |
---|
1833 | |
---|
1834 | group_index = 0; |
---|
1835 | |
---|
1836 | if (mGeoMesh) |
---|
1837 | { |
---|
1838 | // Remove previous mesh information |
---|
1839 | this->mMeshInfo->remove_all(); |
---|
1840 | ogeometry = new fltk::ItemGroup("Geometry"); |
---|
1841 | ogeometry->begin(); |
---|
1842 | |
---|
1843 | group_count = mGeoMesh->mSubMeshCount; |
---|
1844 | |
---|
1845 | // Add one group for skeleton info. |
---|
1846 | if (mGeoMesh->hasSkeleton) |
---|
1847 | { |
---|
1848 | group_count++; |
---|
1849 | } |
---|
1850 | |
---|
1851 | info_group = new fltk::ItemGroup*[group_count]; |
---|
1852 | |
---|
1853 | // Write skeleton info. |
---|
1854 | if (mGeoMesh->hasSkeleton) |
---|
1855 | { |
---|
1856 | char *group_name = new char[256]; |
---|
1857 | char *skel_name = new char[256]; |
---|
1858 | char *bone_assig = new char[256]; |
---|
1859 | sprintf(group_name,"Skeleton"); |
---|
1860 | info_group[group_index] = new fltk::ItemGroup(group_name); |
---|
1861 | |
---|
1862 | info_group[group_index]->begin(); |
---|
1863 | sprintf(skel_name,"Name: %s",mGeoMesh->mSkeletonName); |
---|
1864 | new fltk::Item(skel_name); |
---|
1865 | bone_count = mGeoMesh->mBones.size(); |
---|
1866 | |
---|
1867 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
1868 | { |
---|
1869 | bone_count += mGeoMesh->mSubMesh[i].mBones.size(); |
---|
1870 | } |
---|
1871 | sprintf(bone_assig,"Bone assignamets: %d",bone_count); |
---|
1872 | new fltk::Item(bone_assig); |
---|
1873 | info_group[group_index]->end(); |
---|
1874 | |
---|
1875 | group_index++; |
---|
1876 | } |
---|
1877 | |
---|
1878 | for(int i=0; i<mGeoMesh->mSubMeshCount;i++) |
---|
1879 | { |
---|
1880 | char *group_name = new char[256]; |
---|
1881 | |
---|
1882 | if (geoMeshView->getLeavesSubMesh() >= 0) |
---|
1883 | { |
---|
1884 | if (geoMeshView->getLeavesSubMesh() == i) |
---|
1885 | { |
---|
1886 | strcpy(type,"(Leaves)"); |
---|
1887 | } |
---|
1888 | else |
---|
1889 | { |
---|
1890 | strcpy(type,"(Trunc)"); |
---|
1891 | } |
---|
1892 | } |
---|
1893 | else |
---|
1894 | { |
---|
1895 | strcpy(type,""); |
---|
1896 | } |
---|
1897 | |
---|
1898 | // Submesh identifier. |
---|
1899 | sprintf(group_name,"SubMesh %d %s",i,type); |
---|
1900 | |
---|
1901 | info_group[group_index] = new fltk::ItemGroup(group_name); |
---|
1902 | info_group[group_index]->begin(); |
---|
1903 | fltk::Item *sharedGeometry; |
---|
1904 | if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) |
---|
1905 | { |
---|
1906 | sharedGeometry = new fltk::Item("Shared Geometry: Yes"); |
---|
1907 | } |
---|
1908 | else |
---|
1909 | { |
---|
1910 | sharedGeometry = new fltk::Item("Shared Geometry: No"); |
---|
1911 | } |
---|
1912 | |
---|
1913 | // Adds material name. |
---|
1914 | char *cadena2=new char[100]; |
---|
1915 | sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); |
---|
1916 | |
---|
1917 | fltk::Item *geomaterial = new fltk::Item(cadena2); |
---|
1918 | |
---|
1919 | char *cadena3=new char[100]; |
---|
1920 | |
---|
1921 | sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); |
---|
1922 | fltk::Item *numberIndex = new fltk::Item(cadena3); |
---|
1923 | if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) |
---|
1924 | { |
---|
1925 | fltk::Item *type = new fltk::Item("Triangle List"); |
---|
1926 | } |
---|
1927 | else |
---|
1928 | { |
---|
1929 | fltk::Item *type = new fltk::Item("Triangle Strips"); |
---|
1930 | } |
---|
1931 | |
---|
1932 | char *cadenavertex=new char[30]; |
---|
1933 | sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); |
---|
1934 | fltk::Item *numberVertex = new fltk::Item(cadenavertex); |
---|
1935 | |
---|
1936 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) |
---|
1937 | { |
---|
1938 | fltk::Item *normals = new fltk::Item("Normals: Yes"); |
---|
1939 | } |
---|
1940 | else |
---|
1941 | { |
---|
1942 | fltk::Item *normals = new fltk::Item("Normals: No"); |
---|
1943 | } |
---|
1944 | |
---|
1945 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) |
---|
1946 | { |
---|
1947 | fltk::Item *textures = new fltk::Item("Textures: Yes"); |
---|
1948 | } |
---|
1949 | else |
---|
1950 | { |
---|
1951 | fltk::Item *textures = new fltk::Item("Textures: No"); |
---|
1952 | } |
---|
1953 | |
---|
1954 | |
---|
1955 | info_group[group_index]->end(); |
---|
1956 | } |
---|
1957 | ogeometry->end(); |
---|
1958 | this->mMeshInfo->add(ogeometry); |
---|
1959 | } |
---|
1960 | |
---|
1961 | // Hide the right panel. |
---|
1962 | hideRightPanel(); |
---|
1963 | |
---|
1964 | mMeshInfo->set_visible(); |
---|
1965 | mMeshInfo->activate(); |
---|
1966 | } |
---|
1967 | |
---|
1968 | //------------------------------------------------------------------------- |
---|
1969 | // Hide the mesh info browser. |
---|
1970 | //------------------------------------------------------------------------- |
---|
1971 | void GeoMeshViewUI::hideMeshInfo() |
---|
1972 | { |
---|
1973 | mMeshInfo->hide(); |
---|
1974 | mMeshInfo->deactivate(); |
---|
1975 | } |
---|
1976 | |
---|
1977 | //------------------------------------------------------------------------- |
---|
1978 | // Hide the right panel. |
---|
1979 | //------------------------------------------------------------------------- |
---|
1980 | void GeoMeshViewUI::hideRightPanel() |
---|
1981 | { |
---|
1982 | hideStripify(); |
---|
1983 | hideEdgeCollapse(); |
---|
1984 | hideLeavesCollapse(); |
---|
1985 | hideOpenMeshSimplification(); |
---|
1986 | hideOpenLeavesSimplification(); |
---|
1987 | hideLodStripSlider(); |
---|
1988 | hideLodTreeSlider(); |
---|
1989 | hideMeshInfo(); |
---|
1990 | } |
---|
1991 | |
---|
1992 | //------------------------------------------------------------------------- |
---|
1993 | // Get the number of vertices. |
---|
1994 | //------------------------------------------------------------------------- |
---|
1995 | size_t GeoMeshViewUI::getVertexCount(Mesh *geoMesh) |
---|
1996 | { |
---|
1997 | size_t vertex_count; |
---|
1998 | SubMesh *geoSubMesh; |
---|
1999 | |
---|
2000 | vertex_count = geoMesh->mVertexBuffer->mVertexCount; |
---|
2001 | |
---|
2002 | // For each submesh. |
---|
2003 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
2004 | { |
---|
2005 | // Gets the actual submesh. |
---|
2006 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
2007 | |
---|
2008 | // If the mesh does not have shared vertex. |
---|
2009 | if (!geoSubMesh->mSharedVertexBuffer) |
---|
2010 | { |
---|
2011 | // Adds the vertex of the submesh to the total count. |
---|
2012 | vertex_count += geoSubMesh->mVertexBuffer->mVertexCount; |
---|
2013 | } |
---|
2014 | } |
---|
2015 | |
---|
2016 | return vertex_count; |
---|
2017 | } |
---|
2018 | |
---|
2019 | //------------------------------------------------------------------------- |
---|
2020 | // Get the number of triangles. |
---|
2021 | //------------------------------------------------------------------------- |
---|
2022 | size_t GeoMeshViewUI::getTriangleCount(Geometry::Mesh *geoMesh) |
---|
2023 | { |
---|
2024 | size_t triangle_count; |
---|
2025 | SubMesh *geoSubMesh; |
---|
2026 | |
---|
2027 | // Initialize the triangle count. |
---|
2028 | triangle_count = 0; |
---|
2029 | |
---|
2030 | // If the application is in visualize lodstrips mode. |
---|
2031 | if (mApplicationState == VISUALIZE_LODSTRIPS) |
---|
2032 | { |
---|
2033 | triangle_count = geoMeshView->getLodStripsTriangleCount(); |
---|
2034 | } |
---|
2035 | else |
---|
2036 | { |
---|
2037 | // For each submesh. |
---|
2038 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
2039 | { |
---|
2040 | // Gets the actual submesh. |
---|
2041 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
2042 | |
---|
2043 | switch (geoSubMesh->mType) |
---|
2044 | { |
---|
2045 | case GEO_TRIANGLE_LIST: |
---|
2046 | triangle_count += geoSubMesh->mIndexCount / 3; |
---|
2047 | break; |
---|
2048 | case GEO_TRIANGLE_STRIPS: |
---|
2049 | triangle_count += geoSubMesh->mIndexCount - 2; |
---|
2050 | break; |
---|
2051 | } |
---|
2052 | } |
---|
2053 | } |
---|
2054 | |
---|
2055 | return triangle_count; |
---|
2056 | } |
---|
2057 | |
---|
2058 | //------------------------------------------------------------------------- |
---|
2059 | // Get the number of strips. |
---|
2060 | //------------------------------------------------------------------------- |
---|
2061 | size_t GeoMeshViewUI::getStripCount(Geometry::Mesh *geoMesh) |
---|
2062 | { |
---|
2063 | size_t strip_count; |
---|
2064 | SubMesh *geoSubMesh; |
---|
2065 | |
---|
2066 | // Initialize the triangle count. |
---|
2067 | strip_count = 0; |
---|
2068 | |
---|
2069 | // For each submesh. |
---|
2070 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
2071 | { |
---|
2072 | // Gets the actual submesh. |
---|
2073 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
2074 | |
---|
2075 | if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) |
---|
2076 | { |
---|
2077 | strip_count += geoSubMesh->mStripCount; |
---|
2078 | } |
---|
2079 | } |
---|
2080 | |
---|
2081 | return strip_count; |
---|
2082 | } |
---|
2083 | |
---|
2084 | //------------------------------------------------------------------------- |
---|
2085 | // It paints the submesh selected by the mMeshInfo tree. |
---|
2086 | // Trate the mMeshInfo event. |
---|
2087 | //------------------------------------------------------------------------- |
---|
2088 | int GeoMeshViewUI::paintMesh(void) |
---|
2089 | { |
---|
2090 | char selectedTag[100]; |
---|
2091 | char *pch; |
---|
2092 | char *p; |
---|
2093 | int meshNumber; |
---|
2094 | |
---|
2095 | // Initializa mesh to not selected. |
---|
2096 | meshNumber = -1; |
---|
2097 | |
---|
2098 | // Shows the selected object label. |
---|
2099 | strcpy(selectedTag,mMeshInfo->goto_focus()->label()); |
---|
2100 | |
---|
2101 | p=strstr(selectedTag,"SubMesh "); |
---|
2102 | |
---|
2103 | // If the item begins with string "SubMesh". |
---|
2104 | if (p!=NULL) |
---|
2105 | { |
---|
2106 | pch = strtok (selectedTag," "); |
---|
2107 | pch = strtok (NULL, " "); |
---|
2108 | sscanf(pch,"%d",&meshNumber); |
---|
2109 | } |
---|
2110 | |
---|
2111 | geoMeshView->setSubMeshSelected(meshNumber); |
---|
2112 | geoMeshView->redraw(); |
---|
2113 | |
---|
2114 | return meshNumber; |
---|
2115 | } |
---|
2116 | |
---|
2117 | //------------------------------------------------------------------------- |
---|
2118 | // Simplify the mesh object. |
---|
2119 | //------------------------------------------------------------------------- |
---|
2120 | bool GeoMeshViewUI::simplifyEdgeCollapse() |
---|
2121 | { |
---|
2122 | Real percent; |
---|
2123 | |
---|
2124 | // Free memory. |
---|
2125 | if (mMeshSimplifier != NULL) |
---|
2126 | { |
---|
2127 | delete mMeshSimplifier; |
---|
2128 | } |
---|
2129 | |
---|
2130 | // If input field empty. |
---|
2131 | if (mMeshReduction->fvalue() <= 0.0) |
---|
2132 | { |
---|
2133 | return false; |
---|
2134 | } |
---|
2135 | |
---|
2136 | // Saves OpenGL contex. |
---|
2137 | geoMeshView->saveContext(); |
---|
2138 | |
---|
2139 | // Debug. |
---|
2140 | cout << "Mesh Reduction: " |
---|
2141 | << mMeshReduction->fvalue() |
---|
2142 | << endl; |
---|
2143 | |
---|
2144 | // Gets simplify option. |
---|
2145 | if (mGeometryBased->value()) |
---|
2146 | { |
---|
2147 | simplificationState = MESHSIMP; |
---|
2148 | mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, |
---|
2149 | progress_function); |
---|
2150 | } |
---|
2151 | else |
---|
2152 | { |
---|
2153 | simplificationState = VIEWPOINTDRIVEN; |
---|
2154 | mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, |
---|
2155 | progress_function); |
---|
2156 | } |
---|
2157 | |
---|
2158 | mMeshSimplifier->setMeshLeaves(idMeshLeaves); |
---|
2159 | |
---|
2160 | if (mPercent->value()) |
---|
2161 | { |
---|
2162 | // Simplificaci?n por porcentaje |
---|
2163 | if (mMeshReduction->fvalue() <= 100.0 && |
---|
2164 | mMeshReduction->fvalue() > 0.0) |
---|
2165 | { |
---|
2166 | percent = mMeshReduction->fvalue(); |
---|
2167 | percent = percent / 100.0; |
---|
2168 | |
---|
2169 | // Simplifica el geomesh -> Par?metro es un factor LOD [0,1]. |
---|
2170 | |
---|
2171 | mMeshSimplifier->Simplify(percent); |
---|
2172 | |
---|
2173 | // Deletes the previous mesh. |
---|
2174 | delete mUndoMesh; |
---|
2175 | |
---|
2176 | mUndoMesh = new Mesh(); |
---|
2177 | |
---|
2178 | // Sets the undo mesh. |
---|
2179 | *mUndoMesh = *mGeoMesh; |
---|
2180 | |
---|
2181 | delete mGeoMesh; |
---|
2182 | |
---|
2183 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
2184 | } |
---|
2185 | else |
---|
2186 | { |
---|
2187 | fltk::alert("Wrong value for simplification.\n" |
---|
2188 | "Valid values [0..100]"); |
---|
2189 | |
---|
2190 | return false; |
---|
2191 | } |
---|
2192 | } |
---|
2193 | else |
---|
2194 | { |
---|
2195 | // Simplificar hasta un n?mero de v?rtices. |
---|
2196 | uint32 v = (uint32)mMeshReduction->fvalue(); |
---|
2197 | |
---|
2198 | // Simplifica el geomesh -> Par?metro es un factor LOD [0,1]. |
---|
2199 | mMeshSimplifier->Simplify(v); |
---|
2200 | |
---|
2201 | // Deletes the previous mesh. |
---|
2202 | delete mUndoMesh; |
---|
2203 | |
---|
2204 | mUndoMesh = new Mesh(); |
---|
2205 | |
---|
2206 | // Sets the undo mesh. |
---|
2207 | *mUndoMesh = *mGeoMesh; |
---|
2208 | |
---|
2209 | delete mGeoMesh; |
---|
2210 | |
---|
2211 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
2212 | } |
---|
2213 | |
---|
2214 | return true; |
---|
2215 | } |
---|
2216 | |
---|
2217 | //------------------------------------------------------------------------- |
---|
2218 | // Simplify the mesh object. |
---|
2219 | //------------------------------------------------------------------------- |
---|
2220 | void GeoMeshViewUI::simplifyLeavesCollapse() |
---|
2221 | { |
---|
2222 | bool error; |
---|
2223 | uint32 vi; |
---|
2224 | |
---|
2225 | // Initialize error flag. |
---|
2226 | error = false; |
---|
2227 | |
---|
2228 | // Check submeshes for triangles strips. |
---|
2229 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
2230 | { |
---|
2231 | // If current submesh is in triangle strips. |
---|
2232 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
2233 | { |
---|
2234 | error = true; |
---|
2235 | } |
---|
2236 | } |
---|
2237 | |
---|
2238 | // if the mesh is stripified. |
---|
2239 | if (error) |
---|
2240 | { |
---|
2241 | fltk::alert("Can't simplify a tree in triagle strips."); |
---|
2242 | } |
---|
2243 | // if the mesh is in triangle list. |
---|
2244 | else |
---|
2245 | { |
---|
2246 | simplificationState = HOJAS; |
---|
2247 | |
---|
2248 | mTreeSimplifier = new TreeSimplifier(mGeoMesh, progress_function); |
---|
2249 | vi = (uint32)mMeshReduction->fvalue(); |
---|
2250 | |
---|
2251 | // Simplify |
---|
2252 | if(idMeshLeaves != (unsigned short)-1) |
---|
2253 | { |
---|
2254 | // Simplify |
---|
2255 | mTreeSimplifier->Simplify(vi, idMeshLeaves); |
---|
2256 | |
---|
2257 | // Deletes the previous mesh. |
---|
2258 | delete mUndoMesh; |
---|
2259 | |
---|
2260 | mUndoMesh = new Mesh(); |
---|
2261 | |
---|
2262 | // Sets the undo mesh. |
---|
2263 | *mUndoMesh = *mGeoMesh; |
---|
2264 | |
---|
2265 | delete mGeoMesh; |
---|
2266 | |
---|
2267 | mGeoMesh = mTreeSimplifier->GetMesh(); |
---|
2268 | |
---|
2269 | geoMeshView->setMesh(mGeoMesh); |
---|
2270 | } |
---|
2271 | else |
---|
2272 | { |
---|
2273 | fltk::alert("You must select the mesh that contains the leaves."); |
---|
2274 | } |
---|
2275 | } |
---|
2276 | } |
---|
2277 | |
---|
2278 | //------------------------------------------------------------------------- |
---|
2279 | // Create a simplification sequence of the simplification method. |
---|
2280 | //------------------------------------------------------------------------- |
---|
2281 | void GeoMeshViewUI::createSimplificationSequence() |
---|
2282 | { |
---|
2283 | MeshSimplificationSequence *secsimpl; |
---|
2284 | |
---|
2285 | secsimpl = mMeshSimplifier->GetSimplificationSequence(); |
---|
2286 | |
---|
2287 | // Nombre del mesh para guardar la secuencia de simplificaci?n. |
---|
2288 | secsimpl->putMeshName(nombremesh); |
---|
2289 | secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); |
---|
2290 | } |
---|
2291 | |
---|
2292 | //------------------------------------------------------------------------- |
---|
2293 | // Create a simplification sequence of the leaves. |
---|
2294 | //------------------------------------------------------------------------- |
---|
2295 | void GeoMeshViewUI::createLeavesSequence(const std::string &filename) |
---|
2296 | { |
---|
2297 | TreeSimplificationSequence *tree_sequencer; |
---|
2298 | |
---|
2299 | tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); |
---|
2300 | |
---|
2301 | tree_sequencer->putMeshName(nombremesh); |
---|
2302 | tree_sequencer->Save(Serializer(filename,Serializer::APPEND)); |
---|
2303 | |
---|
2304 | delete tree_sequencer; |
---|
2305 | } |
---|
2306 | |
---|
2307 | //------------------------------------------------------------------------- |
---|
2308 | // Stripify the mesh object. |
---|
2309 | //------------------------------------------------------------------------- |
---|
2310 | void GeoMeshViewUI::stripify() |
---|
2311 | { |
---|
2312 | bool error; |
---|
2313 | char char_value[10]; |
---|
2314 | CustomStripifier *geoStripifier; |
---|
2315 | |
---|
2316 | // Initialize error flag. |
---|
2317 | error = false; |
---|
2318 | |
---|
2319 | // Check submeshes for triangles strips. |
---|
2320 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
2321 | { |
---|
2322 | // If current submesh is in triangle strips. |
---|
2323 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
2324 | { |
---|
2325 | error = true; |
---|
2326 | } |
---|
2327 | } |
---|
2328 | |
---|
2329 | // if the mesh is stripified. |
---|
2330 | if (error) |
---|
2331 | { |
---|
2332 | fltk::alert("The mesh is already in strips."); |
---|
2333 | } |
---|
2334 | // if the mesh is in triangle list. |
---|
2335 | else |
---|
2336 | { |
---|
2337 | //Stripify. |
---|
2338 | geoStripifier = new CustomStripifier(mGeoMesh); |
---|
2339 | |
---|
2340 | // Set the progress bar function. |
---|
2341 | geoStripifier->SetProgressFunc(progress_function); |
---|
2342 | |
---|
2343 | // Sets the leaves submesh if exists. |
---|
2344 | geoStripifier->SetSubMeshLeaves(idMeshLeaves); |
---|
2345 | |
---|
2346 | if (geoStripifier->Stripify()) |
---|
2347 | { |
---|
2348 | // Deletes the mesh object. |
---|
2349 | delete mUndoMesh; |
---|
2350 | |
---|
2351 | mUndoMesh = new Mesh(); |
---|
2352 | |
---|
2353 | *mUndoMesh = *mGeoMesh; |
---|
2354 | |
---|
2355 | delete mGeoMesh; |
---|
2356 | |
---|
2357 | // Gets the mesh stripified. |
---|
2358 | mGeoMesh = geoStripifier->GetMesh(); |
---|
2359 | |
---|
2360 | // Visualize the mesh stripified. |
---|
2361 | geoMeshView->setMesh(mGeoMesh); |
---|
2362 | |
---|
2363 | // Store the color of the strips. |
---|
2364 | geoMeshView->setStripColors(); |
---|
2365 | } |
---|
2366 | else |
---|
2367 | { |
---|
2368 | // Error message. |
---|
2369 | fltk::alert("Impossible to stripify. The mesh is not manifold"); |
---|
2370 | } |
---|
2371 | |
---|
2372 | // Deletes the stripifier object. |
---|
2373 | delete geoStripifier; |
---|
2374 | } |
---|
2375 | } |
---|
2376 | |
---|
2377 | //------------------------------------------------------------------------- |
---|
2378 | // Method that undo then mesh changes. |
---|
2379 | //------------------------------------------------------------------------- |
---|
2380 | void GeoMeshViewUI::undo() |
---|
2381 | { |
---|
2382 | Mesh *aux_mesh; |
---|
2383 | |
---|
2384 | // if the undo mesh is not initialized. |
---|
2385 | if (mUndoMesh != NULL) |
---|
2386 | { |
---|
2387 | aux_mesh = mGeoMesh; |
---|
2388 | mGeoMesh = mUndoMesh; |
---|
2389 | |
---|
2390 | // Visualize the mesh. |
---|
2391 | geoMeshView->setMesh(mGeoMesh); |
---|
2392 | |
---|
2393 | // Refresh geometry attributes. |
---|
2394 | refreshApplicationBar(); |
---|
2395 | |
---|
2396 | // Repaint the window. |
---|
2397 | mMainWindow->redraw(); |
---|
2398 | |
---|
2399 | // Deletes the actual mesh. |
---|
2400 | delete aux_mesh; |
---|
2401 | |
---|
2402 | mUndoMesh = NULL; |
---|
2403 | } |
---|
2404 | } |
---|
2405 | |
---|
2406 | //------------------------------------------------------------------------- |
---|
2407 | // Refresh number of vertices, triangles, strips, ... |
---|
2408 | //------------------------------------------------------------------------- |
---|
2409 | void GeoMeshViewUI::refreshApplicationBar() |
---|
2410 | { |
---|
2411 | static char vertices_value[50]; |
---|
2412 | static char triangles_value[50]; |
---|
2413 | static char strips_value[50]; |
---|
2414 | |
---|
2415 | // Translate the vertex count to a char value. |
---|
2416 | sprintf(vertices_value,"Vertices %d",getVertexCount(mGeoMesh)); |
---|
2417 | |
---|
2418 | mVertices->label(vertices_value); |
---|
2419 | |
---|
2420 | // Translate the triangle count to a char value. |
---|
2421 | sprintf(triangles_value,"Triangles %d",getTriangleCount(mGeoMesh)); |
---|
2422 | |
---|
2423 | mTriangles->label(triangles_value); |
---|
2424 | |
---|
2425 | // Translate the triangle count to a char value. |
---|
2426 | sprintf(strips_value,"Strips %d",getStripCount(mGeoMesh)); |
---|
2427 | |
---|
2428 | mStrips->label(strips_value); |
---|
2429 | |
---|
2430 | mMainWindow->redraw(); |
---|
2431 | } |
---|
2432 | |
---|
2433 | // Method that updates the porgress bar. |
---|
2434 | float GeoMeshViewUI::updateProgressBar(float v) |
---|
2435 | { |
---|
2436 | fltk::ProgressBar *progressBar; |
---|
2437 | |
---|
2438 | // Choose progress bar to update. |
---|
2439 | switch(progressBarType) |
---|
2440 | { |
---|
2441 | case PROCESS: |
---|
2442 | progressBar = mProcessBar; |
---|
2443 | break; |
---|
2444 | case BUILD: |
---|
2445 | progressBar = mBuildBar; |
---|
2446 | break; |
---|
2447 | } |
---|
2448 | |
---|
2449 | // Update progress bar. |
---|
2450 | progressBar->step(v); |
---|
2451 | progressBar->step(); |
---|
2452 | mMainWindow->flush(); |
---|
2453 | //mMainWindow->redraw(); |
---|
2454 | |
---|
2455 | return 0; |
---|
2456 | } |
---|
2457 | |
---|
2458 | //------------------------------------------------------------------------- |
---|
2459 | // Initialize the lodstripslibrary for visualization. |
---|
2460 | //------------------------------------------------------------------------- |
---|
2461 | void GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData *loddata, Mesh *geomesh) |
---|
2462 | { |
---|
2463 | // If there is no lod strips object. |
---|
2464 | if (lodStripsLib) |
---|
2465 | { |
---|
2466 | delete lodStripsLib; |
---|
2467 | delete lod_index_data; |
---|
2468 | } |
---|
2469 | |
---|
2470 | // New lod strips object. |
---|
2471 | lod_index_data = new GeoToolIndexData(geomesh->mSubMeshCount); |
---|
2472 | lodStripsLib = new LodStripsLibrary(loddata, geomesh, lod_index_data); |
---|
2473 | |
---|
2474 | // Sets the slider range. |
---|
2475 | // mLodStripSlider->range(lodStripsLib->MinLod(),lodStripsLib->MaxLod()); |
---|
2476 | mLodStripSlider->range(0.0f,1.0f); |
---|
2477 | |
---|
2478 | // Pass to geomeshview the lod strips object. |
---|
2479 | geoMeshView->setLodStripsLibrary(lodStripsLib); |
---|
2480 | |
---|
2481 | // Puts the slider in the max position. |
---|
2482 | mLodStripSlider->value(1.0f); |
---|
2483 | } |
---|
2484 | |
---|
2485 | //------------------------------------------------------------------------- |
---|
2486 | // Initialize the lodTreelibrary for visualization. |
---|
2487 | //------------------------------------------------------------------------- |
---|
2488 | void GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData *lodstripsdata, const TreeSimplificationSequence *treesimpseq, Mesh *geomesh/*, uint32 ileafSubMesh*/) |
---|
2489 | { |
---|
2490 | // If there is no lod strips object. |
---|
2491 | if (lodTreeLib) |
---|
2492 | { |
---|
2493 | delete lodTreeLib; |
---|
2494 | delete lod_index_data; |
---|
2495 | } |
---|
2496 | |
---|
2497 | // New lod strips object. |
---|
2498 | |
---|
2499 | lod_index_data = new GeoToolIndexData(geomesh->mSubMeshCount); |
---|
2500 | lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh,lod_index_data); |
---|
2501 | |
---|
2502 | // Sets the slider range. |
---|
2503 | mLodStripSlider->range(0.0f,1.0f); |
---|
2504 | mLodTreeSlider->range(0.0f,1.0f); |
---|
2505 | |
---|
2506 | // Pass to geomeshview the lod strips object. |
---|
2507 | geoMeshView->setLodTreesLibrary(lodTreeLib); |
---|
2508 | |
---|
2509 | // Puts the slider in the max position. |
---|
2510 | mLodStripSlider->value(1.0f); |
---|
2511 | mLodTreeSlider->value(1.0f); |
---|
2512 | } |
---|
2513 | |
---|
2514 | //------------------------------------------------------------------------- |
---|
2515 | // Open a mesh file. |
---|
2516 | //------------------------------------------------------------------------- |
---|
2517 | void GeoMeshViewUI::openMeshFile(void) |
---|
2518 | { |
---|
2519 | Mesh *mesh_loaded; |
---|
2520 | fltk::FileChooser *fcho; |
---|
2521 | static char char_value[10]; |
---|
2522 | static char title[256]; |
---|
2523 | |
---|
2524 | fcho = new fltk::FileChooser("", |
---|
2525 | "*.{mesh,obj}", |
---|
2526 | fltk::FileChooser::CREATE, |
---|
2527 | "Open a mesh"); |
---|
2528 | |
---|
2529 | fcho->exec(); |
---|
2530 | |
---|
2531 | // File name. |
---|
2532 | mFileName = (char *)fcho->value(); |
---|
2533 | |
---|
2534 | if (mFileName) |
---|
2535 | { |
---|
2536 | // Loads a new mesh. |
---|
2537 | mesh_loaded = geoMeshLoader->load(mFileName); |
---|
2538 | |
---|
2539 | // If no error happens. |
---|
2540 | if (mesh_loaded) |
---|
2541 | { |
---|
2542 | // Identify the mesh that stores the leaves |
---|
2543 | idMeshLeaves = -1; |
---|
2544 | |
---|
2545 | // Delete the current mesh. |
---|
2546 | delete mGeoMesh; |
---|
2547 | delete mUndoMesh; |
---|
2548 | |
---|
2549 | // Assigns mesh loaded. |
---|
2550 | mGeoMesh = mesh_loaded; |
---|
2551 | |
---|
2552 | // Set Window Title. |
---|
2553 | strcpy(title,filename_name(mFileName)); |
---|
2554 | mMainWindow->label(strcat(title," - GeoTool")); |
---|
2555 | |
---|
2556 | // Stores the name of the mesh. |
---|
2557 | nombremesh = new char[255]; |
---|
2558 | strcpy(nombremesh,mFileName); |
---|
2559 | |
---|
2560 | // Reset the undo mesh. |
---|
2561 | mUndoMesh = new Mesh(); |
---|
2562 | *mUndoMesh = *mGeoMesh; |
---|
2563 | |
---|
2564 | // Translate the MB count to a char value. |
---|
2565 | sprintf(char_value, |
---|
2566 | "MB %.3f", |
---|
2567 | (float)geoMeshLoader->getFileSize()/1024/1024); |
---|
2568 | |
---|
2569 | mMB->label(char_value); |
---|
2570 | |
---|
2571 | // Set textures. |
---|
2572 | geoMeshView->resetTextures(); |
---|
2573 | setTextures(); |
---|
2574 | |
---|
2575 | // Visualize mesh. |
---|
2576 | geoMeshView->setMesh(mGeoMesh); |
---|
2577 | |
---|
2578 | // Hide right panel. |
---|
2579 | hideRightPanel(); |
---|
2580 | |
---|
2581 | // Quit culling. |
---|
2582 | menuRenderCW->clear_value(); |
---|
2583 | menuRenderCCW->clear_value(); |
---|
2584 | geoMeshView->deactiveCW(); |
---|
2585 | geoMeshView->deactiveCCW(); |
---|
2586 | |
---|
2587 | // Deactive solid mode and wire. |
---|
2588 | menuRenderSolid->clear_value(); |
---|
2589 | menuRenderWire->clear_value(); |
---|
2590 | menuRenderLighting->set_value(); |
---|
2591 | geoMeshView->deactiveSolid(); |
---|
2592 | geoMeshView->deactiveWire(); |
---|
2593 | geoMeshView->activeLighting(); |
---|
2594 | |
---|
2595 | // Fit model in midle. |
---|
2596 | geoMeshView->fit(); |
---|
2597 | |
---|
2598 | // Lighting smooth. |
---|
2599 | menuRenderFlat->clear_value(); |
---|
2600 | menuRenderSmooth->set_value(); |
---|
2601 | geoMeshView->smooth(); |
---|
2602 | |
---|
2603 | // Show title. |
---|
2604 | mProcessTitle->label("Mesh Info"); |
---|
2605 | |
---|
2606 | // Shows the mesh info. |
---|
2607 | showMeshInfo(); |
---|
2608 | |
---|
2609 | // if the mesh is stripified. |
---|
2610 | geoMeshView->setStripColors(); |
---|
2611 | |
---|
2612 | // Refresh geometry attributes. |
---|
2613 | refreshApplicationBar(); |
---|
2614 | |
---|
2615 | // Restore simplification state. |
---|
2616 | simplificationState = NO_SIMPLIFICATION; |
---|
2617 | } |
---|
2618 | } |
---|
2619 | |
---|
2620 | // Free memory. |
---|
2621 | delete fcho; |
---|
2622 | } |
---|
2623 | |
---|
2624 | // Set textures to mesh model. |
---|
2625 | void GeoMeshViewUI::setTextures() |
---|
2626 | { |
---|
2627 | GeoMaterialLoader *loader; |
---|
2628 | string filename; |
---|
2629 | string material; |
---|
2630 | |
---|
2631 | loader = new GeoMaterialLoader(); |
---|
2632 | |
---|
2633 | // For each submesh. |
---|
2634 | for (int submesh = 0; submesh < mGeoMesh->mSubMeshCount; submesh++) |
---|
2635 | { |
---|
2636 | material = string(mGeoMesh->mSubMesh[submesh].mMaterialName); |
---|
2637 | |
---|
2638 | // If exists material. |
---|
2639 | if (loader->existsMaterial(material)) |
---|
2640 | { |
---|
2641 | // Gets file name. |
---|
2642 | filename = loader->getTextureFileName(material); |
---|
2643 | |
---|
2644 | geoMeshView->addTexFile(filename.c_str()); |
---|
2645 | } |
---|
2646 | // If not exists material. |
---|
2647 | else |
---|
2648 | { |
---|
2649 | // File name empty. |
---|
2650 | filename = string(); |
---|
2651 | |
---|
2652 | geoMeshView->addTexFile(filename.c_str()); |
---|
2653 | } |
---|
2654 | } |
---|
2655 | } |
---|
2656 | |
---|
2657 | //------------------------------------------------------------------------- |
---|
2658 | // If file exists. |
---|
2659 | //------------------------------------------------------------------------- |
---|
2660 | bool GeoMeshViewUI::fileExists(const char *fileNameMesh) |
---|
2661 | { |
---|
2662 | FILE *pFile; |
---|
2663 | |
---|
2664 | // Open the mesh file. |
---|
2665 | pFile = fopen(fileNameMesh, "r"); |
---|
2666 | |
---|
2667 | if (pFile) |
---|
2668 | { |
---|
2669 | return true; |
---|
2670 | } |
---|
2671 | else |
---|
2672 | { |
---|
2673 | return false; |
---|
2674 | } |
---|
2675 | } |
---|
2676 | |
---|
2677 | //------------------------------------------------------------------------- |
---|
2678 | // Constructor |
---|
2679 | //------------------------------------------------------------------------- |
---|
2680 | GeoMeshViewUI::GeoMeshViewUI(TIPOFUNC fun) |
---|
2681 | { |
---|
2682 | progress_function = fun; |
---|
2683 | fltk::gifImage *logo; |
---|
2684 | |
---|
2685 | // Initialize the file name. |
---|
2686 | mFileName = NULL; |
---|
2687 | |
---|
2688 | // Initialize the 3D object. |
---|
2689 | mGeoMesh = NULL; |
---|
2690 | mUndoMesh = NULL; |
---|
2691 | |
---|
2692 | // Initialize mesh simplifier. |
---|
2693 | mMeshSimplifier = NULL; |
---|
2694 | |
---|
2695 | // Initialize the lod strip object. |
---|
2696 | lodStripsLib = NULL; |
---|
2697 | lodTreeLib = NULL; |
---|
2698 | |
---|
2699 | // Identify the mesh that stores the leaves |
---|
2700 | idMeshLeaves = -1; |
---|
2701 | |
---|
2702 | // Initialize the loader of meshes. |
---|
2703 | geoMeshLoader = new GeoMeshLoader(); |
---|
2704 | |
---|
2705 | // Initialize the menus application state. |
---|
2706 | mApplicationState = NONE; |
---|
2707 | |
---|
2708 | SubMeshNames=NULL; |
---|
2709 | |
---|
2710 | { |
---|
2711 | fltk::Window* o = new fltk::Window(800, 600,"GeoTool"); |
---|
2712 | |
---|
2713 | mMainWindow = o; |
---|
2714 | |
---|
2715 | // Program Icon for Win32. |
---|
2716 | mMainWindow->icon((char *)LoadIcon( GetModuleHandle(0), |
---|
2717 | MAKEINTRESOURCE(GEOICON))); |
---|
2718 | |
---|
2719 | // Double buffer. |
---|
2720 | mMainWindow->set_double_buffer(); |
---|
2721 | |
---|
2722 | o->user_data((void*)(this)); |
---|
2723 | o->begin(); |
---|
2724 | |
---|
2725 | { |
---|
2726 | fltk::Group* o = new fltk::Group(0, 27, 806, 559); |
---|
2727 | o->begin(); |
---|
2728 | |
---|
2729 | { |
---|
2730 | fltk::Group* o; |
---|
2731 | o = MainView = new fltk::Group(0, 0, 570, 530); |
---|
2732 | o->begin(); |
---|
2733 | |
---|
2734 | { |
---|
2735 | fltk::InvisibleBox* o; |
---|
2736 | o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); |
---|
2737 | o->box(fltk::FLAT_BOX); |
---|
2738 | o->color((fltk::Color)0xffffff00); |
---|
2739 | } |
---|
2740 | |
---|
2741 | { |
---|
2742 | GeoMeshView* o; |
---|
2743 | o = geoMeshView = new GeoMeshView( 0,0,570,530,0,this); |
---|
2744 | } |
---|
2745 | |
---|
2746 | o->end(); |
---|
2747 | |
---|
2748 | fltk::Group::current()->resizable(o); |
---|
2749 | |
---|
2750 | } |
---|
2751 | |
---|
2752 | { |
---|
2753 | fltk::Group* o; |
---|
2754 | o = MainView = new fltk::Group(570, 0, 230, 530); |
---|
2755 | o->begin(); |
---|
2756 | |
---|
2757 | { |
---|
2758 | fltk::Button* o; |
---|
2759 | o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); |
---|
2760 | o->callback((fltk::Callback*)cb_mButtonProcess); |
---|
2761 | o->hide(); |
---|
2762 | o->deactivate(); |
---|
2763 | } |
---|
2764 | |
---|
2765 | { |
---|
2766 | fltk::ProgressBar* o; |
---|
2767 | o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); |
---|
2768 | o->hide(); |
---|
2769 | o->deactivate(); |
---|
2770 | } |
---|
2771 | |
---|
2772 | { |
---|
2773 | fltk::Button* o; |
---|
2774 | o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); |
---|
2775 | o->callback((fltk::Callback*)cb_mButtonSort); |
---|
2776 | o->hide(); |
---|
2777 | o->deactivate(); |
---|
2778 | } |
---|
2779 | |
---|
2780 | { |
---|
2781 | fltk::ProgressBar* o; |
---|
2782 | o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); |
---|
2783 | o->hide(); |
---|
2784 | o->deactivate(); |
---|
2785 | } |
---|
2786 | |
---|
2787 | { |
---|
2788 | fltk::Button* o; |
---|
2789 | o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); |
---|
2790 | o->callback((fltk::Callback*)cb_mButtonBuild); |
---|
2791 | o->hide(); |
---|
2792 | o->deactivate(); |
---|
2793 | } |
---|
2794 | |
---|
2795 | { |
---|
2796 | fltk::ProgressBar* o; |
---|
2797 | o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); |
---|
2798 | o->hide(); |
---|
2799 | o->deactivate(); |
---|
2800 | } |
---|
2801 | |
---|
2802 | { |
---|
2803 | fltk::Slider* o; |
---|
2804 | o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); |
---|
2805 | o->linesize(0.01f); |
---|
2806 | o->type(fltk::Slider::TICK_BELOW); |
---|
2807 | o->set_vertical(); |
---|
2808 | o->callback((fltk::Callback*)cb_mLodStripSlider); |
---|
2809 | o->hide(); |
---|
2810 | o->deactivate(); |
---|
2811 | } |
---|
2812 | { |
---|
2813 | fltk::Slider* o; |
---|
2814 | o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); |
---|
2815 | o->linesize(0.01f); |
---|
2816 | o->type(fltk::Slider::TICK_BELOW); |
---|
2817 | o->set_vertical(); |
---|
2818 | o->callback((fltk::Callback*)cb_mLodTreeSlider); |
---|
2819 | o->hide(); |
---|
2820 | o->deactivate(); |
---|
2821 | } |
---|
2822 | |
---|
2823 | { |
---|
2824 | mMetricLabel = new fltk::Output(26, 28, 0, 25, "Metric"); |
---|
2825 | fltk::Output* o = mMetricLabel; |
---|
2826 | o->set_vertical(); |
---|
2827 | o->box(fltk::NO_BOX); |
---|
2828 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2829 | o->color((fltk::Color)0xe0dfe300); |
---|
2830 | o->align(fltk::ALIGN_RIGHT); |
---|
2831 | } |
---|
2832 | |
---|
2833 | { |
---|
2834 | fltk::Group* o; |
---|
2835 | o = MainView = new fltk::Group(30, 40, 30, 60); |
---|
2836 | o->begin(); |
---|
2837 | { |
---|
2838 | mGeometryBased = new fltk::RadioButton(0, 8, 25, 25, "Geometry based"); |
---|
2839 | mViewPointDriven = new fltk::RadioButton(0, 23, 25, 25, "Viewpoint driven"); |
---|
2840 | } |
---|
2841 | o->end(); |
---|
2842 | } |
---|
2843 | |
---|
2844 | { |
---|
2845 | mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); |
---|
2846 | fltk::Widget* o = mProcessTitle; |
---|
2847 | o->set_vertical(); |
---|
2848 | o->box(fltk::NO_BOX); |
---|
2849 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2850 | o->labelsize(15.0); |
---|
2851 | o->color((fltk::Color)0xe0dfe300); |
---|
2852 | o->align(fltk::ALIGN_CENTER); |
---|
2853 | } |
---|
2854 | |
---|
2855 | { |
---|
2856 | mMeshReductionLabel = new fltk::Output(26, 124, 0, 25, "Mesh Reduction"); |
---|
2857 | fltk::Output* o = mMeshReductionLabel; |
---|
2858 | o->set_vertical(); |
---|
2859 | o->box(fltk::NO_BOX); |
---|
2860 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2861 | o->color((fltk::Color)0xe0dfe300); |
---|
2862 | o->align(fltk::ALIGN_RIGHT); |
---|
2863 | } |
---|
2864 | |
---|
2865 | { |
---|
2866 | fltk::Group* o; |
---|
2867 | o = MainView = new fltk::Group(30, 140, 30, 60); |
---|
2868 | o->begin(); |
---|
2869 | |
---|
2870 | { |
---|
2871 | mPercent = new fltk::RadioButton(0, 5, 25, 25, "%"); |
---|
2872 | mVerticesNumber = new fltk::RadioButton(0, 20, 25, 25, "Vertices number"); |
---|
2873 | } |
---|
2874 | o->end(); |
---|
2875 | } |
---|
2876 | |
---|
2877 | { |
---|
2878 | mMeshReduction = new fltk::FloatInput(75, 181, 75, 21, "Value:"); |
---|
2879 | fltk::FloatInput* o = mMeshReduction; |
---|
2880 | o->type(1); |
---|
2881 | } |
---|
2882 | |
---|
2883 | { |
---|
2884 | fltk::Group* o; |
---|
2885 | o = MainView = new fltk::Group(30, 100, 30, 60); |
---|
2886 | o->begin(); |
---|
2887 | |
---|
2888 | { |
---|
2889 | mOneCacheStrip = new fltk::RadioButton(0, 4, 25, 25, "One cache strip"); |
---|
2890 | mQualityStrips = new fltk::RadioButton(0, 23, 25, 25, "Quality strips"); |
---|
2891 | } |
---|
2892 | o->end(); |
---|
2893 | } |
---|
2894 | |
---|
2895 | { |
---|
2896 | fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); |
---|
2897 | o->set_vertical(); |
---|
2898 | o->callback((fltk::Callback*)cb_mMeshInfo); |
---|
2899 | } |
---|
2900 | o->end(); |
---|
2901 | } |
---|
2902 | |
---|
2903 | o->end(); |
---|
2904 | |
---|
2905 | fltk::Group::current()->resizable(o); |
---|
2906 | } |
---|
2907 | |
---|
2908 | { |
---|
2909 | fltk::MenuBar* o = menuBar = new fltk::MenuBar(1, 2, 801, 21); |
---|
2910 | o->begin(); |
---|
2911 | |
---|
2912 | // Menu File. |
---|
2913 | { |
---|
2914 | fltk::ItemGroup* o = menuFile = new fltk::ItemGroup("File"); |
---|
2915 | o->begin(); |
---|
2916 | |
---|
2917 | { |
---|
2918 | fltk::Item* o = menuFileOpen = new fltk::Item("Open"); |
---|
2919 | o->callback((fltk::Callback*)cb_menuFileOpen); |
---|
2920 | } |
---|
2921 | |
---|
2922 | { |
---|
2923 | fltk::Item* o = menuFileSave = new fltk::Item("Save"); |
---|
2924 | o->callback((fltk::Callback*)cb_menuFileSave); |
---|
2925 | } |
---|
2926 | |
---|
2927 | { |
---|
2928 | fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); |
---|
2929 | o->callback((fltk::Callback*)cb_menuFileSaveAs); |
---|
2930 | } |
---|
2931 | |
---|
2932 | { |
---|
2933 | fltk::Item* o = menuMeshExportOBJ = new fltk::Item("Export to OBJ"); |
---|
2934 | o->callback((fltk::Callback*)cb_menuMeshExportOBJ); |
---|
2935 | } |
---|
2936 | |
---|
2937 | { |
---|
2938 | fltk::Item* o = new fltk::Item("Transform to SV"); |
---|
2939 | o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex); |
---|
2940 | } |
---|
2941 | |
---|
2942 | { |
---|
2943 | menuLoadTextures = new fltk::ItemGroup("Load Textures"); |
---|
2944 | o->add(menuLoadTextures); |
---|
2945 | } |
---|
2946 | |
---|
2947 | { |
---|
2948 | fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); |
---|
2949 | o->callback((fltk::Callback*)cb_menuFileQuit); |
---|
2950 | } |
---|
2951 | |
---|
2952 | o->end(); |
---|
2953 | } |
---|
2954 | |
---|
2955 | // Menu Edit. |
---|
2956 | { |
---|
2957 | fltk::ItemGroup* o = menuEdit = new fltk::ItemGroup("Edit"); |
---|
2958 | o->begin(); |
---|
2959 | |
---|
2960 | { |
---|
2961 | fltk::Item* o = menuEditUndo = new fltk::Item("Undo"); |
---|
2962 | o->callback((fltk::Callback*)cb_menuEditUndo); |
---|
2963 | } |
---|
2964 | |
---|
2965 | { |
---|
2966 | fltk::Item* o = menuEditFit = new fltk::Item("Fit"); |
---|
2967 | o->callback((fltk::Callback*)cb_menuEditFit); |
---|
2968 | } |
---|
2969 | |
---|
2970 | { |
---|
2971 | fltk::Item* o = menuEditRotate = new fltk::Item("Rotate"); |
---|
2972 | o->type(fltk::Item::RADIO); |
---|
2973 | o->set_value(); |
---|
2974 | o->callback((fltk::Callback*)cb_menuEditRotate); |
---|
2975 | } |
---|
2976 | |
---|
2977 | { |
---|
2978 | fltk::Item* o = menuEditPan = new fltk::Item("Pan"); |
---|
2979 | o->type(fltk::Item::RADIO); |
---|
2980 | o->callback((fltk::Callback*)cb_menuEditPan); |
---|
2981 | } |
---|
2982 | |
---|
2983 | new fltk::Divider(); |
---|
2984 | |
---|
2985 | { |
---|
2986 | fltk::Item* o = menuMeshInfo = new fltk::Item("Mesh info"); |
---|
2987 | o->callback((fltk::Callback*)cb_menuMeshInfo); |
---|
2988 | } |
---|
2989 | |
---|
2990 | { |
---|
2991 | fltk::Item* o; |
---|
2992 | o = menuSelectLeaves = new fltk::Item("Select leaves"); |
---|
2993 | o->callback((fltk::Callback*)cb_menuSelectLeaves); |
---|
2994 | } |
---|
2995 | o->end(); |
---|
2996 | } |
---|
2997 | |
---|
2998 | // Menu Render. |
---|
2999 | { |
---|
3000 | fltk::ItemGroup* o = menuRender = new fltk::ItemGroup("Render"); |
---|
3001 | o->begin(); |
---|
3002 | |
---|
3003 | { |
---|
3004 | fltk::Item* o = menuRenderWire = new fltk::Item("Wire"); |
---|
3005 | o->type(fltk::Item::RADIO); |
---|
3006 | o->callback((fltk::Callback*)cb_menuRenderWire); |
---|
3007 | } |
---|
3008 | |
---|
3009 | { |
---|
3010 | fltk::Item* o = menuRenderSolid = new fltk::Item("Solid"); |
---|
3011 | o->type(fltk::Item::RADIO); |
---|
3012 | o->callback((fltk::Callback*)cb_menuRenderSolid); |
---|
3013 | } |
---|
3014 | |
---|
3015 | { |
---|
3016 | fltk::Item* o = menuRenderLighting = new fltk::Item("Lighting"); |
---|
3017 | o->type(fltk::Item::RADIO); |
---|
3018 | o->callback((fltk::Callback*)cb_menuRenderLighting); |
---|
3019 | } |
---|
3020 | |
---|
3021 | { |
---|
3022 | fltk::Item* o = menuRenderCW = new fltk::Item("CW"); |
---|
3023 | o->type(fltk::Item::RADIO); |
---|
3024 | o->callback((fltk::Callback*)cb_menuRenderCW); |
---|
3025 | } |
---|
3026 | |
---|
3027 | { |
---|
3028 | fltk::Item* o = menuRenderCCW = new fltk::Item("CCW"); |
---|
3029 | o->type(fltk::Item::RADIO); |
---|
3030 | o->set_value(); |
---|
3031 | o->callback((fltk::Callback*)cb_menuRenderCCW); |
---|
3032 | } |
---|
3033 | |
---|
3034 | new fltk::Divider(); |
---|
3035 | |
---|
3036 | { |
---|
3037 | fltk::Item* o = menuRenderFlat = new fltk::Item("Flat"); |
---|
3038 | o->type(fltk::Item::RADIO); |
---|
3039 | o->clear_value(); |
---|
3040 | o->callback((fltk::Callback*)cb_menuRenderFlat); |
---|
3041 | } |
---|
3042 | |
---|
3043 | { |
---|
3044 | fltk::Item* o = menuRenderSmooth = new fltk::Item("Smooth"); |
---|
3045 | o->type(fltk::Item::RADIO); |
---|
3046 | o->set_value(); |
---|
3047 | o->callback((fltk::Callback*)cb_menuRenderSmooth); |
---|
3048 | } |
---|
3049 | |
---|
3050 | new fltk::Divider(); |
---|
3051 | |
---|
3052 | { |
---|
3053 | fltk::Item* o = new fltk::Item("Texture mapping"); |
---|
3054 | o->type(fltk::Item::RADIO); |
---|
3055 | o->set_value(); |
---|
3056 | o->callback((fltk::Callback*)cb_menuRenderTextures); |
---|
3057 | } |
---|
3058 | |
---|
3059 | new fltk::Divider(); |
---|
3060 | |
---|
3061 | { |
---|
3062 | fltk::Item* o = new fltk::Item("Axis"); |
---|
3063 | o->type(fltk::Item::RADIO); |
---|
3064 | o->set_value(); |
---|
3065 | o->callback((fltk::Callback*)cb_menuRenderAxes); |
---|
3066 | } |
---|
3067 | |
---|
3068 | { |
---|
3069 | fltk::Item* o = new fltk::Item("Bounding Box"); |
---|
3070 | o->type(fltk::Item::RADIO); |
---|
3071 | o->set_value(); |
---|
3072 | o->callback((fltk::Callback*)cb_menuRenderBoundingBox); |
---|
3073 | } |
---|
3074 | |
---|
3075 | o->end(); |
---|
3076 | } |
---|
3077 | |
---|
3078 | // Menu Stripify. |
---|
3079 | { |
---|
3080 | fltk::Item* o = menuStripify = new fltk::Item("Stripify"); |
---|
3081 | o->callback((fltk::Callback*)cb_menuStripify); |
---|
3082 | } |
---|
3083 | |
---|
3084 | // Menu Simplify. |
---|
3085 | { |
---|
3086 | fltk::ItemGroup* o = menuSimplify = new fltk::ItemGroup("Simplify"); |
---|
3087 | o->callback((fltk::Callback*)cb_menuSimplify); |
---|
3088 | o->begin(); |
---|
3089 | |
---|
3090 | { |
---|
3091 | fltk::Item* o; |
---|
3092 | o = menuSimplifyEdgeCollapse = new fltk::Item("Mesh Simplification"); |
---|
3093 | o->callback((fltk::Callback*)cb_menuSimplifyEdgeCollapse); |
---|
3094 | } |
---|
3095 | |
---|
3096 | { |
---|
3097 | fltk::Item* o; |
---|
3098 | o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification"); |
---|
3099 | o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse); |
---|
3100 | } |
---|
3101 | |
---|
3102 | o->end(); |
---|
3103 | } |
---|
3104 | |
---|
3105 | // Menu LodStrips. |
---|
3106 | { |
---|
3107 | fltk::ItemGroup* o; |
---|
3108 | o = menuLodStrips = new fltk::ItemGroup("LodStrips"); |
---|
3109 | o->begin(); |
---|
3110 | |
---|
3111 | { |
---|
3112 | fltk::Item* o; |
---|
3113 | o = menuLodStripsGenerate = new fltk::Item("Generate"); |
---|
3114 | o->callback((fltk::Callback*)cb_menuLodStripsGenerate); |
---|
3115 | } |
---|
3116 | |
---|
3117 | { |
---|
3118 | fltk::Item* o; |
---|
3119 | o = menuLodStripsVisualize = new fltk::Item("Visualize"); |
---|
3120 | o->callback((fltk::Callback*)cb_menuLodStripsVisualize); |
---|
3121 | } |
---|
3122 | |
---|
3123 | o->end(); |
---|
3124 | } |
---|
3125 | |
---|
3126 | // Menu LodTrees. |
---|
3127 | { |
---|
3128 | fltk::ItemGroup* o; |
---|
3129 | o = menuLodTrees = new fltk::ItemGroup("LodTrees"); |
---|
3130 | o->begin(); |
---|
3131 | |
---|
3132 | { |
---|
3133 | fltk::Item* o; |
---|
3134 | o = menuLodTreesGenerate = new fltk::Item("Generate"); |
---|
3135 | o->callback((fltk::Callback*)cb_menuLodTreesGenerate); |
---|
3136 | } |
---|
3137 | { |
---|
3138 | fltk::Item* o; |
---|
3139 | o = menuLodTreesVisualize = new fltk::Item("Visualize"); |
---|
3140 | o->callback((fltk::Callback*)cb_menuLodTreesVisualize); |
---|
3141 | } |
---|
3142 | |
---|
3143 | o->end(); |
---|
3144 | } |
---|
3145 | |
---|
3146 | |
---|
3147 | { |
---|
3148 | fltk::ItemGroup* o = new fltk::ItemGroup("?"); |
---|
3149 | o->begin(); |
---|
3150 | |
---|
3151 | { |
---|
3152 | fltk::Item* o = menuHelpAbout = new fltk::Item("About"); |
---|
3153 | o->callback((fltk::Callback*)cb_menuHelpAbout); |
---|
3154 | } |
---|
3155 | |
---|
3156 | o->end(); |
---|
3157 | } |
---|
3158 | |
---|
3159 | o->end(); |
---|
3160 | } |
---|
3161 | |
---|
3162 | { |
---|
3163 | fltk::Group* o; |
---|
3164 | o = ApplicationBar = new fltk::Group(0, 570, 807, 28); |
---|
3165 | o->box(fltk::BORDER_BOX); |
---|
3166 | o->begin(); |
---|
3167 | |
---|
3168 | { |
---|
3169 | fltk::Widget* o; |
---|
3170 | o = mVertices = new fltk::Widget(154, 4, 40, 15, "Vertices"); |
---|
3171 | o->box(fltk::NO_BOX); |
---|
3172 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3173 | o->color((fltk::Color)0xe0dfe300); |
---|
3174 | } |
---|
3175 | |
---|
3176 | { |
---|
3177 | fltk::Widget* o; |
---|
3178 | o = mTriangles = new fltk::Widget(254, 3, 40, 15, "Triangles"); |
---|
3179 | o->box(fltk::NO_BOX); |
---|
3180 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3181 | o->color((fltk::Color)0xe0dfe300); |
---|
3182 | } |
---|
3183 | |
---|
3184 | { |
---|
3185 | fltk::Widget* o; |
---|
3186 | o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); |
---|
3187 | o->box(fltk::NO_BOX); |
---|
3188 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3189 | o->color((fltk::Color)0xe0dfe300); |
---|
3190 | } |
---|
3191 | |
---|
3192 | { |
---|
3193 | fltk::Widget* o; |
---|
3194 | o = mMB = new fltk::Widget(740, 3, 30, 15, "MB"); |
---|
3195 | o->box(fltk::NO_BOX); |
---|
3196 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3197 | o->color((fltk::Color)0xe0dfe300); |
---|
3198 | } |
---|
3199 | o->end(); |
---|
3200 | } |
---|
3201 | o->end(); |
---|
3202 | } |
---|
3203 | |
---|
3204 | fltk::focus(geoMeshView); |
---|
3205 | |
---|
3206 | /*Hide Right Panel*/ |
---|
3207 | hideRightPanel(); |
---|
3208 | |
---|
3209 | mMainWindow->show(); |
---|
3210 | } |
---|
3211 | |
---|
3212 | //------------------------------------------------------------------------- |
---|
3213 | // Destructor. |
---|
3214 | //------------------------------------------------------------------------- |
---|
3215 | GeoMeshViewUI::~GeoMeshViewUI() |
---|
3216 | { |
---|
3217 | //delete geoMeshLoader; |
---|
3218 | mMainWindow->destroy(); |
---|
3219 | } |
---|
3220 | |
---|
3221 | //------------------------------------------------------------------------- |
---|
3222 | // Shows the main window. |
---|
3223 | //------------------------------------------------------------------------- |
---|
3224 | void GeoMeshViewUI::show() |
---|
3225 | { |
---|
3226 | } |
---|
3227 | |
---|
3228 | //------------------------------------------------------------------------- |
---|
3229 | // Build Textures menu. |
---|
3230 | //------------------------------------------------------------------------- |
---|
3231 | void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void) |
---|
3232 | { |
---|
3233 | if (SubMeshNames) |
---|
3234 | { |
---|
3235 | menuLoadTextures->clear(); |
---|
3236 | |
---|
3237 | for (int i = 0; i < numSubMeshNames; i++) |
---|
3238 | { |
---|
3239 | delete[] SubMeshNames[i]; |
---|
3240 | } |
---|
3241 | delete[] SubMeshNames; |
---|
3242 | } |
---|
3243 | |
---|
3244 | menuFileLoadTexture = new fltk::Item("Entire model"); |
---|
3245 | |
---|
3246 | menuFileLoadTexture->callback((fltk::Callback*)cb_menuFileLoadTexture); |
---|
3247 | menuLoadTextures->add(menuFileLoadTexture); |
---|
3248 | |
---|
3249 | numSubMeshNames = geoMeshView->getSubMeshCount(); |
---|
3250 | SubMeshNames = new char*[numSubMeshNames]; |
---|
3251 | |
---|
3252 | for (int i = 0; i < numSubMeshNames; i++) |
---|
3253 | { |
---|
3254 | SubMeshNames[i] = new char[10]; |
---|
3255 | |
---|
3256 | sprintf(SubMeshNames[i],"submesh %d",i); |
---|
3257 | |
---|
3258 | fltk::Item *item = new fltk::Item(SubMeshNames[i]); |
---|
3259 | |
---|
3260 | item->callback((fltk::Callback*)cb_menuFileLoadTextureSubMesh); |
---|
3261 | menuLoadTextures->add(item); |
---|
3262 | } |
---|
3263 | } |
---|
3264 | |
---|