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