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