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