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 | fltk::FileChooser *fcho; |
---|
798 | const char *lod_file; |
---|
799 | |
---|
800 | // Sets menus application state to NONE. |
---|
801 | mApplicationState = NONE; |
---|
802 | |
---|
803 | // Deactive Lod strip visualization. |
---|
804 | geoMeshView->deactiveLodStrip(); |
---|
805 | geoMeshView->deactiveLodTree(); |
---|
806 | |
---|
807 | // Loads a mesh file. |
---|
808 | openMeshFile(); |
---|
809 | |
---|
810 | // If an object is loaded. |
---|
811 | if (mGeoMesh != NULL) |
---|
812 | { |
---|
813 | fcho = new fltk::FileChooser("", |
---|
814 | "*.lod", |
---|
815 | fltk::FileChooser::CREATE, |
---|
816 | "Open Lod file"); |
---|
817 | |
---|
818 | fcho->exec(); |
---|
819 | |
---|
820 | // If a file was selected. |
---|
821 | if (fcho->value()) |
---|
822 | { |
---|
823 | // Build lod strips library. |
---|
824 | setLodStripsLibrary(string(fcho->value()), mGeoMesh); |
---|
825 | |
---|
826 | // Sets the aplication mode. |
---|
827 | mApplicationState = VISUALIZE_LODSTRIPS; |
---|
828 | } |
---|
829 | |
---|
830 | // Free memory. |
---|
831 | delete fcho; |
---|
832 | |
---|
833 | // Hide the right panel. |
---|
834 | hideRightPanel(); |
---|
835 | |
---|
836 | // Show title. |
---|
837 | mProcessTitle->label("Visualize LodStrips"); |
---|
838 | |
---|
839 | // Show the Visulize LodStrips panel. |
---|
840 | showLodStripSlider(); |
---|
841 | |
---|
842 | // Repaint the window. |
---|
843 | mMainWindow->redraw(); |
---|
844 | |
---|
845 | } |
---|
846 | } |
---|
847 | |
---|
848 | inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) |
---|
849 | { |
---|
850 | fltk::FileChooser *fcho; |
---|
851 | const char *lod_file; |
---|
852 | |
---|
853 | // Sets menus application state to NONE. |
---|
854 | mApplicationState = NONE; |
---|
855 | |
---|
856 | // Deactive Lod strip visualization. |
---|
857 | geoMeshView->deactiveLodTree(); |
---|
858 | geoMeshView->deactiveLodStrip(); |
---|
859 | |
---|
860 | // Loads a mesh file. |
---|
861 | openMeshFile(); |
---|
862 | |
---|
863 | /*if (geoMeshView->getLeavesSubmesh()==-1) |
---|
864 | { |
---|
865 | fltk::alert("No se ha seleccionado el submesh de hojas!"); |
---|
866 | return; |
---|
867 | }*/ |
---|
868 | |
---|
869 | // If an object is loaded. |
---|
870 | if (mGeoMesh != NULL) |
---|
871 | { |
---|
872 | // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS |
---|
873 | int leafsSubMeshID = -1; |
---|
874 | |
---|
875 | for (int i=0; i<mGeoMesh->mSubMeshCount; i++) |
---|
876 | { |
---|
877 | if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) |
---|
878 | { |
---|
879 | leafsSubMeshID=i; |
---|
880 | break; |
---|
881 | } |
---|
882 | } |
---|
883 | |
---|
884 | // If an object is loaded. |
---|
885 | if (mGeoMesh != NULL) |
---|
886 | { |
---|
887 | fcho = new fltk::FileChooser("", |
---|
888 | "*.lod", |
---|
889 | fltk::FileChooser::CREATE, |
---|
890 | "Open Lod file"); |
---|
891 | |
---|
892 | fcho->exec(); |
---|
893 | |
---|
894 | // If a file was selected. |
---|
895 | if (fcho->value()) |
---|
896 | { |
---|
897 | // Build lod strips library. |
---|
898 | |
---|
899 | std::string lodstripFile(fcho->value()); |
---|
900 | delete fcho; |
---|
901 | fcho = new fltk::FileChooser("", |
---|
902 | "*.leafseq", |
---|
903 | fltk::FileChooser::CREATE, |
---|
904 | "Open LeafSeq file"); |
---|
905 | |
---|
906 | fcho->exec(); |
---|
907 | |
---|
908 | if (fcho->value()) |
---|
909 | { |
---|
910 | std::string leafseqFile(fcho->value()); |
---|
911 | |
---|
912 | setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); |
---|
913 | |
---|
914 | // Sets the aplication mode. |
---|
915 | mApplicationState = VISUALIZE_LODTREES; |
---|
916 | } |
---|
917 | } |
---|
918 | |
---|
919 | // Free memory. |
---|
920 | delete fcho; |
---|
921 | |
---|
922 | // Hide the right panel. |
---|
923 | hideRightPanel(); |
---|
924 | |
---|
925 | // Show title. |
---|
926 | mProcessTitle->label("Visualize LodTrees"); |
---|
927 | |
---|
928 | // Show the Visulize LodTree panel. |
---|
929 | showLodStripSlider(); |
---|
930 | showLodTreeSlider(); |
---|
931 | |
---|
932 | // Repaint the window. |
---|
933 | mMainWindow->redraw(); |
---|
934 | } |
---|
935 | } |
---|
936 | } |
---|
937 | |
---|
938 | void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) |
---|
939 | { |
---|
940 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
941 | -> |
---|
942 | cb_menuLodTreesVisualize_i(o,v); |
---|
943 | } |
---|
944 | |
---|
945 | void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) |
---|
946 | { |
---|
947 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
948 | -> |
---|
949 | cb_menuLodStripsVisualize_i(o,v); |
---|
950 | } |
---|
951 | |
---|
952 | //--------------------------------------------------------------------------- |
---|
953 | // Open LodStrip trunk Callback |
---|
954 | //--------------------------------------------------------------------------- |
---|
955 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) |
---|
956 | { |
---|
957 | } |
---|
958 | |
---|
959 | void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) |
---|
960 | { |
---|
961 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
962 | -> |
---|
963 | cb_menuLodTreesOpenLodStripTrunk_i(o,v); |
---|
964 | } |
---|
965 | |
---|
966 | //--------------------------------------------------------------------------- |
---|
967 | // Open leaves simplification Callback |
---|
968 | //--------------------------------------------------------------------------- |
---|
969 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) |
---|
970 | { |
---|
971 | // Hide the right panel. |
---|
972 | hideRightPanel(); |
---|
973 | |
---|
974 | // Show the LodTrees panel. |
---|
975 | showOpenLeavesSimplification(); |
---|
976 | |
---|
977 | // Sets menus application state to LODTREES. |
---|
978 | mApplicationState = LODTREES; |
---|
979 | |
---|
980 | // Repaint the window. |
---|
981 | mMainWindow->redraw(); |
---|
982 | } |
---|
983 | |
---|
984 | void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification(fltk::Item* o, void* v) |
---|
985 | { |
---|
986 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
987 | -> |
---|
988 | cb_menuLodTreesOpenLeavesSimplification_i(o,v); |
---|
989 | } |
---|
990 | |
---|
991 | |
---|
992 | |
---|
993 | //--------------------------------------------------------------------------- |
---|
994 | // About Callback |
---|
995 | //--------------------------------------------------------------------------- |
---|
996 | inline void GeoMeshViewUI::cb_menuHelpAbout_i(fltk::Item*, void*) |
---|
997 | { |
---|
998 | new GTAboutDialog(); |
---|
999 | } |
---|
1000 | |
---|
1001 | void GeoMeshViewUI::cb_menuHelpAbout(fltk::Item* o, void* v) |
---|
1002 | { |
---|
1003 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1004 | -> |
---|
1005 | cb_menuHelpAbout_i(o,v); |
---|
1006 | } |
---|
1007 | |
---|
1008 | VertexBuffer *origSubMeshVB=NULL; |
---|
1009 | int orig_numindices=0; |
---|
1010 | Index *orig_indices=NULL; |
---|
1011 | |
---|
1012 | //--------------------------------------------------------------------------- |
---|
1013 | // Button Process Callback |
---|
1014 | //--------------------------------------------------------------------------- |
---|
1015 | inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) |
---|
1016 | { |
---|
1017 | bool error; |
---|
1018 | Mesh *mesh_aux; |
---|
1019 | |
---|
1020 | // Sets the progress bar to process bar. |
---|
1021 | progressBarType = PROCESS; |
---|
1022 | mProcessBar->position(0); |
---|
1023 | |
---|
1024 | origSubMeshVB=NULL; |
---|
1025 | |
---|
1026 | // Initialize error flag. |
---|
1027 | error = false; |
---|
1028 | |
---|
1029 | // If there is a mesh object. |
---|
1030 | if (mGeoMesh != NULL) |
---|
1031 | { |
---|
1032 | // Choose between aplication state. |
---|
1033 | switch(mApplicationState) |
---|
1034 | { |
---|
1035 | // Stripify state. |
---|
1036 | case STRIPIFY: |
---|
1037 | |
---|
1038 | // Stripify the mesh object. |
---|
1039 | stripify(); |
---|
1040 | |
---|
1041 | break; |
---|
1042 | |
---|
1043 | // Simplify edge collapse state. |
---|
1044 | case EDGE_COLLAPSE: |
---|
1045 | |
---|
1046 | // Check submeshes for triangles strips. |
---|
1047 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
1048 | { |
---|
1049 | // If current submesh is in triangle strips. |
---|
1050 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
1051 | { |
---|
1052 | error = true; |
---|
1053 | } |
---|
1054 | } |
---|
1055 | |
---|
1056 | // if the mesh is stripified. |
---|
1057 | if (error) |
---|
1058 | { |
---|
1059 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
1060 | } |
---|
1061 | else |
---|
1062 | { |
---|
1063 | // Simplify the mesh object. |
---|
1064 | if(simplifyEdgeCollapse()) |
---|
1065 | { |
---|
1066 | delete mMeshSimplifier; |
---|
1067 | geoMeshView->restoreContext(); |
---|
1068 | } |
---|
1069 | } |
---|
1070 | break; |
---|
1071 | |
---|
1072 | // Simplify leaves |
---|
1073 | case LEAVES_COLLAPSE: |
---|
1074 | |
---|
1075 | // Simplify the mesh object. |
---|
1076 | simplifyLeavesCollapse(); |
---|
1077 | |
---|
1078 | // Create the leaves simplification sequence. |
---|
1079 | createLeavesSequence("leavesSimplification.txt"); |
---|
1080 | |
---|
1081 | break; |
---|
1082 | |
---|
1083 | // Simplify and generate simplification sequence. |
---|
1084 | case LODTREES_AUTO: |
---|
1085 | if (idMeshLeaves==(unsigned short)-1) |
---|
1086 | { |
---|
1087 | fltk::alert("Leaves submesh not selected!"); |
---|
1088 | } |
---|
1089 | else |
---|
1090 | { |
---|
1091 | origSubMeshVB=mGeoMesh->mSubMesh[idMeshLeaves].mVertexBuffer->Clone(); |
---|
1092 | orig_numindices=mGeoMesh->mSubMesh[idMeshLeaves].mIndexCount; |
---|
1093 | orig_indices=new Index[orig_numindices];
|
---|
1094 | for (int i=0; i<orig_numindices; i++)
|
---|
1095 | orig_indices[i]=mGeoMesh->mSubMesh[idMeshLeaves].mIndex[i]; |
---|
1096 | |
---|
1097 | std::cout << "Simplificando hojas..."; |
---|
1098 | simplifyLeavesCollapse(); |
---|
1099 | std::cout << "OK!" << std::endl; |
---|
1100 | |
---|
1101 | // std::cout << "Creando secuencia de simplificacion de hojas..."; |
---|
1102 | // createLeavesSequence("leavesSimplification.txt"); |
---|
1103 | // std::cout << "OK!" << std::endl; |
---|
1104 | |
---|
1105 | undo(); |
---|
1106 | |
---|
1107 | |
---|
1108 | std::cout << "Simplificando tronco..."; |
---|
1109 | std::cout << "OK!" << std::endl; |
---|
1110 | |
---|
1111 | // Transform NoSV Mesh to a SV Mesh. |
---|
1112 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
1113 | |
---|
1114 | // Deletes the mesh No Shared Vertex. |
---|
1115 | delete mGeoMesh; |
---|
1116 | |
---|
1117 | // Gets the mesh Shared Vertex. |
---|
1118 | mGeoMesh = mesh_aux; |
---|
1119 | |
---|
1120 | geoMeshView->setMesh(mGeoMesh); |
---|
1121 | |
---|
1122 | // Simplify the mesh object. |
---|
1123 | if (simplifyEdgeCollapse()) |
---|
1124 | { |
---|
1125 | // Create the simplification sequence. |
---|
1126 | createSimplificationSequence(); |
---|
1127 | |
---|
1128 | // Show build process. |
---|
1129 | activeBuildProcess(); |
---|
1130 | } |
---|
1131 | |
---|
1132 | } |
---|
1133 | |
---|
1134 | break; |
---|
1135 | |
---|
1136 | case LODSTRIPS_AUTO: |
---|
1137 | |
---|
1138 | // Check submeshes for triangles strips. |
---|
1139 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
1140 | { |
---|
1141 | // If current submesh is in triangle strips. |
---|
1142 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
1143 | { |
---|
1144 | error = true; |
---|
1145 | } |
---|
1146 | } |
---|
1147 | |
---|
1148 | // if the mesh is stripified. |
---|
1149 | if (error) |
---|
1150 | { |
---|
1151 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
1152 | } |
---|
1153 | else |
---|
1154 | { |
---|
1155 | // Transform NoSV Mesh to a SV Mesh. |
---|
1156 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
1157 | |
---|
1158 | // Deletes the mesh No Shared Vertex. |
---|
1159 | delete mGeoMesh; |
---|
1160 | |
---|
1161 | // Gets the mesh Shared Vertex. |
---|
1162 | mGeoMesh = mesh_aux; |
---|
1163 | |
---|
1164 | // Visualize mesh. |
---|
1165 | geoMeshView->setMesh(mGeoMesh); |
---|
1166 | |
---|
1167 | // Simplify the mesh object. |
---|
1168 | if (simplifyEdgeCollapse()) |
---|
1169 | { |
---|
1170 | // Create the simplification sequence. |
---|
1171 | createSimplificationSequence(); |
---|
1172 | |
---|
1173 | delete mMeshSimplifier; |
---|
1174 | geoMeshView->restoreContext(); |
---|
1175 | |
---|
1176 | // Show build process. |
---|
1177 | activeBuildProcess(); |
---|
1178 | } |
---|
1179 | } |
---|
1180 | |
---|
1181 | break; |
---|
1182 | |
---|
1183 | // Añadido 23-12-2005 |
---|
1184 | case SELECT_LEAVES: |
---|
1185 | |
---|
1186 | idMeshLeaves = paintMesh(); |
---|
1187 | |
---|
1188 | // Set the leaves submesh. |
---|
1189 | geoMeshView->setLeavesSubMesh(idMeshLeaves); |
---|
1190 | |
---|
1191 | // Refresh mesh info. |
---|
1192 | showMeshInfo(); |
---|
1193 | |
---|
1194 | break; |
---|
1195 | } |
---|
1196 | |
---|
1197 | // Refresh geometry attributes. |
---|
1198 | refreshApplicationBar(); |
---|
1199 | } |
---|
1200 | |
---|
1201 | // Repaint the GL Window. |
---|
1202 | mMainWindow->redraw(); |
---|
1203 | } |
---|
1204 | |
---|
1205 | void GeoMeshViewUI::cb_mButtonProcess(fltk::Button* o, void* v) |
---|
1206 | { |
---|
1207 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1208 | -> |
---|
1209 | cb_mButtonProcess_i(o,v); |
---|
1210 | } |
---|
1211 | |
---|
1212 | //--------------------------------------------------------------------------- |
---|
1213 | // Button Sort Callback |
---|
1214 | //--------------------------------------------------------------------------- |
---|
1215 | inline void GeoMeshViewUI::cb_mButtonSort_i(fltk::Button*, void*) |
---|
1216 | { |
---|
1217 | } |
---|
1218 | |
---|
1219 | void GeoMeshViewUI::cb_mButtonSort(fltk::Button* o, void* v) |
---|
1220 | { |
---|
1221 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1222 | -> |
---|
1223 | cb_mButtonSort_i(o,v); |
---|
1224 | } |
---|
1225 | |
---|
1226 | //--------------------------------------------------------------------------- |
---|
1227 | // Button Build Callback |
---|
1228 | //--------------------------------------------------------------------------- |
---|
1229 | inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) |
---|
1230 | { |
---|
1231 | char *file_name = NULL; |
---|
1232 | GeoMeshSaver *mesh_saver; |
---|
1233 | Serializer *oSerializer; |
---|
1234 | |
---|
1235 | // Sets the progress bar to process bar. |
---|
1236 | progressBarType = BUILD; |
---|
1237 | |
---|
1238 | // Reset the build bar. |
---|
1239 | mBuildBar->position(0); |
---|
1240 | |
---|
1241 | // If there is a mesh object. |
---|
1242 | if (mGeoMesh != NULL) |
---|
1243 | { |
---|
1244 | // Choose between aplication state. |
---|
1245 | switch(mApplicationState) |
---|
1246 | { |
---|
1247 | // Build the LOD file. |
---|
1248 | case LODTREES_AUTO: |
---|
1249 | |
---|
1250 | // Open file chooser dialog. |
---|
1251 | file_name = fltk::file_chooser("Build LOD","*",""); |
---|
1252 | |
---|
1253 | if (!file_name) |
---|
1254 | { |
---|
1255 | break; |
---|
1256 | } |
---|
1257 | |
---|
1258 | std::cout << "Creando secuencia de simplificacion de hojas..."; |
---|
1259 | |
---|
1260 | createLeavesSequence(file_name+std::string(".leafseq")); |
---|
1261 | |
---|
1262 | std::cout << "OK!" << std::endl; |
---|
1263 | |
---|
1264 | /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); |
---|
1265 | auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); |
---|
1266 | |
---|
1267 | if (auxTreeSimpSequence && mGeoMesh) |
---|
1268 | { |
---|
1269 | LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); |
---|
1270 | delete auxLodTreeConstructor; |
---|
1271 | } |
---|
1272 | else |
---|
1273 | { |
---|
1274 | fltk::alert("There is no leaf simplification sequence."); |
---|
1275 | break; |
---|
1276 | } |
---|
1277 | |
---|
1278 | |
---|
1279 | delete auxTreeSimpSequence;*/ |
---|
1280 | |
---|
1281 | case LODSTRIPS_AUTO: |
---|
1282 | |
---|
1283 | // Builder |
---|
1284 | if (!file_name) |
---|
1285 | { |
---|
1286 | file_name = fltk::file_chooser("Build LOD","*",""); |
---|
1287 | } |
---|
1288 | |
---|
1289 | // If a file was selected. |
---|
1290 | if (file_name) |
---|
1291 | { |
---|
1292 | // Undo the simplification changes. |
---|
1293 | undo(); |
---|
1294 | |
---|
1295 | // Stripify the mesh object. |
---|
1296 | stripify(); |
---|
1297 | |
---|
1298 | // Reset the build bar. |
---|
1299 | mBuildBar->position(0); |
---|
1300 | |
---|
1301 | // Simplification sequence. |
---|
1302 | oMeshSimpSequence = new MeshSimplificationSequence(); |
---|
1303 | |
---|
1304 | // Loads a simplification sequence file. |
---|
1305 | oMeshSimpSequence->Load(Serializer( "SimplifSequence.txt", |
---|
1306 | Serializer::READ)); |
---|
1307 | |
---|
1308 | // If the simplification sequence and the mesh exist. |
---|
1309 | if (oMeshSimpSequence && mGeoMesh) |
---|
1310 | { |
---|
1311 | oLodStrip = new LodStripsConstructor( mGeoMesh, |
---|
1312 | oMeshSimpSequence, |
---|
1313 | idMeshLeaves, |
---|
1314 | progress_function); |
---|
1315 | |
---|
1316 | oSerializer = new Serializer( strcat(file_name,".lod"), |
---|
1317 | Serializer::Mode::WRITE); |
---|
1318 | |
---|
1319 | oLodStrip->Save(*oSerializer); |
---|
1320 | |
---|
1321 | // Close file. |
---|
1322 | delete oSerializer; |
---|
1323 | |
---|
1324 | // Deletes the previous mesh. |
---|
1325 | delete mUndoMesh; |
---|
1326 | |
---|
1327 | mUndoMesh = new Mesh(); |
---|
1328 | |
---|
1329 | // Sets the undo mesh. |
---|
1330 | *mUndoMesh = *mGeoMesh; |
---|
1331 | |
---|
1332 | delete mGeoMesh; |
---|
1333 | |
---|
1334 | mGeoMesh = oLodStrip->GetMesh(); |
---|
1335 | |
---|
1336 | geoMeshView->setMesh(mGeoMesh); |
---|
1337 | |
---|
1338 | mesh_saver = new GeoMeshSaver(); |
---|
1339 | file_name[strlen(file_name) - 4] = '\0'; |
---|
1340 | |
---|
1341 | mesh_saver->leavesSubMesh=idMeshLeaves; |
---|
1342 | mesh_saver->leavesVB=origSubMeshVB; |
---|
1343 | mesh_saver->numindices=orig_numindices; |
---|
1344 | mesh_saver->indices=orig_indices; |
---|
1345 | mesh_saver->save(mGeoMesh,strcat(file_name,".mesh")); |
---|
1346 | |
---|
1347 | delete mesh_saver; |
---|
1348 | } |
---|
1349 | else |
---|
1350 | { |
---|
1351 | // Error message. |
---|
1352 | fltk::alert("There is no simplification sequence."); |
---|
1353 | } |
---|
1354 | |
---|
1355 | // Deletes the siplification sequence object. |
---|
1356 | delete oMeshSimpSequence; |
---|
1357 | } |
---|
1358 | break; |
---|
1359 | } |
---|
1360 | // Refresh data aplication. |
---|
1361 | refreshApplicationBar(); |
---|
1362 | } |
---|
1363 | } |
---|
1364 | |
---|
1365 | void GeoMeshViewUI::cb_mButtonBuild(fltk::Button *o, void *v) |
---|
1366 | { |
---|
1367 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1368 | -> |
---|
1369 | cb_mButtonBuild_i(o,v); |
---|
1370 | } |
---|
1371 | |
---|
1372 | //--------------------------------------------------------------------------- |
---|
1373 | // Lod Slider Callback |
---|
1374 | //--------------------------------------------------------------------------- |
---|
1375 | inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider *o, void *) |
---|
1376 | { |
---|
1377 | // Change the lod. |
---|
1378 | geoMeshView->GoToLod_LodStrip((float)o->value()); |
---|
1379 | |
---|
1380 | // Refresh data aplication. |
---|
1381 | refreshApplicationBar(); |
---|
1382 | |
---|
1383 | mMainWindow->flush(); |
---|
1384 | } |
---|
1385 | |
---|
1386 | void GeoMeshViewUI::cb_mLodStripSlider(fltk::Slider *o, void *v) |
---|
1387 | { |
---|
1388 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1389 | -> |
---|
1390 | cb_mLodStripSlider_i(o,v); |
---|
1391 | } |
---|
1392 | |
---|
1393 | //--------------------------------------------------------------------------- |
---|
1394 | // Lod Slider Callback for the foliage |
---|
1395 | //--------------------------------------------------------------------------- |
---|
1396 | inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider *o, void *) |
---|
1397 | { |
---|
1398 | // Change the lod. |
---|
1399 | geoMeshView->GoToLod_LodTree((float)o->value()); |
---|
1400 | |
---|
1401 | // Refresh data aplication. |
---|
1402 | refreshApplicationBar(); |
---|
1403 | |
---|
1404 | mMainWindow->flush(); |
---|
1405 | } |
---|
1406 | |
---|
1407 | void GeoMeshViewUI::cb_mLodTreeSlider(fltk::Slider *o, void *v) |
---|
1408 | { |
---|
1409 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1410 | -> |
---|
1411 | cb_mLodTreeSlider_i(o,v); |
---|
1412 | } |
---|
1413 | |
---|
1414 | //--------------------------------------------------------------------------- |
---|
1415 | // Mesh Info Callback |
---|
1416 | //--------------------------------------------------------------------------- |
---|
1417 | inline void GeoMeshViewUI::cb_mMeshInfo_i(fltk::Browser *, void *) |
---|
1418 | { |
---|
1419 | paintMesh(); |
---|
1420 | } |
---|
1421 | |
---|
1422 | void GeoMeshViewUI::cb_mMeshInfo(fltk::Browser* o, void* v) |
---|
1423 | { |
---|
1424 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
1425 | -> |
---|
1426 | cb_mMeshInfo_i(o,v); |
---|
1427 | } |
---|
1428 | |
---|
1429 | //--------------------------------------------------------------------------- |
---|
1430 | // Logo Callback. |
---|
1431 | //--------------------------------------------------------------------------- |
---|
1432 | inline void GeoMeshViewUI::cb_mLogo_i(fltk::InvisibleBox*, void*) |
---|
1433 | { |
---|
1434 | } |
---|
1435 | |
---|
1436 | void GeoMeshViewUI::cb_mLogo(fltk::InvisibleBox* o, void* v) |
---|
1437 | { |
---|
1438 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
1439 | -> |
---|
1440 | cb_mLogo_i(o,v); |
---|
1441 | } |
---|
1442 | |
---|
1443 | //--------------------------------------------------------------------------- |
---|
1444 | // Active Build process. |
---|
1445 | //--------------------------------------------------------------------------- |
---|
1446 | void GeoMeshViewUI::activeBuildProcess() |
---|
1447 | { |
---|
1448 | //mButtonBuild->set_visible(); |
---|
1449 | mButtonBuild->activate(); |
---|
1450 | |
---|
1451 | //mBuildBar->set_visible(); |
---|
1452 | mBuildBar->activate(); |
---|
1453 | } |
---|
1454 | |
---|
1455 | //--------------------------------------------------------------------------- |
---|
1456 | // Show the stripify panel. |
---|
1457 | //--------------------------------------------------------------------------- |
---|
1458 | void GeoMeshViewUI::showStripify() |
---|
1459 | { |
---|
1460 | /* |
---|
1461 | mTypeLabel->set_visible(); |
---|
1462 | mTypeLabel->activate(); |
---|
1463 | |
---|
1464 | mOneCacheStrip->set_visible(); |
---|
1465 | mOneCacheStrip->activate(); |
---|
1466 | |
---|
1467 | mQualityStrips->set_visible(); |
---|
1468 | mQualityStrips->activate(); |
---|
1469 | */ |
---|
1470 | |
---|
1471 | mButtonProcess->set_visible(); |
---|
1472 | mButtonProcess->activate(); |
---|
1473 | |
---|
1474 | mProcessBar->set_visible(); |
---|
1475 | mProcessBar->activate(); |
---|
1476 | } |
---|
1477 | |
---|
1478 | //--------------------------------------------------------------------------- |
---|
1479 | // Hide the stripify panel. |
---|
1480 | //--------------------------------------------------------------------------- |
---|
1481 | void GeoMeshViewUI::hideStripify() |
---|
1482 | { |
---|
1483 | /* |
---|
1484 | mTypeLabel->hide(); |
---|
1485 | mTypeLabel->deactivate(); |
---|
1486 | */ |
---|
1487 | |
---|
1488 | mOneCacheStrip->hide(); |
---|
1489 | mOneCacheStrip->deactivate(); |
---|
1490 | |
---|
1491 | mQualityStrips->hide(); |
---|
1492 | mQualityStrips->deactivate(); |
---|
1493 | |
---|
1494 | mButtonProcess->hide(); |
---|
1495 | mButtonProcess->deactivate(); |
---|
1496 | |
---|
1497 | mProcessBar->hide(); |
---|
1498 | mProcessBar->deactivate(); |
---|
1499 | } |
---|
1500 | |
---|
1501 | //--------------------------------------------------------------------------- |
---|
1502 | // Show the Simplify Edge Collapse panel. |
---|
1503 | //--------------------------------------------------------------------------- |
---|
1504 | void GeoMeshViewUI::showEdgeCollapse() |
---|
1505 | { |
---|
1506 | mMetricLabel->set_visible(); |
---|
1507 | mMetricLabel->activate(); |
---|
1508 | |
---|
1509 | mGeometryBased->set_visible(); |
---|
1510 | mGeometryBased->activate(); |
---|
1511 | mGeometryBased->set(); |
---|
1512 | |
---|
1513 | mViewPointDriven->set_visible(); |
---|
1514 | mViewPointDriven->activate(); |
---|
1515 | |
---|
1516 | /* |
---|
1517 | mTypeLabel->set_visible(); |
---|
1518 | mTypeLabel->activate(); |
---|
1519 | |
---|
1520 | mChangeVertices->set_visible(); |
---|
1521 | mChangeVertices->activate(); |
---|
1522 | */ |
---|
1523 | |
---|
1524 | mMeshReductionLabel->set_visible(); |
---|
1525 | mMeshReductionLabel->activate(); |
---|
1526 | |
---|
1527 | mPercent->set_visible(); |
---|
1528 | mPercent->activate(); |
---|
1529 | mPercent->set(); |
---|
1530 | |
---|
1531 | mVerticesNumber->set_visible(); |
---|
1532 | mVerticesNumber->activate(); |
---|
1533 | |
---|
1534 | mMeshReduction->set_visible(); |
---|
1535 | |
---|
1536 | // Allows floating point. |
---|
1537 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
1538 | |
---|
1539 | mMeshReduction->activate(); |
---|
1540 | |
---|
1541 | mButtonProcess->set_visible(); |
---|
1542 | mButtonProcess->activate(); |
---|
1543 | |
---|
1544 | mProcessBar->set_visible(); |
---|
1545 | mProcessBar->activate(); |
---|
1546 | } |
---|
1547 | |
---|
1548 | //--------------------------------------------------------------------------- |
---|
1549 | // Hide the Simplify Edge Collapse |
---|
1550 | //--------------------------------------------------------------------------- |
---|
1551 | void GeoMeshViewUI::hideEdgeCollapse() |
---|
1552 | { |
---|
1553 | mMetricLabel->hide(); |
---|
1554 | mMetricLabel->deactivate(); |
---|
1555 | |
---|
1556 | mGeometryBased->hide(); |
---|
1557 | mGeometryBased->deactivate(); |
---|
1558 | |
---|
1559 | mViewPointDriven->hide(); |
---|
1560 | mViewPointDriven->deactivate(); |
---|
1561 | |
---|
1562 | /* |
---|
1563 | mTypeLabel->hide(); |
---|
1564 | mTypeLabel->deactivate(); |
---|
1565 | |
---|
1566 | mChangeVertices->hide(); |
---|
1567 | mChangeVertices->deactivate(); |
---|
1568 | */ |
---|
1569 | |
---|
1570 | mMeshReductionLabel->hide(); |
---|
1571 | mMeshReductionLabel->deactivate(); |
---|
1572 | |
---|
1573 | mPercent->hide(); |
---|
1574 | mPercent->deactivate(); |
---|
1575 | |
---|
1576 | mVerticesNumber->hide(); |
---|
1577 | mVerticesNumber->deactivate(); |
---|
1578 | |
---|
1579 | mMeshReduction->hide(); |
---|
1580 | mMeshReduction->deactivate(); |
---|
1581 | |
---|
1582 | mButtonProcess->hide(); |
---|
1583 | mButtonProcess->deactivate(); |
---|
1584 | |
---|
1585 | mProcessBar->hide(); |
---|
1586 | mProcessBar->deactivate(); |
---|
1587 | } |
---|
1588 | |
---|
1589 | //--------------------------------------------------------------------------- |
---|
1590 | // Show the Simlify Leaves Collapse. |
---|
1591 | //--------------------------------------------------------------------------- |
---|
1592 | void GeoMeshViewUI::showLeavesCollapse() |
---|
1593 | { |
---|
1594 | mMetricLabel->set_visible(); |
---|
1595 | mMetricLabel->activate(); |
---|
1596 | |
---|
1597 | mGeometryBased->set_visible(); |
---|
1598 | mGeometryBased->activate(); |
---|
1599 | mGeometryBased->set(); |
---|
1600 | |
---|
1601 | mViewPointDriven->set_visible(); |
---|
1602 | mViewPointDriven->activate(); |
---|
1603 | |
---|
1604 | /* |
---|
1605 | mTypeLabel->set_visible(); |
---|
1606 | mTypeLabel->activate(); |
---|
1607 | |
---|
1608 | mChangeTexture->set_visible(); |
---|
1609 | mChangeTexture->activate(); |
---|
1610 | */ |
---|
1611 | |
---|
1612 | mMeshReductionLabel->set_visible(); |
---|
1613 | mMeshReductionLabel->activate(); |
---|
1614 | |
---|
1615 | mPercent->set_visible(); |
---|
1616 | mPercent->activate(); |
---|
1617 | mPercent->set(); |
---|
1618 | |
---|
1619 | mVerticesNumber->set_visible(); |
---|
1620 | mVerticesNumber->activate(); |
---|
1621 | |
---|
1622 | mMeshReduction->set_visible(); |
---|
1623 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
1624 | mMeshReduction->activate(); |
---|
1625 | |
---|
1626 | mButtonProcess->set_visible(); |
---|
1627 | mButtonProcess->activate(); |
---|
1628 | |
---|
1629 | mProcessBar->set_visible(); |
---|
1630 | mProcessBar->activate(); |
---|
1631 | } |
---|
1632 | |
---|
1633 | //--------------------------------------------------------------------------- |
---|
1634 | // Hide the Simplify Leaves Collapse. |
---|
1635 | //--------------------------------------------------------------------------- |
---|
1636 | void GeoMeshViewUI::hideLeavesCollapse() |
---|
1637 | { |
---|
1638 | mMetricLabel->hide(); |
---|
1639 | mMetricLabel->deactivate(); |
---|
1640 | |
---|
1641 | mGeometryBased->hide(); |
---|
1642 | mGeometryBased->deactivate(); |
---|
1643 | |
---|
1644 | mViewPointDriven->hide(); |
---|
1645 | mViewPointDriven->deactivate(); |
---|
1646 | |
---|
1647 | /* |
---|
1648 | mTypeLabel->hide(); |
---|
1649 | mTypeLabel->deactivate(); |
---|
1650 | |
---|
1651 | mChangeTexture->hide(); |
---|
1652 | mChangeTexture->deactivate(); |
---|
1653 | */ |
---|
1654 | |
---|
1655 | mMeshReductionLabel->hide(); |
---|
1656 | mMeshReductionLabel->deactivate(); |
---|
1657 | |
---|
1658 | mPercent->hide(); |
---|
1659 | mPercent->deactivate(); |
---|
1660 | |
---|
1661 | mVerticesNumber->hide(); |
---|
1662 | mVerticesNumber->deactivate(); |
---|
1663 | |
---|
1664 | mMeshReduction->hide(); |
---|
1665 | mMeshReduction->deactivate(); |
---|
1666 | |
---|
1667 | mButtonProcess->hide(); |
---|
1668 | mButtonProcess->deactivate(); |
---|
1669 | |
---|
1670 | mProcessBar->hide(); |
---|
1671 | mProcessBar->deactivate(); |
---|
1672 | } |
---|
1673 | |
---|
1674 | //--------------------------------------------------------------------------- |
---|
1675 | // Show the LodStrips Panel. |
---|
1676 | //--------------------------------------------------------------------------- |
---|
1677 | void GeoMeshViewUI::showOpenMeshSimplification() |
---|
1678 | { |
---|
1679 | mButtonProcess->set_visible(); |
---|
1680 | mButtonProcess->activate(); |
---|
1681 | |
---|
1682 | mProcessBar->set_visible(); |
---|
1683 | mProcessBar->activate(); |
---|
1684 | |
---|
1685 | mButtonBuild->set_visible(); |
---|
1686 | mButtonBuild->activate(); |
---|
1687 | |
---|
1688 | mBuildBar->set_visible(); |
---|
1689 | mBuildBar->activate(); |
---|
1690 | } |
---|
1691 | |
---|
1692 | //--------------------------------------------------------------------------- |
---|
1693 | // Hide the LodStrips Panel. |
---|
1694 | //--------------------------------------------------------------------------- |
---|
1695 | void GeoMeshViewUI::hideOpenMeshSimplification() |
---|
1696 | { |
---|
1697 | mButtonProcess->hide(); |
---|
1698 | mButtonProcess->deactivate(); |
---|
1699 | |
---|
1700 | mProcessBar->hide(); |
---|
1701 | mProcessBar->deactivate(); |
---|
1702 | |
---|
1703 | mButtonBuild->hide(); |
---|
1704 | mButtonBuild->deactivate(); |
---|
1705 | |
---|
1706 | mBuildBar->hide(); |
---|
1707 | mBuildBar->deactivate(); |
---|
1708 | } |
---|
1709 | |
---|
1710 | //--------------------------------------------------------------------------- |
---|
1711 | // Shows the auto generate LodStrips panel. |
---|
1712 | //--------------------------------------------------------------------------- |
---|
1713 | void GeoMeshViewUI::showAutoGenerateLodStrips() |
---|
1714 | { |
---|
1715 | // Shows the simplify panel. |
---|
1716 | showEdgeCollapse(); |
---|
1717 | |
---|
1718 | mButtonBuild->set_visible(); |
---|
1719 | //mButtonBuild->activate(); |
---|
1720 | |
---|
1721 | mBuildBar->set_visible(); |
---|
1722 | //mBuildBar->activate(); |
---|
1723 | } |
---|
1724 | |
---|
1725 | //--------------------------------------------------------------------------- |
---|
1726 | // Shows the auto generate LodStrips panel. |
---|
1727 | //--------------------------------------------------------------------------- |
---|
1728 | void GeoMeshViewUI::showAutoGenerateLodTrees() |
---|
1729 | { |
---|
1730 | // Shows the simplify panel. |
---|
1731 | showEdgeCollapse(); |
---|
1732 | |
---|
1733 | mButtonBuild->set_visible(); |
---|
1734 | //mButtonBuild->activate(); |
---|
1735 | |
---|
1736 | mBuildBar->set_visible(); |
---|
1737 | //mBuildBar->activate(); |
---|
1738 | } |
---|
1739 | |
---|
1740 | //--------------------------------------------------------------------------- |
---|
1741 | // Show the LodStrips visulization panel. |
---|
1742 | //--------------------------------------------------------------------------- |
---|
1743 | void GeoMeshViewUI::showLodStripSlider() |
---|
1744 | { |
---|
1745 | mLodStripSlider->set_visible(); |
---|
1746 | mLodStripSlider->activate(); |
---|
1747 | } |
---|
1748 | |
---|
1749 | //--------------------------------------------------------------------------- |
---|
1750 | // Hide the LodStrips visualization panel. |
---|
1751 | //--------------------------------------------------------------------------- |
---|
1752 | void GeoMeshViewUI::hideLodStripSlider() |
---|
1753 | { |
---|
1754 | mLodStripSlider->hide(); |
---|
1755 | mLodStripSlider->deactivate(); |
---|
1756 | } |
---|
1757 | |
---|
1758 | //--------------------------------------------------------------------------- |
---|
1759 | // Show the LodTree visulization panel. |
---|
1760 | //--------------------------------------------------------------------------- |
---|
1761 | void GeoMeshViewUI::showLodTreeSlider() |
---|
1762 | { |
---|
1763 | mLodTreeSlider->set_visible(); |
---|
1764 | mLodTreeSlider->activate(); |
---|
1765 | } |
---|
1766 | |
---|
1767 | //--------------------------------------------------------------------------- |
---|
1768 | // Hide the LodTree visualization panel. |
---|
1769 | //--------------------------------------------------------------------------- |
---|
1770 | void GeoMeshViewUI::hideLodTreeSlider() |
---|
1771 | { |
---|
1772 | mLodTreeSlider->hide(); |
---|
1773 | mLodTreeSlider->deactivate(); |
---|
1774 | } |
---|
1775 | |
---|
1776 | //--------------------------------------------------------------------------- |
---|
1777 | // Show the LodTrees Panel. |
---|
1778 | //--------------------------------------------------------------------------- |
---|
1779 | void GeoMeshViewUI::showOpenLeavesSimplification() |
---|
1780 | { |
---|
1781 | mButtonBuild->set_visible(); |
---|
1782 | mButtonBuild->activate(); |
---|
1783 | |
---|
1784 | mBuildBar->set_visible(); |
---|
1785 | mBuildBar->activate(); |
---|
1786 | } |
---|
1787 | |
---|
1788 | //--------------------------------------------------------------------------- |
---|
1789 | // Hide the LodTrees Panel. |
---|
1790 | //--------------------------------------------------------------------------- |
---|
1791 | void GeoMeshViewUI::hideOpenLeavesSimplification() |
---|
1792 | { |
---|
1793 | mButtonBuild->hide(); |
---|
1794 | mButtonBuild->deactivate(); |
---|
1795 | |
---|
1796 | mBuildBar->hide(); |
---|
1797 | mBuildBar->deactivate(); |
---|
1798 | } |
---|
1799 | |
---|
1800 | //--------------------------------------------------------------------------- |
---|
1801 | // Show the mesh info browser. |
---|
1802 | //--------------------------------------------------------------------------- |
---|
1803 | void GeoMeshViewUI::showMeshInfo() |
---|
1804 | { |
---|
1805 | char type[10]; |
---|
1806 | |
---|
1807 | if (mGeoMesh) |
---|
1808 | { |
---|
1809 | // Remove previous mesh information |
---|
1810 | this->mMeshInfo->remove_all(); |
---|
1811 | ogeometry = new fltk::ItemGroup("Geometry"); |
---|
1812 | ogeometry->begin(); |
---|
1813 | |
---|
1814 | fltk::ItemGroup **oprueba; |
---|
1815 | oprueba=new fltk::ItemGroup*[mGeoMesh->mSubMeshCount]; |
---|
1816 | for(int i=0; i<mGeoMesh->mSubMeshCount;i++) |
---|
1817 | { |
---|
1818 | char *cadena=new char[256]; |
---|
1819 | |
---|
1820 | if (geoMeshView->getLeavesSubMesh() >= 0) |
---|
1821 | { |
---|
1822 | if (geoMeshView->getLeavesSubMesh() == i) |
---|
1823 | { |
---|
1824 | strcpy(type,"(Leaves)"); |
---|
1825 | } |
---|
1826 | else |
---|
1827 | { |
---|
1828 | strcpy(type,"(Trunc)"); |
---|
1829 | } |
---|
1830 | } |
---|
1831 | else |
---|
1832 | { |
---|
1833 | strcpy(type,""); |
---|
1834 | } |
---|
1835 | |
---|
1836 | // Submesh identifier. |
---|
1837 | sprintf(cadena,"SubMesh %d %s",i,type); |
---|
1838 | |
---|
1839 | oprueba[i] = new fltk::ItemGroup(cadena); |
---|
1840 | oprueba[i]->begin(); |
---|
1841 | fltk::Item *sharedGeometry; |
---|
1842 | if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) |
---|
1843 | { |
---|
1844 | sharedGeometry = new fltk::Item("Shared Geometry: Yes"); |
---|
1845 | } |
---|
1846 | else |
---|
1847 | { |
---|
1848 | sharedGeometry = new fltk::Item("Shared Geometry: No"); |
---|
1849 | } |
---|
1850 | |
---|
1851 | // Adds material name. |
---|
1852 | char *cadena2=new char[100]; |
---|
1853 | sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); |
---|
1854 | |
---|
1855 | fltk::Item *geomaterial = new fltk::Item(cadena2); |
---|
1856 | |
---|
1857 | char *cadena3=new char[100]; |
---|
1858 | |
---|
1859 | sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); |
---|
1860 | fltk::Item *numberIndex = new fltk::Item(cadena3); |
---|
1861 | if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) |
---|
1862 | { |
---|
1863 | fltk::Item *type = new fltk::Item("Triangle List"); |
---|
1864 | } |
---|
1865 | else |
---|
1866 | { |
---|
1867 | fltk::Item *type = new fltk::Item("Triangle Strips"); |
---|
1868 | } |
---|
1869 | |
---|
1870 | char *cadenavertex=new char[30]; |
---|
1871 | sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); |
---|
1872 | fltk::Item *numberVertex = new fltk::Item(cadenavertex); |
---|
1873 | |
---|
1874 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) |
---|
1875 | { |
---|
1876 | fltk::Item *normals = new fltk::Item("Normals: Yes"); |
---|
1877 | } |
---|
1878 | else |
---|
1879 | { |
---|
1880 | fltk::Item *normals = new fltk::Item("Normals: No"); |
---|
1881 | } |
---|
1882 | |
---|
1883 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) |
---|
1884 | { |
---|
1885 | fltk::Item *textures = new fltk::Item("Textures: Yes"); |
---|
1886 | } |
---|
1887 | else |
---|
1888 | { |
---|
1889 | fltk::Item *textures = new fltk::Item("Textures: No"); |
---|
1890 | } |
---|
1891 | |
---|
1892 | |
---|
1893 | oprueba[i]->end(); |
---|
1894 | } |
---|
1895 | ogeometry->end(); |
---|
1896 | this->mMeshInfo->add(ogeometry); |
---|
1897 | } |
---|
1898 | |
---|
1899 | // Hide the right panel. |
---|
1900 | hideRightPanel(); |
---|
1901 | |
---|
1902 | mMeshInfo->set_visible(); |
---|
1903 | mMeshInfo->activate(); |
---|
1904 | } |
---|
1905 | |
---|
1906 | //--------------------------------------------------------------------------- |
---|
1907 | // Hide the mesh info browser. |
---|
1908 | //--------------------------------------------------------------------------- |
---|
1909 | void GeoMeshViewUI::hideMeshInfo() |
---|
1910 | { |
---|
1911 | mMeshInfo->hide(); |
---|
1912 | mMeshInfo->deactivate(); |
---|
1913 | } |
---|
1914 | |
---|
1915 | //--------------------------------------------------------------------------- |
---|
1916 | // Hide the right panel. |
---|
1917 | //--------------------------------------------------------------------------- |
---|
1918 | void GeoMeshViewUI::hideRightPanel() |
---|
1919 | { |
---|
1920 | hideStripify(); |
---|
1921 | hideEdgeCollapse(); |
---|
1922 | hideLeavesCollapse(); |
---|
1923 | hideOpenMeshSimplification(); |
---|
1924 | hideOpenLeavesSimplification(); |
---|
1925 | hideLodStripSlider(); |
---|
1926 | hideLodTreeSlider(); |
---|
1927 | hideMeshInfo(); |
---|
1928 | } |
---|
1929 | |
---|
1930 | //--------------------------------------------------------------------------- |
---|
1931 | // Get the number of vertices. |
---|
1932 | //--------------------------------------------------------------------------- |
---|
1933 | size_t GeoMeshViewUI::getVertexCount(Mesh *geoMesh) |
---|
1934 | { |
---|
1935 | size_t vertex_count; |
---|
1936 | SubMesh *geoSubMesh; |
---|
1937 | |
---|
1938 | vertex_count = geoMesh->mVertexBuffer->mVertexCount; |
---|
1939 | |
---|
1940 | // For each submesh. |
---|
1941 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
1942 | { |
---|
1943 | // Gets the actual submesh. |
---|
1944 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
1945 | |
---|
1946 | // If the mesh does not have shared vertex. |
---|
1947 | if (!geoSubMesh->mSharedVertexBuffer) |
---|
1948 | { |
---|
1949 | // Adds the vertex of the submesh to the total count. |
---|
1950 | vertex_count += geoSubMesh->mVertexBuffer->mVertexCount; |
---|
1951 | } |
---|
1952 | } |
---|
1953 | |
---|
1954 | return vertex_count; |
---|
1955 | } |
---|
1956 | |
---|
1957 | //--------------------------------------------------------------------------- |
---|
1958 | // Get the number of triangles. |
---|
1959 | //--------------------------------------------------------------------------- |
---|
1960 | size_t GeoMeshViewUI::getTriangleCount(Geometry::Mesh *geoMesh) |
---|
1961 | { |
---|
1962 | size_t triangle_count; |
---|
1963 | SubMesh *geoSubMesh; |
---|
1964 | |
---|
1965 | // Initialize the triangle count. |
---|
1966 | triangle_count = 0; |
---|
1967 | |
---|
1968 | // If the application is in visualize lodstrips mode. |
---|
1969 | if (mApplicationState == VISUALIZE_LODSTRIPS) |
---|
1970 | { |
---|
1971 | triangle_count = geoMeshView->getLodStripsTriangleCount(); |
---|
1972 | } |
---|
1973 | else |
---|
1974 | { |
---|
1975 | // For each submesh. |
---|
1976 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
1977 | { |
---|
1978 | // Gets the actual submesh. |
---|
1979 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
1980 | |
---|
1981 | switch (geoSubMesh->mType) |
---|
1982 | { |
---|
1983 | case GEO_TRIANGLE_LIST: |
---|
1984 | triangle_count += geoSubMesh->mIndexCount / 3; |
---|
1985 | break; |
---|
1986 | case GEO_TRIANGLE_STRIPS: |
---|
1987 | triangle_count += geoSubMesh->mIndexCount - 2; |
---|
1988 | break; |
---|
1989 | } |
---|
1990 | } |
---|
1991 | } |
---|
1992 | |
---|
1993 | return triangle_count; |
---|
1994 | } |
---|
1995 | |
---|
1996 | //--------------------------------------------------------------------------- |
---|
1997 | // Get the number of strips. |
---|
1998 | //--------------------------------------------------------------------------- |
---|
1999 | size_t GeoMeshViewUI::getStripCount(Geometry::Mesh *geoMesh) |
---|
2000 | { |
---|
2001 | size_t strip_count; |
---|
2002 | SubMesh *geoSubMesh; |
---|
2003 | |
---|
2004 | // Initialize the triangle count. |
---|
2005 | strip_count = 0; |
---|
2006 | |
---|
2007 | // For each submesh. |
---|
2008 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
2009 | { |
---|
2010 | // Gets the actual submesh. |
---|
2011 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
2012 | |
---|
2013 | if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) |
---|
2014 | { |
---|
2015 | strip_count += geoSubMesh->mStripCount; |
---|
2016 | } |
---|
2017 | } |
---|
2018 | |
---|
2019 | return strip_count; |
---|
2020 | } |
---|
2021 | |
---|
2022 | //--------------------------------------------------------------------------- |
---|
2023 | // It paints the submesh selected by the mMeshInfo tree. |
---|
2024 | // Trate the mMeshInfo event. |
---|
2025 | //--------------------------------------------------------------------------- |
---|
2026 | int GeoMeshViewUI::paintMesh(void) |
---|
2027 | { |
---|
2028 | char selectedTag[100]; |
---|
2029 | char *pch; |
---|
2030 | char *p; |
---|
2031 | int meshNumber; |
---|
2032 | |
---|
2033 | // Initializa mesh to not selected. |
---|
2034 | meshNumber = -1; |
---|
2035 | |
---|
2036 | // Shows the selected object label. |
---|
2037 | strcpy(selectedTag,mMeshInfo->goto_focus()->label()); |
---|
2038 | |
---|
2039 | p=strstr(selectedTag,"SubMesh "); |
---|
2040 | |
---|
2041 | // If the item begins with string "SubMesh". |
---|
2042 | if (p!=NULL) |
---|
2043 | { |
---|
2044 | pch = strtok (selectedTag," "); |
---|
2045 | pch = strtok (NULL, " "); |
---|
2046 | sscanf(pch,"%d",&meshNumber); |
---|
2047 | } |
---|
2048 | |
---|
2049 | geoMeshView->setSubMeshSelected(meshNumber); |
---|
2050 | geoMeshView->redraw(); |
---|
2051 | |
---|
2052 | return meshNumber; |
---|
2053 | } |
---|
2054 | |
---|
2055 | //--------------------------------------------------------------------------- |
---|
2056 | // Simplify the mesh object. |
---|
2057 | //--------------------------------------------------------------------------- |
---|
2058 | bool GeoMeshViewUI::simplifyEdgeCollapse() |
---|
2059 | { |
---|
2060 | Real percent; |
---|
2061 | |
---|
2062 | // If input field empty. |
---|
2063 | if (mMeshReduction->fvalue() <= 0.0) |
---|
2064 | { |
---|
2065 | return false; |
---|
2066 | } |
---|
2067 | |
---|
2068 | geoMeshView->saveContext(); |
---|
2069 | |
---|
2070 | // Debug. |
---|
2071 | cout << "Mesh Reduction: " |
---|
2072 | << mMeshReduction->fvalue() |
---|
2073 | << endl; |
---|
2074 | |
---|
2075 | // Gets simplify option. |
---|
2076 | if (mGeometryBased->value()) |
---|
2077 | { |
---|
2078 | simplificationState = MESHSIMP; |
---|
2079 | mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, |
---|
2080 | progress_function); |
---|
2081 | } |
---|
2082 | else |
---|
2083 | { |
---|
2084 | simplificationState = VIEWPOINTDRIVEN; |
---|
2085 | mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, |
---|
2086 | progress_function); |
---|
2087 | } |
---|
2088 | |
---|
2089 | mMeshSimplifier->setMeshLeaves(idMeshLeaves); |
---|
2090 | |
---|
2091 | if (mPercent->value()) |
---|
2092 | { |
---|
2093 | // Simplificación por porcentaje |
---|
2094 | if (mMeshReduction->fvalue() <= 100.0 && |
---|
2095 | mMeshReduction->fvalue() > 0.0) |
---|
2096 | { |
---|
2097 | percent = mMeshReduction->fvalue(); |
---|
2098 | percent = percent / 100.0; |
---|
2099 | |
---|
2100 | // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. |
---|
2101 | mMeshSimplifier->Simplify(percent); |
---|
2102 | |
---|
2103 | // Deletes the previous mesh. |
---|
2104 | delete mUndoMesh; |
---|
2105 | |
---|
2106 | mUndoMesh = new Mesh(); |
---|
2107 | |
---|
2108 | // Sets the undo mesh. |
---|
2109 | *mUndoMesh = *mGeoMesh; |
---|
2110 | |
---|
2111 | delete mGeoMesh; |
---|
2112 | |
---|
2113 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
2114 | |
---|
2115 | // Visualize mesh. |
---|
2116 | geoMeshView->setMesh(mGeoMesh); |
---|
2117 | } |
---|
2118 | else |
---|
2119 | { |
---|
2120 | fltk::alert("Wrong value for simplification.\n" |
---|
2121 | "Valid values [0..100]"); |
---|
2122 | |
---|
2123 | return false; |
---|
2124 | } |
---|
2125 | } |
---|
2126 | else |
---|
2127 | { |
---|
2128 | // Simplificar hasta un número de vértices. |
---|
2129 | uint32 v = (uint32)mMeshReduction->fvalue(); |
---|
2130 | |
---|
2131 | // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. |
---|
2132 | mMeshSimplifier->Simplify(v); |
---|
2133 | |
---|
2134 | // Deletes the previous mesh. |
---|
2135 | delete mUndoMesh; |
---|
2136 | |
---|
2137 | mUndoMesh = new Mesh(); |
---|
2138 | |
---|
2139 | // Sets the undo mesh. |
---|
2140 | *mUndoMesh = *mGeoMesh; |
---|
2141 | |
---|
2142 | delete mGeoMesh; |
---|
2143 | |
---|
2144 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
2145 | |
---|
2146 | // Visualize the mesh. |
---|
2147 | geoMeshView->setMesh(mGeoMesh); |
---|
2148 | } |
---|
2149 | |
---|
2150 | return true; |
---|
2151 | } |
---|
2152 | |
---|
2153 | //--------------------------------------------------------------------------- |
---|
2154 | // Simplify the mesh object. |
---|
2155 | //--------------------------------------------------------------------------- |
---|
2156 | void GeoMeshViewUI::simplifyLeavesCollapse() |
---|
2157 | { |
---|
2158 | bool error; |
---|
2159 | uint32 vi; |
---|
2160 | |
---|
2161 | // Initialize error flag. |
---|
2162 | error = false; |
---|
2163 | |
---|
2164 | // Check submeshes for triangles strips. |
---|
2165 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
2166 | { |
---|
2167 | // If current submesh is in triangle strips. |
---|
2168 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
2169 | { |
---|
2170 | error = true; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | |
---|
2174 | // if the mesh is stripified. |
---|
2175 | if (error) |
---|
2176 | { |
---|
2177 | fltk::alert("Can't simplify a tree in triagle strips."); |
---|
2178 | } |
---|
2179 | // if the mesh is in triangle list. |
---|
2180 | else |
---|
2181 | { |
---|
2182 | simplificationState = HOJAS; |
---|
2183 | |
---|
2184 | mTreeSimplifier = new TreeSimplifier(mGeoMesh, progress_function); |
---|
2185 | vi = (uint32)mMeshReduction->fvalue(); |
---|
2186 | |
---|
2187 | // Simplify |
---|
2188 | if(idMeshLeaves != (unsigned short)-1) |
---|
2189 | { |
---|
2190 | // Simplify |
---|
2191 | mTreeSimplifier->Simplify(vi, idMeshLeaves); |
---|
2192 | |
---|
2193 | // Deletes the previous mesh. |
---|
2194 | delete mUndoMesh; |
---|
2195 | |
---|
2196 | mUndoMesh = new Mesh(); |
---|
2197 | |
---|
2198 | // Sets the undo mesh. |
---|
2199 | *mUndoMesh = *mGeoMesh; |
---|
2200 | |
---|
2201 | delete mGeoMesh; |
---|
2202 | |
---|
2203 | mGeoMesh = mTreeSimplifier->GetMesh(); |
---|
2204 | |
---|
2205 | geoMeshView->setMesh(mGeoMesh); |
---|
2206 | } |
---|
2207 | else |
---|
2208 | { |
---|
2209 | fltk::alert("You must select the mesh that contains the leaves."); |
---|
2210 | } |
---|
2211 | } |
---|
2212 | } |
---|
2213 | |
---|
2214 | //--------------------------------------------------------------------------- |
---|
2215 | // Create a simplification sequence of the simplification method. |
---|
2216 | //--------------------------------------------------------------------------- |
---|
2217 | void GeoMeshViewUI::createSimplificationSequence() |
---|
2218 | { |
---|
2219 | MeshSimplificationSequence *secsimpl; |
---|
2220 | |
---|
2221 | secsimpl = mMeshSimplifier->GetSimplificationSequence(); |
---|
2222 | |
---|
2223 | secsimpl->putMeshName(nombremesh); // Nombre del mesh para guardar la secuencia de simplificación |
---|
2224 | secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); |
---|
2225 | |
---|
2226 | //delete secsimpl; |
---|
2227 | } |
---|
2228 | |
---|
2229 | //--------------------------------------------------------------------------- |
---|
2230 | // Create a simplification sequence of the leaves. |
---|
2231 | //--------------------------------------------------------------------------- |
---|
2232 | void GeoMeshViewUI::createLeavesSequence(const std::string &filename) |
---|
2233 | { |
---|
2234 | TreeSimplificationSequence *tree_sequencer; |
---|
2235 | |
---|
2236 | tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); |
---|
2237 | |
---|
2238 | tree_sequencer->putMeshName(nombremesh); |
---|
2239 | tree_sequencer->Save(Serializer(filename,Serializer::WRITE)); |
---|
2240 | |
---|
2241 | delete tree_sequencer; |
---|
2242 | } |
---|
2243 | |
---|
2244 | //--------------------------------------------------------------------------- |
---|
2245 | // Stripify the mesh object. |
---|
2246 | //--------------------------------------------------------------------------- |
---|
2247 | void GeoMeshViewUI::stripify() |
---|
2248 | { |
---|
2249 | bool error; |
---|
2250 | char char_value[10]; |
---|
2251 | CustomStripifier *geoStripifier; |
---|
2252 | |
---|
2253 | // Initialize error flag. |
---|
2254 | error = false; |
---|
2255 | |
---|
2256 | // Check submeshes for triangles strips. |
---|
2257 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
2258 | { |
---|
2259 | // If current submesh is in triangle strips. |
---|
2260 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
2261 | { |
---|
2262 | error = true; |
---|
2263 | } |
---|
2264 | } |
---|
2265 | |
---|
2266 | // if the mesh is stripified. |
---|
2267 | if (error) |
---|
2268 | { |
---|
2269 | fltk::alert("The mesh is already in strips."); |
---|
2270 | } |
---|
2271 | // if the mesh is in triangle list. |
---|
2272 | else |
---|
2273 | { |
---|
2274 | //Stripify. |
---|
2275 | geoStripifier = new CustomStripifier(mGeoMesh); |
---|
2276 | |
---|
2277 | // Set the progress bar function. |
---|
2278 | geoStripifier->SetProgressFunc(progress_function); |
---|
2279 | |
---|
2280 | // Sets the leaves submesh if exists. |
---|
2281 | geoStripifier->SetSubMeshLeaves(idMeshLeaves); |
---|
2282 | |
---|
2283 | if (geoStripifier->Stripify()) |
---|
2284 | { |
---|
2285 | // Deletes the mesh object. |
---|
2286 | delete mUndoMesh; |
---|
2287 | |
---|
2288 | mUndoMesh = new Mesh(); |
---|
2289 | |
---|
2290 | *mUndoMesh = *mGeoMesh; |
---|
2291 | |
---|
2292 | delete mGeoMesh; |
---|
2293 | |
---|
2294 | // Gets the mesh stripified. |
---|
2295 | mGeoMesh = geoStripifier->GetMesh(); |
---|
2296 | |
---|
2297 | // Visualize the mesh stripified. |
---|
2298 | geoMeshView->setMesh(mGeoMesh); |
---|
2299 | |
---|
2300 | // Store the color of the strips. |
---|
2301 | geoMeshView->setStripColors(); |
---|
2302 | } |
---|
2303 | else |
---|
2304 | { |
---|
2305 | // Error message. |
---|
2306 | fltk::alert("Impossible to stripify. The mesh is not manifold"); |
---|
2307 | } |
---|
2308 | |
---|
2309 | // Deletes the stripifier object. |
---|
2310 | delete geoStripifier; |
---|
2311 | } |
---|
2312 | } |
---|
2313 | |
---|
2314 | //--------------------------------------------------------------------------- |
---|
2315 | // Method that undo then mesh changes. |
---|
2316 | //--------------------------------------------------------------------------- |
---|
2317 | void GeoMeshViewUI::undo() |
---|
2318 | { |
---|
2319 | // if the undo mesh is not initialized. |
---|
2320 | if (mUndoMesh != NULL) |
---|
2321 | { |
---|
2322 | // Deletes the actual mesh. |
---|
2323 | delete mGeoMesh; |
---|
2324 | |
---|
2325 | mGeoMesh = new Mesh(); |
---|
2326 | |
---|
2327 | // Restore the previous mesh. |
---|
2328 | *mGeoMesh = *mUndoMesh; |
---|
2329 | |
---|
2330 | // Visualize the mesh. |
---|
2331 | geoMeshView->setMesh(mGeoMesh); |
---|
2332 | |
---|
2333 | // Refresh geometry attributes. |
---|
2334 | refreshApplicationBar(); |
---|
2335 | |
---|
2336 | // Repaint the window. |
---|
2337 | mMainWindow->redraw(); |
---|
2338 | } |
---|
2339 | } |
---|
2340 | |
---|
2341 | //--------------------------------------------------------------------------- |
---|
2342 | // Refresh number of vertices, triangles, strips, ... |
---|
2343 | //--------------------------------------------------------------------------- |
---|
2344 | void GeoMeshViewUI::refreshApplicationBar() |
---|
2345 | { |
---|
2346 | static char vertices_value[50]; |
---|
2347 | static char triangles_value[50]; |
---|
2348 | static char strips_value[50]; |
---|
2349 | |
---|
2350 | // Translate the vertex count to a char value. |
---|
2351 | sprintf(vertices_value,"Vertices %d",getVertexCount(mGeoMesh)); |
---|
2352 | |
---|
2353 | mVertices->label(vertices_value); |
---|
2354 | |
---|
2355 | // Translate the triangle count to a char value. |
---|
2356 | sprintf(triangles_value,"Triangles %d",getTriangleCount(mGeoMesh)); |
---|
2357 | |
---|
2358 | mTriangles->label(triangles_value); |
---|
2359 | |
---|
2360 | // Translate the triangle count to a char value. |
---|
2361 | sprintf(strips_value,"Strips %d",getStripCount(mGeoMesh)); |
---|
2362 | |
---|
2363 | mStrips->label(strips_value); |
---|
2364 | } |
---|
2365 | |
---|
2366 | // Method that updates the porgress bar. |
---|
2367 | float GeoMeshViewUI::updateProgressBar(float v) |
---|
2368 | { |
---|
2369 | fltk::ProgressBar *progressBar; |
---|
2370 | |
---|
2371 | // Choose progress bar to update. |
---|
2372 | switch(progressBarType) |
---|
2373 | { |
---|
2374 | case PROCESS: |
---|
2375 | progressBar = mProcessBar; |
---|
2376 | break; |
---|
2377 | case BUILD: |
---|
2378 | progressBar = mBuildBar; |
---|
2379 | break; |
---|
2380 | } |
---|
2381 | |
---|
2382 | // Update progress bar. |
---|
2383 | progressBar->step(v); |
---|
2384 | progressBar->step(); |
---|
2385 | mMainWindow->flush(); |
---|
2386 | //mMainWindow->redraw(); |
---|
2387 | |
---|
2388 | return 0; |
---|
2389 | } |
---|
2390 | |
---|
2391 | //--------------------------------------------------------------------------- |
---|
2392 | // Initialize the lodstripslibrary for visualization. |
---|
2393 | //--------------------------------------------------------------------------- |
---|
2394 | void GeoMeshViewUI::setLodStripsLibrary(std::string lodfile, Mesh *geomesh) |
---|
2395 | { |
---|
2396 | // If there is no lod strips object. |
---|
2397 | if (lodStripsLib) |
---|
2398 | { |
---|
2399 | delete lodStripsLib; |
---|
2400 | } |
---|
2401 | |
---|
2402 | // New lod strips object. |
---|
2403 | lodStripsLib = new LodStripsLibrary(lodfile, geomesh); |
---|
2404 | |
---|
2405 | // Sets the slider range. |
---|
2406 | // mLodStripSlider->range(lodStripsLib->MinLod(),lodStripsLib->MaxLod()); |
---|
2407 | mLodStripSlider->range(0.0f,1.0f); |
---|
2408 | |
---|
2409 | // Pass to geomeshview the lod strips object. |
---|
2410 | geoMeshView->setLodStripsLibrary(lodStripsLib); |
---|
2411 | |
---|
2412 | // Puts the slider in the max position. |
---|
2413 | mLodStripSlider->value(1.0f); |
---|
2414 | } |
---|
2415 | |
---|
2416 | //--------------------------------------------------------------------------- |
---|
2417 | // Initialize the lodTreelibrary for visualization. |
---|
2418 | //--------------------------------------------------------------------------- |
---|
2419 | //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) |
---|
2420 | void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) |
---|
2421 | |
---|
2422 | { |
---|
2423 | // If there is no lod strips object. |
---|
2424 | if (lodTreeLib) |
---|
2425 | { |
---|
2426 | delete lodTreeLib; |
---|
2427 | } |
---|
2428 | |
---|
2429 | // New lod strips object. |
---|
2430 | /* lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", |
---|
2431 | "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", |
---|
2432 | "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ |
---|
2433 | |
---|
2434 | lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); |
---|
2435 | |
---|
2436 | // Sets the slider range. |
---|
2437 | // mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); |
---|
2438 | // mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod()); |
---|
2439 | mLodStripSlider->range(0.0f,1.0f); |
---|
2440 | mLodTreeSlider->range(0.0f,1.0f); |
---|
2441 | |
---|
2442 | // Pass to geomeshview the lod strips object. |
---|
2443 | geoMeshView->setLodTreesLibrary(lodTreeLib); |
---|
2444 | |
---|
2445 | // Puts the slider in the max position. |
---|
2446 | mLodStripSlider->value(1.0f); |
---|
2447 | mLodTreeSlider->value(1.0f); |
---|
2448 | } |
---|
2449 | |
---|
2450 | //--------------------------------------------------------------------------- |
---|
2451 | // Open a mesh file. |
---|
2452 | //--------------------------------------------------------------------------- |
---|
2453 | void GeoMeshViewUI::openMeshFile(void) |
---|
2454 | { |
---|
2455 | Mesh *mesh_loaded; |
---|
2456 | fltk::FileChooser *fcho; |
---|
2457 | static char char_value[10]; |
---|
2458 | static char title[256]; |
---|
2459 | |
---|
2460 | fcho = new fltk::FileChooser("", "*.{mesh,obj}", fltk::FileChooser::CREATE, "Open a mesh"); |
---|
2461 | |
---|
2462 | fcho->exec(); |
---|
2463 | |
---|
2464 | // File name. |
---|
2465 | mFileName = (char *)fcho->value(); |
---|
2466 | |
---|
2467 | if (mFileName) |
---|
2468 | { |
---|
2469 | // Loads a new mesh. |
---|
2470 | mesh_loaded = geoMeshLoader->load(mFileName); |
---|
2471 | |
---|
2472 | // If no error happens. |
---|
2473 | if (mesh_loaded) |
---|
2474 | { |
---|
2475 | // Identify the mesh that stores the leaves |
---|
2476 | idMeshLeaves = -1; |
---|
2477 | |
---|
2478 | // Delete the current mesh. |
---|
2479 | delete mGeoMesh; |
---|
2480 | delete mUndoMesh; |
---|
2481 | |
---|
2482 | // Assigns mesh loaded. |
---|
2483 | mGeoMesh = mesh_loaded; |
---|
2484 | |
---|
2485 | // Set Window Title. |
---|
2486 | strcpy(title,filename_name(mFileName)); |
---|
2487 | mMainWindow->label(strcat(title," - GeoTool")); |
---|
2488 | |
---|
2489 | // Stores the name of the mesh. |
---|
2490 | nombremesh = new char[255]; |
---|
2491 | strcpy(nombremesh,mFileName); |
---|
2492 | |
---|
2493 | // Reset the undo mesh. |
---|
2494 | mUndoMesh = new Mesh(); |
---|
2495 | *mUndoMesh = *mGeoMesh; |
---|
2496 | |
---|
2497 | // Translate the MB count to a char value. |
---|
2498 | sprintf(char_value, |
---|
2499 | "MB %.3f", |
---|
2500 | (float)geoMeshLoader->getFileSize()/1024/1024); |
---|
2501 | |
---|
2502 | mMB->label(char_value); |
---|
2503 | |
---|
2504 | // Visualize mesh. |
---|
2505 | geoMeshView->setMesh(mGeoMesh); |
---|
2506 | |
---|
2507 | // Set textures. |
---|
2508 | geoMeshView->resetTextures(); |
---|
2509 | setTextures(); |
---|
2510 | |
---|
2511 | // Hide right panel. |
---|
2512 | hideRightPanel(); |
---|
2513 | |
---|
2514 | // Quit culling. |
---|
2515 | menuRenderCW->clear_value(); |
---|
2516 | menuRenderCCW->clear_value(); |
---|
2517 | geoMeshView->deactiveCW(); |
---|
2518 | geoMeshView->deactiveCCW(); |
---|
2519 | |
---|
2520 | // Deactive solid mode and wire. |
---|
2521 | menuRenderSolid->clear_value(); |
---|
2522 | menuRenderWire->clear_value(); |
---|
2523 | geoMeshView->deactiveSolid(); |
---|
2524 | geoMeshView->deactiveWire(); |
---|
2525 | |
---|
2526 | // Fit model in midle. |
---|
2527 | geoMeshView->fit(); |
---|
2528 | |
---|
2529 | // Lighting smooth. |
---|
2530 | menuRenderFlat->clear_value(); |
---|
2531 | menuRenderSmooth->set_value(); |
---|
2532 | geoMeshView->smooth(); |
---|
2533 | |
---|
2534 | // Show title. |
---|
2535 | mProcessTitle->label("Mesh Info"); |
---|
2536 | |
---|
2537 | // Shows the mesh info. |
---|
2538 | showMeshInfo(); |
---|
2539 | |
---|
2540 | // if the mesh is stripified. |
---|
2541 | geoMeshView->setStripColors(); |
---|
2542 | |
---|
2543 | // Refresh geometry attributes. |
---|
2544 | refreshApplicationBar(); |
---|
2545 | |
---|
2546 | // Restore simplification state. |
---|
2547 | simplificationState = NO_SIMPLIFICATION; |
---|
2548 | } |
---|
2549 | } |
---|
2550 | // Free memory. |
---|
2551 | delete fcho; |
---|
2552 | } |
---|
2553 | |
---|
2554 | // Set textures to mesh model. |
---|
2555 | void GeoMeshViewUI::setTextures() |
---|
2556 | { |
---|
2557 | GeoMaterialLoader *loader; |
---|
2558 | string filename; |
---|
2559 | string material; |
---|
2560 | |
---|
2561 | loader = new GeoMaterialLoader(); |
---|
2562 | |
---|
2563 | // For each submesh. |
---|
2564 | for (int submesh = 0; submesh < mGeoMesh->mSubMeshCount; submesh++) |
---|
2565 | { |
---|
2566 | material = string(mGeoMesh->mSubMesh[submesh].mMaterialName); |
---|
2567 | |
---|
2568 | if (loader->existsMaterial(material)) |
---|
2569 | { |
---|
2570 | // Debug. |
---|
2571 | cout << "Material " |
---|
2572 | << material |
---|
2573 | << " found." |
---|
2574 | << endl; |
---|
2575 | |
---|
2576 | filename = loader->getTextureFileName(material); |
---|
2577 | |
---|
2578 | // Debug. |
---|
2579 | cout << "File: " |
---|
2580 | << filename.c_str() |
---|
2581 | << endl; |
---|
2582 | |
---|
2583 | geoMeshView->LoadTextureSubMesh(submesh, filename.c_str()); |
---|
2584 | } |
---|
2585 | } |
---|
2586 | } |
---|
2587 | |
---|
2588 | //--------------------------------------------------------------------------- |
---|
2589 | // If file exists. |
---|
2590 | //--------------------------------------------------------------------------- |
---|
2591 | bool GeoMeshViewUI::fileExists(const char *fileNameMesh) |
---|
2592 | { |
---|
2593 | FILE *pFile; |
---|
2594 | |
---|
2595 | // Open the mesh file. |
---|
2596 | pFile = fopen(fileNameMesh, "r"); |
---|
2597 | |
---|
2598 | if (pFile) |
---|
2599 | { |
---|
2600 | return true; |
---|
2601 | } |
---|
2602 | else |
---|
2603 | { |
---|
2604 | return false; |
---|
2605 | } |
---|
2606 | } |
---|
2607 | |
---|
2608 | /******************/ |
---|
2609 | /* Constructor */ |
---|
2610 | /******************/ |
---|
2611 | GeoMeshViewUI::GeoMeshViewUI(TIPOFUNC fun) |
---|
2612 | { |
---|
2613 | progress_function = fun; |
---|
2614 | fltk::gifImage *logo; |
---|
2615 | |
---|
2616 | // Initialize the file name. |
---|
2617 | mFileName = NULL; |
---|
2618 | |
---|
2619 | // Initialize the 3D object. |
---|
2620 | mGeoMesh = NULL; |
---|
2621 | mUndoMesh = NULL; |
---|
2622 | |
---|
2623 | // Initialize the lod strip object. |
---|
2624 | lodStripsLib = NULL; |
---|
2625 | lodTreeLib = NULL; |
---|
2626 | |
---|
2627 | // Identify the mesh that stores the leaves |
---|
2628 | idMeshLeaves = -1; |
---|
2629 | |
---|
2630 | // Initialize the loader of meshes. |
---|
2631 | geoMeshLoader = new GeoMeshLoader(); |
---|
2632 | |
---|
2633 | // Initialize the menus application state. |
---|
2634 | mApplicationState = NONE; |
---|
2635 | |
---|
2636 | SubMeshNames=NULL; |
---|
2637 | |
---|
2638 | { |
---|
2639 | fltk::Window* o = new fltk::Window(800, 600,"GeoTool"); |
---|
2640 | |
---|
2641 | mMainWindow = o; |
---|
2642 | |
---|
2643 | // Program Icon for Win32. |
---|
2644 | mMainWindow->icon((char *)LoadIcon( GetModuleHandle(0), |
---|
2645 | MAKEINTRESOURCE(GEOICON))); |
---|
2646 | |
---|
2647 | // Double buffer. |
---|
2648 | mMainWindow->set_double_buffer(); |
---|
2649 | |
---|
2650 | o->user_data((void*)(this)); |
---|
2651 | o->begin(); |
---|
2652 | |
---|
2653 | { |
---|
2654 | fltk::Group* o = new fltk::Group(0, 27, 806, 559); |
---|
2655 | o->begin(); |
---|
2656 | |
---|
2657 | { |
---|
2658 | fltk::Group* o; |
---|
2659 | o = MainView = new fltk::Group(0, 0, 570, 530); |
---|
2660 | o->begin(); |
---|
2661 | |
---|
2662 | { |
---|
2663 | fltk::InvisibleBox* o; |
---|
2664 | o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); |
---|
2665 | o->box(fltk::FLAT_BOX); |
---|
2666 | o->color((fltk::Color)0xffffff00); |
---|
2667 | //fltk::Group::current()->resizable(o); |
---|
2668 | } |
---|
2669 | |
---|
2670 | { |
---|
2671 | GeoMeshView* o; |
---|
2672 | o = geoMeshView = new GeoMeshView( 0,0,570,530,0,this); |
---|
2673 | } |
---|
2674 | |
---|
2675 | o->end(); |
---|
2676 | |
---|
2677 | fltk::Group::current()->resizable(o); |
---|
2678 | |
---|
2679 | } |
---|
2680 | |
---|
2681 | { |
---|
2682 | fltk::Group* o; |
---|
2683 | o = MainView = new fltk::Group(570, 0, 230, 530); |
---|
2684 | o->begin(); |
---|
2685 | |
---|
2686 | { |
---|
2687 | fltk::Button* o; |
---|
2688 | //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); |
---|
2689 | o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); |
---|
2690 | o->callback((fltk::Callback*)cb_mButtonProcess); |
---|
2691 | o->hide(); |
---|
2692 | o->deactivate(); |
---|
2693 | } |
---|
2694 | |
---|
2695 | { |
---|
2696 | fltk::ProgressBar* o; |
---|
2697 | //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); |
---|
2698 | o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); |
---|
2699 | o->hide(); |
---|
2700 | o->deactivate(); |
---|
2701 | } |
---|
2702 | |
---|
2703 | { |
---|
2704 | fltk::Button* o; |
---|
2705 | o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); |
---|
2706 | o->callback((fltk::Callback*)cb_mButtonSort); |
---|
2707 | o->hide(); |
---|
2708 | o->deactivate(); |
---|
2709 | } |
---|
2710 | |
---|
2711 | { |
---|
2712 | fltk::ProgressBar* o; |
---|
2713 | o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); |
---|
2714 | o->hide(); |
---|
2715 | o->deactivate(); |
---|
2716 | } |
---|
2717 | |
---|
2718 | { |
---|
2719 | fltk::Button* o; |
---|
2720 | o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); |
---|
2721 | o->callback((fltk::Callback*)cb_mButtonBuild); |
---|
2722 | o->hide(); |
---|
2723 | o->deactivate(); |
---|
2724 | } |
---|
2725 | |
---|
2726 | { |
---|
2727 | fltk::ProgressBar* o; |
---|
2728 | o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); |
---|
2729 | o->hide(); |
---|
2730 | o->deactivate(); |
---|
2731 | } |
---|
2732 | |
---|
2733 | { |
---|
2734 | fltk::Slider* o; |
---|
2735 | o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); |
---|
2736 | o->type(fltk::Slider::TICK_BELOW); |
---|
2737 | o->set_vertical(); |
---|
2738 | o->callback((fltk::Callback*)cb_mLodStripSlider); |
---|
2739 | o->hide(); |
---|
2740 | o->deactivate(); |
---|
2741 | } |
---|
2742 | { |
---|
2743 | fltk::Slider* o; |
---|
2744 | o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); |
---|
2745 | o->type(fltk::Slider::TICK_BELOW); |
---|
2746 | o->set_vertical(); |
---|
2747 | o->callback((fltk::Callback*)cb_mLodTreeSlider); |
---|
2748 | o->hide(); |
---|
2749 | o->deactivate(); |
---|
2750 | } |
---|
2751 | |
---|
2752 | { |
---|
2753 | mMetricLabel = new fltk::Output(26, 28, 5, 25, "Metric"); |
---|
2754 | fltk::Output* o = mMetricLabel; |
---|
2755 | o->set_vertical(); |
---|
2756 | o->box(fltk::NO_BOX); |
---|
2757 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2758 | o->color((fltk::Color)0xe0dfe300); |
---|
2759 | o->align(fltk::ALIGN_RIGHT); |
---|
2760 | } |
---|
2761 | |
---|
2762 | { |
---|
2763 | fltk::Group* o; |
---|
2764 | o = MainView = new fltk::Group(30, 40, 30, 60); |
---|
2765 | o->begin(); |
---|
2766 | { |
---|
2767 | mGeometryBased = new fltk::RadioButton(0, 8, 25, 25, "Geometry based"); |
---|
2768 | mViewPointDriven = new fltk::RadioButton(0, 23, 25, 25, "Viewpoint driven"); |
---|
2769 | } |
---|
2770 | o->end(); |
---|
2771 | } |
---|
2772 | |
---|
2773 | //mChangeVertices = new fltk::CheckButton(30, 104, 25, 25, "Change vertices"); |
---|
2774 | |
---|
2775 | { |
---|
2776 | mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); |
---|
2777 | fltk::Widget* o = mProcessTitle; |
---|
2778 | o->set_vertical(); |
---|
2779 | o->box(fltk::NO_BOX); |
---|
2780 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2781 | o->labelsize(15.0); |
---|
2782 | o->color((fltk::Color)0xe0dfe300); |
---|
2783 | o->align(fltk::ALIGN_CENTER); |
---|
2784 | } |
---|
2785 | |
---|
2786 | /* |
---|
2787 | { |
---|
2788 | mTypeLabel = new fltk::Output(26, 82, 5, 25, "Type"); |
---|
2789 | fltk::Output* o = mTypeLabel; |
---|
2790 | o->set_vertical(); |
---|
2791 | o->box(fltk::NO_BOX); |
---|
2792 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2793 | o->color((fltk::Color)0xe0dfe300); |
---|
2794 | o->align(fltk::ALIGN_RIGHT); |
---|
2795 | } |
---|
2796 | */ |
---|
2797 | |
---|
2798 | { |
---|
2799 | mMeshReductionLabel = new fltk::Output(26, 124, 5, 25, "Mesh Reduction"); |
---|
2800 | fltk::Output* o = mMeshReductionLabel; |
---|
2801 | o->set_vertical(); |
---|
2802 | o->box(fltk::NO_BOX); |
---|
2803 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
2804 | o->color((fltk::Color)0xe0dfe300); |
---|
2805 | o->align(fltk::ALIGN_RIGHT); |
---|
2806 | } |
---|
2807 | |
---|
2808 | //mChangeTexture = new fltk::CheckButton(30, 104, 25, 25, "Change texture"); |
---|
2809 | |
---|
2810 | { |
---|
2811 | fltk::Group* o; |
---|
2812 | o = MainView = new fltk::Group(30, 140, 30, 60); |
---|
2813 | o->begin(); |
---|
2814 | |
---|
2815 | { |
---|
2816 | mPercent = new fltk::RadioButton(0, 5, 25, 25, "%"); |
---|
2817 | mVerticesNumber = new fltk::RadioButton(0, 20, 25, 25, "Vertices number"); |
---|
2818 | } |
---|
2819 | o->end(); |
---|
2820 | } |
---|
2821 | |
---|
2822 | { |
---|
2823 | mMeshReduction = new fltk::FloatInput(75, 181, 75, 21, "Value:"); |
---|
2824 | fltk::FloatInput* o = mMeshReduction; |
---|
2825 | o->type(1); |
---|
2826 | } |
---|
2827 | |
---|
2828 | { |
---|
2829 | fltk::Group* o; |
---|
2830 | o = MainView = new fltk::Group(30, 100, 30, 60); |
---|
2831 | o->begin(); |
---|
2832 | |
---|
2833 | { |
---|
2834 | mOneCacheStrip = new fltk::RadioButton(0, 4, 25, 25, "One cache strip"); |
---|
2835 | mQualityStrips = new fltk::RadioButton(0, 23, 25, 25, "Quality strips"); |
---|
2836 | } |
---|
2837 | o->end(); |
---|
2838 | } |
---|
2839 | |
---|
2840 | { |
---|
2841 | fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); |
---|
2842 | o->set_vertical(); |
---|
2843 | o->callback((fltk::Callback*)cb_mMeshInfo); |
---|
2844 | } |
---|
2845 | o->end(); |
---|
2846 | } |
---|
2847 | |
---|
2848 | o->end(); |
---|
2849 | |
---|
2850 | fltk::Group::current()->resizable(o); |
---|
2851 | } |
---|
2852 | |
---|
2853 | { |
---|
2854 | fltk::MenuBar* o = menuBar = new fltk::MenuBar(1, 2, 801, 21); |
---|
2855 | o->begin(); |
---|
2856 | |
---|
2857 | // Menu File. |
---|
2858 | { |
---|
2859 | fltk::ItemGroup* o = menuFile = new fltk::ItemGroup("File"); |
---|
2860 | o->begin(); |
---|
2861 | |
---|
2862 | { |
---|
2863 | fltk::Item* o = menuFileOpen = new fltk::Item("Open"); |
---|
2864 | o->callback((fltk::Callback*)cb_menuFileOpen); |
---|
2865 | } |
---|
2866 | |
---|
2867 | { |
---|
2868 | fltk::Item* o = menuFileSave = new fltk::Item("Save"); |
---|
2869 | o->callback((fltk::Callback*)cb_menuFileSave); |
---|
2870 | } |
---|
2871 | |
---|
2872 | { |
---|
2873 | fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); |
---|
2874 | o->callback((fltk::Callback*)cb_menuFileSaveAs); |
---|
2875 | } |
---|
2876 | |
---|
2877 | { |
---|
2878 | fltk::Item* o = menuMeshExportOBJ = new fltk::Item("Export to OBJ"); |
---|
2879 | o->callback((fltk::Callback*)cb_menuMeshExportOBJ); |
---|
2880 | } |
---|
2881 | |
---|
2882 | //{ |
---|
2883 | // fltk::Item* o = menuFileTransformSharedVertex = new fltk::Item("Transform to Shared Vertex"); |
---|
2884 | // o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex); |
---|
2885 | //} |
---|
2886 | |
---|
2887 | { |
---|
2888 | menuLoadTextures = new fltk::ItemGroup("Load Textures"); |
---|
2889 | o->add(menuLoadTextures); |
---|
2890 | } |
---|
2891 | |
---|
2892 | { |
---|
2893 | fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); |
---|
2894 | o->callback((fltk::Callback*)cb_menuFileQuit); |
---|
2895 | } |
---|
2896 | |
---|
2897 | o->end(); |
---|
2898 | } |
---|
2899 | |
---|
2900 | // Menu Edit. |
---|
2901 | { |
---|
2902 | fltk::ItemGroup* o = menuEdit = new fltk::ItemGroup("Edit"); |
---|
2903 | o->begin(); |
---|
2904 | |
---|
2905 | { |
---|
2906 | fltk::Item* o = menuEditUndo = new fltk::Item("Undo"); |
---|
2907 | o->callback((fltk::Callback*)cb_menuEditUndo); |
---|
2908 | } |
---|
2909 | |
---|
2910 | { |
---|
2911 | fltk::Item* o = menuEditFit = new fltk::Item("Fit"); |
---|
2912 | o->callback((fltk::Callback*)cb_menuEditFit); |
---|
2913 | |
---|
2914 | } |
---|
2915 | |
---|
2916 | { |
---|
2917 | fltk::Item* o = menuEditRotate = new fltk::Item("Rotate"); |
---|
2918 | o->type(fltk::Item::RADIO); |
---|
2919 | o->set_value(); |
---|
2920 | o->callback((fltk::Callback*)cb_menuEditRotate); |
---|
2921 | } |
---|
2922 | |
---|
2923 | { |
---|
2924 | fltk::Item* o = menuEditPan = new fltk::Item("Pan"); |
---|
2925 | o->type(fltk::Item::RADIO); |
---|
2926 | o->callback((fltk::Callback*)cb_menuEditPan); |
---|
2927 | } |
---|
2928 | |
---|
2929 | //{ |
---|
2930 | // fltk::Item* o = menuEditZoom = new fltk::Item("Zoom"); |
---|
2931 | // o->callback((fltk::Callback*)cb_menuEditZoom); |
---|
2932 | //} |
---|
2933 | |
---|
2934 | new fltk::Divider(); |
---|
2935 | |
---|
2936 | { |
---|
2937 | fltk::Item* o = menuMeshInfo = new fltk::Item("Mesh info"); |
---|
2938 | o->callback((fltk::Callback*)cb_menuMeshInfo); |
---|
2939 | } |
---|
2940 | |
---|
2941 | { |
---|
2942 | fltk::Item* o; |
---|
2943 | o = menuSelectLeaves = new fltk::Item("Select leaves"); |
---|
2944 | o->callback((fltk::Callback*)cb_menuSelectLeaves); |
---|
2945 | } |
---|
2946 | |
---|
2947 | o->end(); |
---|
2948 | } |
---|
2949 | |
---|
2950 | // Menu Render. |
---|
2951 | { |
---|
2952 | fltk::ItemGroup* o = menuRender = new fltk::ItemGroup("Render"); |
---|
2953 | o->begin(); |
---|
2954 | |
---|
2955 | { |
---|
2956 | fltk::Item* o = menuRenderWire = new fltk::Item("Wire"); |
---|
2957 | o->type(fltk::Item::RADIO); |
---|
2958 | o->callback((fltk::Callback*)cb_menuRenderWire); |
---|
2959 | } |
---|
2960 | |
---|
2961 | { |
---|
2962 | fltk::Item* o = menuRenderSolid = new fltk::Item("Solid"); |
---|
2963 | o->type(fltk::Item::RADIO); |
---|
2964 | o->callback((fltk::Callback*)cb_menuRenderSolid); |
---|
2965 | } |
---|
2966 | |
---|
2967 | //new fltk::Divider(); |
---|
2968 | |
---|
2969 | { |
---|
2970 | fltk::Item* o = menuRenderCW = new fltk::Item("CW"); |
---|
2971 | o->type(fltk::Item::RADIO); |
---|
2972 | o->callback((fltk::Callback*)cb_menuRenderCW); |
---|
2973 | |
---|
2974 | //o->hide(); |
---|
2975 | } |
---|
2976 | |
---|
2977 | { |
---|
2978 | fltk::Item* o = menuRenderCCW = new fltk::Item("CCW"); |
---|
2979 | o->type(fltk::Item::RADIO); |
---|
2980 | o->set_value(); |
---|
2981 | o->callback((fltk::Callback*)cb_menuRenderCCW); |
---|
2982 | |
---|
2983 | //o->hide(); |
---|
2984 | } |
---|
2985 | |
---|
2986 | new fltk::Divider(); |
---|
2987 | |
---|
2988 | { |
---|
2989 | fltk::Item* o = menuRenderFlat = new fltk::Item("Flat"); |
---|
2990 | o->type(fltk::Item::RADIO); |
---|
2991 | o->clear_value(); |
---|
2992 | o->callback((fltk::Callback*)cb_menuRenderFlat); |
---|
2993 | } |
---|
2994 | |
---|
2995 | { |
---|
2996 | fltk::Item* o = menuRenderSmooth = new fltk::Item("Smooth"); |
---|
2997 | o->type(fltk::Item::RADIO); |
---|
2998 | o->set_value(); |
---|
2999 | o->callback((fltk::Callback*)cb_menuRenderSmooth); |
---|
3000 | } |
---|
3001 | |
---|
3002 | new fltk::Divider(); |
---|
3003 | |
---|
3004 | { |
---|
3005 | fltk::Item* o = menuRenderTextures = new fltk::Item("Texture mapping"); |
---|
3006 | o->type(fltk::Item::RADIO); |
---|
3007 | o->set_value(); |
---|
3008 | o->callback((fltk::Callback*)cb_menuRenderTextures); |
---|
3009 | } |
---|
3010 | |
---|
3011 | o->end(); |
---|
3012 | } |
---|
3013 | |
---|
3014 | // Menu Stripify. |
---|
3015 | { |
---|
3016 | fltk::Item* o = menuStripify = new fltk::Item("Stripify"); |
---|
3017 | o->callback((fltk::Callback*)cb_menuStripify); |
---|
3018 | } |
---|
3019 | |
---|
3020 | // Menu Simplify. |
---|
3021 | { |
---|
3022 | fltk::ItemGroup* o = menuSimplify = new fltk::ItemGroup("Simplify"); |
---|
3023 | o->callback((fltk::Callback*)cb_menuSimplify); |
---|
3024 | o->begin(); |
---|
3025 | |
---|
3026 | { |
---|
3027 | fltk::Item* o; |
---|
3028 | o = menuSimplifyEdgeCollapse = new fltk::Item("Mesh Simplification"); |
---|
3029 | o->callback((fltk::Callback*)cb_menuSimplifyEdgeCollapse); |
---|
3030 | } |
---|
3031 | |
---|
3032 | { |
---|
3033 | fltk::Item* o; |
---|
3034 | o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification"); |
---|
3035 | o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse); |
---|
3036 | } |
---|
3037 | |
---|
3038 | o->end(); |
---|
3039 | } |
---|
3040 | |
---|
3041 | // Menu LodStrips. |
---|
3042 | { |
---|
3043 | fltk::ItemGroup* o; |
---|
3044 | o = menuLodStrips = new fltk::ItemGroup("LodStrips"); |
---|
3045 | o->begin(); |
---|
3046 | |
---|
3047 | { |
---|
3048 | fltk::Item* o; |
---|
3049 | o = menuLodStripsGenerate = new fltk::Item("Generate"); |
---|
3050 | o->callback((fltk::Callback*)cb_menuLodStripsGenerate); |
---|
3051 | } |
---|
3052 | |
---|
3053 | { |
---|
3054 | fltk::Item* o; |
---|
3055 | o = menuLodStripsVisualize = new fltk::Item("Visualize"); |
---|
3056 | o->callback((fltk::Callback*)cb_menuLodStripsVisualize); |
---|
3057 | } |
---|
3058 | |
---|
3059 | o->end(); |
---|
3060 | } |
---|
3061 | |
---|
3062 | // Menu LodTrees. |
---|
3063 | |
---|
3064 | { |
---|
3065 | fltk::ItemGroup* o; |
---|
3066 | o = menuLodTrees = new fltk::ItemGroup("LodTrees"); |
---|
3067 | o->begin(); |
---|
3068 | |
---|
3069 | { |
---|
3070 | fltk::Item* o; |
---|
3071 | o = menuLodTreesGenerate = new fltk::Item("Generate"); |
---|
3072 | o->callback((fltk::Callback*)cb_menuLodTreesGenerate); |
---|
3073 | } |
---|
3074 | { |
---|
3075 | fltk::Item* o; |
---|
3076 | o = menuLodTreesVisualize = new fltk::Item("Visualize"); |
---|
3077 | o->callback((fltk::Callback*)cb_menuLodTreesVisualize); |
---|
3078 | } |
---|
3079 | |
---|
3080 | o->end(); |
---|
3081 | } |
---|
3082 | |
---|
3083 | |
---|
3084 | { |
---|
3085 | fltk::ItemGroup* o = new fltk::ItemGroup("?"); |
---|
3086 | o->begin(); |
---|
3087 | |
---|
3088 | { |
---|
3089 | fltk::Item* o = menuHelpAbout = new fltk::Item("About"); |
---|
3090 | o->callback((fltk::Callback*)cb_menuHelpAbout); |
---|
3091 | } |
---|
3092 | |
---|
3093 | o->end(); |
---|
3094 | } |
---|
3095 | |
---|
3096 | /* { |
---|
3097 | fltk::SharedImage *gifLogo = logo->get("media\\logos\\logo.gif"); |
---|
3098 | |
---|
3099 | //o->callback((fltk::Callback*)cb_mLogo); |
---|
3100 | |
---|
3101 | mLogo = new fltk::InvisibleBox(406, 1, 43, 13); |
---|
3102 | mLogo->image(gifLogo); |
---|
3103 | }*/ |
---|
3104 | |
---|
3105 | o->end(); |
---|
3106 | } |
---|
3107 | |
---|
3108 | { |
---|
3109 | fltk::Group* o; |
---|
3110 | o = ApplicationBar = new fltk::Group(0, 570, 807, 28); |
---|
3111 | o->box(fltk::BORDER_BOX); |
---|
3112 | o->begin(); |
---|
3113 | |
---|
3114 | /* |
---|
3115 | { |
---|
3116 | fltk::Widget* o; |
---|
3117 | o = mFPS = new fltk::Widget(10, 4, 30, 15, "FPS "); |
---|
3118 | o->box(fltk::NO_BOX); |
---|
3119 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3120 | o->color((fltk::Color)0xe0dfe300); |
---|
3121 | } |
---|
3122 | */ |
---|
3123 | |
---|
3124 | { |
---|
3125 | fltk::Widget* o; |
---|
3126 | o = mVertices = new fltk::Widget(154, 4, 40, 15, "Vertices"); |
---|
3127 | o->box(fltk::NO_BOX); |
---|
3128 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3129 | o->color((fltk::Color)0xe0dfe300); |
---|
3130 | } |
---|
3131 | |
---|
3132 | { |
---|
3133 | fltk::Widget* o; |
---|
3134 | o = mTriangles = new fltk::Widget(254, 3, 40, 15, "Triangles"); |
---|
3135 | o->box(fltk::NO_BOX); |
---|
3136 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3137 | o->color((fltk::Color)0xe0dfe300); |
---|
3138 | |
---|
3139 | // Hide triangle count. |
---|
3140 | //o->hide(); |
---|
3141 | } |
---|
3142 | |
---|
3143 | { |
---|
3144 | fltk::Widget* o; |
---|
3145 | o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); |
---|
3146 | o->box(fltk::NO_BOX); |
---|
3147 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3148 | o->color((fltk::Color)0xe0dfe300); |
---|
3149 | } |
---|
3150 | |
---|
3151 | //{ |
---|
3152 | // fltk::Widget* o; |
---|
3153 | // o = mQuads = new fltk::Widget(454, 4, 40, 15, "Quads"); |
---|
3154 | // o->box(fltk::NO_BOX); |
---|
3155 | // o->labelfont(fltk::HELVETICA_BOLD); |
---|
3156 | // o->color((fltk::Color)0xe0dfe300); |
---|
3157 | //} |
---|
3158 | |
---|
3159 | { |
---|
3160 | fltk::Widget* o; |
---|
3161 | o = mMB = new fltk::Widget(740, 3, 30, 15, "MB"); |
---|
3162 | o->box(fltk::NO_BOX); |
---|
3163 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
3164 | o->color((fltk::Color)0xe0dfe300); |
---|
3165 | } |
---|
3166 | o->end(); |
---|
3167 | } |
---|
3168 | |
---|
3169 | |
---|
3170 | o->end(); |
---|
3171 | } |
---|
3172 | |
---|
3173 | fltk::focus(geoMeshView); |
---|
3174 | |
---|
3175 | |
---|
3176 | /*Hide Right Panel*/ |
---|
3177 | hideRightPanel(); |
---|
3178 | |
---|
3179 | mMainWindow->show(); |
---|
3180 | } |
---|
3181 | |
---|
3182 | /****************/ |
---|
3183 | /* Destroyer */ |
---|
3184 | /****************/ |
---|
3185 | GeoMeshViewUI::~GeoMeshViewUI() |
---|
3186 | { |
---|
3187 | delete geoMeshLoader; |
---|
3188 | mMainWindow->destroy(); |
---|
3189 | } |
---|
3190 | |
---|
3191 | // Shows the main window. |
---|
3192 | void GeoMeshViewUI::show() |
---|
3193 | { |
---|
3194 | } |
---|
3195 | |
---|
3196 | |
---|
3197 | void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void) |
---|
3198 | { |
---|
3199 | if (SubMeshNames) |
---|
3200 | { |
---|
3201 | menuLoadTextures->clear(); |
---|
3202 | for (int i=0; i<numSubMeshNames; i++) |
---|
3203 | { |
---|
3204 | delete[] SubMeshNames[i]; |
---|
3205 | } |
---|
3206 | delete[] SubMeshNames; |
---|
3207 | } |
---|
3208 | |
---|
3209 | menuFileLoadTexture = new fltk::Item("Entire model"); |
---|
3210 | menuFileLoadTexture->callback((fltk::Callback*)cb_menuFileLoadTexture); |
---|
3211 | menuLoadTextures->add(menuFileLoadTexture); |
---|
3212 | |
---|
3213 | numSubMeshNames=geoMeshView->getSubMeshCount(); |
---|
3214 | SubMeshNames=new char*[numSubMeshNames]; |
---|
3215 | |
---|
3216 | for (int i=0; i<numSubMeshNames; i++) |
---|
3217 | { |
---|
3218 | SubMeshNames[i]=new char[10]; |
---|
3219 | |
---|
3220 | sprintf(SubMeshNames[i],"submesh %d",i); |
---|
3221 | fltk::Item *item = new fltk::Item(SubMeshNames[i]); |
---|
3222 | item->callback((fltk::Callback*)cb_menuFileLoadTextureSubMesh); |
---|
3223 | menuLoadTextures->add(item); |
---|
3224 | } |
---|
3225 | } |
---|