1 | // generated by Fast Light User Interface Designer (fluid) version 2.0100 |
---|
2 | #ifndef GeoMeshViewUI_h |
---|
3 | #define GeoMeshViewUI_h |
---|
4 | #include "GL/glew.h" |
---|
5 | #ifdef _WIN32 |
---|
6 | #include "GL/wglew.h" |
---|
7 | #endif |
---|
8 | #include <stdio.h> |
---|
9 | #include <stdlib.h> |
---|
10 | #include <string.h> |
---|
11 | #include <fltk/run.h> |
---|
12 | #include <fltk/Group.h> |
---|
13 | #include <fltk/Window.h> |
---|
14 | #include <fltk/ask.h> |
---|
15 | #include <fltk/file_chooser.h> |
---|
16 | #include <fltk/FileChooser.h> |
---|
17 | #include <fltk/MenuBar.h> |
---|
18 | #include <fltk/Input.h> |
---|
19 | #include <fltk/Button.h> |
---|
20 | #include <fltk/ReturnButton.h> |
---|
21 | #include <fltk/TextBuffer.h> |
---|
22 | #include <fltk/TextEditor.h> |
---|
23 | #include <fltk/Input.h> |
---|
24 | #include <fltk/events.h> |
---|
25 | #include <fltk/InvisibleBox.h> |
---|
26 | #include <fltk/ItemGroup.h> |
---|
27 | #include <fltk/Item.h> |
---|
28 | #include <fltk/Divider.h> |
---|
29 | #include <fltk/Output.h> |
---|
30 | #include <fltk/Button.h> |
---|
31 | #include <fltk/ProgressBar.h> |
---|
32 | #include <fltk/CheckButton.h> |
---|
33 | #include <fltk/RadioButton.h> |
---|
34 | #include <fltk/FloatInput.h> |
---|
35 | #include <fltk/Browser.h> |
---|
36 | #include <fltk/Image.h> |
---|
37 | #include <fltk/SharedImage.h> |
---|
38 | #include <fltk/Slider.h> |
---|
39 | #include <GeoMesh.h> |
---|
40 | #include <GeoLodStripsLibrary.h> |
---|
41 | #include <GeoMeshView.h> |
---|
42 | #include <GeoMeshSaver.h> |
---|
43 | #include <GeoMeshSimplifier.h> |
---|
44 | #include <GeoMeshStripifier.h> |
---|
45 | #include <GeoTreeSimplifier.h> |
---|
46 | #include "GeoTreeSimpSequence.h" |
---|
47 | #include "GeoLodStripsConstructor.h" |
---|
48 | #include "GeoLodTreeLibrary.h" |
---|
49 | |
---|
50 | // About Dialog. |
---|
51 | #include "GTAboutDialog.h" |
---|
52 | #include "../resource.h" |
---|
53 | |
---|
54 | #include <GeoMaterialLoader.h> |
---|
55 | |
---|
56 | // State of the button process. |
---|
57 | enum ProcessState |
---|
58 | { |
---|
59 | NONE, |
---|
60 | STRIPIFY, |
---|
61 | EDGE_COLLAPSE, |
---|
62 | LEAVES_COLLAPSE, |
---|
63 | LODSTRIPS, |
---|
64 | LODSTRIPS_AUTO, |
---|
65 | LODTREES, |
---|
66 | LODTREES_AUTO, |
---|
67 | SELECT_LEAVES, |
---|
68 | VISUALIZE_LODSTRIPS, |
---|
69 | VISUALIZE_LODTREES |
---|
70 | }; |
---|
71 | |
---|
72 | // Simplification types |
---|
73 | enum SimplificationType |
---|
74 | { |
---|
75 | NO_SIMPLIFICATION, |
---|
76 | MESHSIMP, |
---|
77 | HOJAS, |
---|
78 | VIEWPOINTDRIVEN |
---|
79 | }; |
---|
80 | |
---|
81 | enum ProgressBarType |
---|
82 | { |
---|
83 | PROCESS, |
---|
84 | BUILD |
---|
85 | }; |
---|
86 | |
---|
87 | using namespace Geometry; |
---|
88 | using namespace std; |
---|
89 | |
---|
90 | //----------------------------------------------------------------------------- |
---|
91 | //----------------------------------------------------------------------------- |
---|
92 | class GeoToolIndexData : public Geometry::IndexData |
---|
93 | { |
---|
94 | public: |
---|
95 | GeoToolIndexData(unsigned int submeshes):Geometry::IndexData(){ |
---|
96 | submeshcount = submeshes; |
---|
97 | indices=new unsigned int*[submeshcount]; |
---|
98 | indexCount=new unsigned int[submeshcount]; |
---|
99 | for (int i=0; i<submeshcount; i++) |
---|
100 | { |
---|
101 | indices[i]=NULL; |
---|
102 | indexCount[i]=0; |
---|
103 | } |
---|
104 | } |
---|
105 | virtual ~GeoToolIndexData(void){ |
---|
106 | for (int i=0; i<submeshcount; i++) |
---|
107 | if (indices[i]) |
---|
108 | delete[] indices[i]; |
---|
109 | delete[] indices; |
---|
110 | delete[] indexCount; |
---|
111 | } |
---|
112 | |
---|
113 | virtual void Begin(unsigned int submesh, unsigned int numinds){ |
---|
114 | if (indices[submesh]) |
---|
115 | delete[] indices[submesh]; |
---|
116 | indices[submesh] = new unsigned int[numinds]; |
---|
117 | indexCount[submesh] = numinds; |
---|
118 | modifySubmesh=submesh; |
---|
119 | } |
---|
120 | |
---|
121 | virtual void SetIndex(unsigned int i, unsigned int index){ |
---|
122 | assert(i<indexCount[modifySubmesh]); |
---|
123 | indices[modifySubmesh][i] = index; |
---|
124 | } |
---|
125 | |
---|
126 | virtual void End(void){} |
---|
127 | virtual void BorrowIndexData(const IndexData *){} |
---|
128 | |
---|
129 | unsigned int submeshcount; |
---|
130 | unsigned int **indices; |
---|
131 | unsigned int *indexCount; |
---|
132 | unsigned int modifySubmesh; |
---|
133 | }; |
---|
134 | |
---|
135 | //----------------------------------------------------------------------------- |
---|
136 | // Class User Interface of GeoTool. |
---|
137 | //----------------------------------------------------------------------------- |
---|
138 | class GeoMeshViewUI |
---|
139 | { |
---|
140 | friend class GeoMeshView; |
---|
141 | |
---|
142 | private: |
---|
143 | |
---|
144 | // File name Selected. |
---|
145 | char *mFileName; |
---|
146 | |
---|
147 | // The state of the application menus. |
---|
148 | ProcessState mApplicationState; |
---|
149 | |
---|
150 | // Mesh object(Model). |
---|
151 | Mesh *mGeoMesh; |
---|
152 | |
---|
153 | // Mesh for undo operation. |
---|
154 | Mesh *mUndoMesh; |
---|
155 | |
---|
156 | // Lod strips object. |
---|
157 | LodStripsLibrary *lodStripsLib; |
---|
158 | // Lod tree object. |
---|
159 | LodTreeLibrary *lodTreeLib; |
---|
160 | |
---|
161 | MeshSimplifier *mMeshSimplifier; |
---|
162 | TreeSimplifier *mTreeSimplifier; |
---|
163 | char *nombremesh; |
---|
164 | SimplificationType simplificationState; |
---|
165 | ProgressBarType progressBarType; |
---|
166 | |
---|
167 | MeshSimplificationSequence *oMeshSimpSequence; |
---|
168 | LodStripsConstructor *oLodStrip; |
---|
169 | GeoMeshLoader *geoMeshLoader; |
---|
170 | |
---|
171 | inline void cb_menuFileOpen_i(fltk::Item*, void*); |
---|
172 | static void cb_menuFileOpen(fltk::Item*, void*); |
---|
173 | inline void cb_menuFileSave_i(fltk::Item*, void*); |
---|
174 | static void cb_menuFileSave(fltk::Item*, void*); |
---|
175 | inline void cb_menuFileSaveAs_i(fltk::Item*, void*); |
---|
176 | static void cb_menuFileSaveAs(fltk::Item*, void*); |
---|
177 | inline void cb_menuFileLoadTexture_i(fltk::Item*, void*); |
---|
178 | static void cb_menuFileLoadTexture(fltk::Item*, void*); |
---|
179 | inline void cb_menuFileLoadTextureSubMesh_i(fltk::Item*, void*); |
---|
180 | static void cb_menuFileLoadTextureSubMesh(fltk::Item*, void*); |
---|
181 | |
---|
182 | inline void cb_menuMeshInfo_i(fltk::Item*, void*); |
---|
183 | static void cb_menuMeshInfo(fltk::Item*, void*); |
---|
184 | inline void cb_menuMeshExportOBJ_i(fltk::Item*, void*); |
---|
185 | static void cb_menuMeshExportOBJ(fltk::Item*, void*); |
---|
186 | inline void cb_menuTransformSharedVertex_i(fltk::Item*, void*); |
---|
187 | static void cb_menuFileTransformSharedVertex(fltk::Item* o, void* v); |
---|
188 | |
---|
189 | inline void cb_menuFileQuit_i(fltk::Item*, void*); |
---|
190 | static void cb_menuFileQuit(fltk::Item*, void*); |
---|
191 | inline void cb_menuEditUndo_i(fltk::Item*, void*); |
---|
192 | static void cb_menuEditUndo(fltk::Item*, void*); |
---|
193 | inline void cb_menuEditFit_i(fltk::Item*, void*); |
---|
194 | static void cb_menuEditFit(fltk::Item*, void*); |
---|
195 | inline void cb_menuEditRotate_i(fltk::Item*, void*); |
---|
196 | static void cb_menuEditRotate(fltk::Item*, void*); |
---|
197 | inline void cb_menuEditPan_i(fltk::Item*, void*); |
---|
198 | static void cb_menuEditPan(fltk::Item*, void*); |
---|
199 | inline void cb_menuEditZoom_i(fltk::Item*, void*); |
---|
200 | static void cb_menuEditZoom(fltk::Item*, void*); |
---|
201 | inline void cb_menuRenderWire_i(fltk::Item*, void*); |
---|
202 | static void cb_menuRenderWire(fltk::Item*, void*); |
---|
203 | inline void cb_menuRenderSolid_i(fltk::Item*, void*); |
---|
204 | static void cb_menuRenderSolid(fltk::Item*, void*); |
---|
205 | inline void cb_menuRenderLighting_i(fltk::Item*, void*); |
---|
206 | static void cb_menuRenderLighting(fltk::Item*, void*); |
---|
207 | inline void cb_menuRenderCW_i(fltk::Item*, void*); |
---|
208 | static void cb_menuRenderCW(fltk::Item*, void*); |
---|
209 | inline void cb_menuRenderCCW_i(fltk::Item*, void*); |
---|
210 | static void cb_menuRenderCCW(fltk::Item*, void*); |
---|
211 | inline void cb_menuRenderFlat_i(fltk::Item*, void*); |
---|
212 | static void cb_menuRenderFlat(fltk::Item*, void*); |
---|
213 | inline void cb_menuRenderSmooth_i(fltk::Item*, void*); |
---|
214 | static void cb_menuRenderSmooth(fltk::Item*, void*); |
---|
215 | inline void cb_menuRenderTextures_i(fltk::Item*, void*); |
---|
216 | static void cb_menuRenderTextures(fltk::Item*, void*); |
---|
217 | inline void cb_menuRenderBoundingBox_i(fltk::Item*, void*); |
---|
218 | static void cb_menuRenderBoundingBox(fltk::Item*, void*); |
---|
219 | inline void cb_menuRenderAxes_i(fltk::Item*, void*); |
---|
220 | static void cb_menuRenderAxes(fltk::Item*, void*); |
---|
221 | inline void cb_menuStripify_i(fltk::Item*, void*); |
---|
222 | static void cb_menuStripify(fltk::Item*, void*); |
---|
223 | inline void cb_menuSimplify_i(fltk::ItemGroup*, void*); |
---|
224 | static void cb_menuSimplify(fltk::ItemGroup*, void*); |
---|
225 | inline void cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*); |
---|
226 | static void cb_menuSimplifyEdgeCollapse(fltk::Item*, void*); |
---|
227 | inline void cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*); |
---|
228 | static void cb_menuSimplifyLeavesCollapse(fltk::Item*, void*); |
---|
229 | |
---|
230 | inline void cb_menuLodStripsGenerate_i(fltk::Item*, void*); |
---|
231 | static void cb_menuLodStripsGenerate(fltk::Item*, void*); |
---|
232 | inline void cb_menuLodStripsVisualize_i(fltk::Item*, void*); |
---|
233 | static void cb_menuLodStripsVisualize(fltk::Item*, void*); |
---|
234 | |
---|
235 | inline void cb_menuSelectLeaves_i(fltk::Item*, void*); |
---|
236 | static void cb_menuSelectLeaves(fltk::Item*, void*); |
---|
237 | inline void cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*); |
---|
238 | static void cb_menuLodTreesOpenLodStripTrunk(fltk::Item*, void*); |
---|
239 | inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); |
---|
240 | static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); |
---|
241 | inline void cb_menuLodTreesGenerate_i(fltk::Item*, void*); |
---|
242 | static void cb_menuLodTreesGenerate(fltk::Item*, void*); |
---|
243 | inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); |
---|
244 | static void cb_menuLodTreesVisualize(fltk::Item*, void*); |
---|
245 | inline void cb_menuHelpAbout_i(fltk::Item*, void*); |
---|
246 | static void cb_menuHelpAbout(fltk::Item*, void*); |
---|
247 | |
---|
248 | inline void cb_mButtonProcess_i(fltk::Button*, void*); |
---|
249 | static void cb_mButtonProcess(fltk::Button*, void*); |
---|
250 | inline void cb_mButtonSort_i(fltk::Button*, void*); |
---|
251 | static void cb_mButtonSort(fltk::Button*, void*); |
---|
252 | inline void cb_mButtonBuild_i(fltk::Button*, void*); |
---|
253 | static void cb_mButtonBuild(fltk::Button*, void*); |
---|
254 | inline void cb_mMeshInfo_i(fltk::Browser*, void*); |
---|
255 | static void cb_mMeshInfo(fltk::Browser*, void*); |
---|
256 | inline void cb_mLodStripSlider_i(fltk::Slider*, void*); |
---|
257 | static void cb_mLodStripSlider(fltk::Slider*, void*); |
---|
258 | inline void cb_mLodTreeSlider_i(fltk::Slider*, void*); |
---|
259 | static void cb_mLodTreeSlider(fltk::Slider*, void*); |
---|
260 | |
---|
261 | // Logo's callback. |
---|
262 | inline void cb_mLogo_i(fltk::InvisibleBox*, void*); |
---|
263 | static void cb_mLogo(fltk::InvisibleBox*, void*); |
---|
264 | |
---|
265 | // Shows build process. |
---|
266 | void activeBuildProcess(); |
---|
267 | |
---|
268 | // Shows the stripify panel. |
---|
269 | void showStripify(); |
---|
270 | |
---|
271 | // Shows the simplify panels. |
---|
272 | void showEdgeCollapse(); |
---|
273 | void showLeavesCollapse(); |
---|
274 | |
---|
275 | // Shows the LodStrips panels. |
---|
276 | void showOpenMeshSimplification(); |
---|
277 | void showAutoGenerateLodStrips(); |
---|
278 | void showAutoGenerateLodTrees(); |
---|
279 | |
---|
280 | // Shows the LodTrees panel. |
---|
281 | void showOpenLeavesSimplification(); |
---|
282 | |
---|
283 | // Show the mesh info browser. |
---|
284 | void showMeshInfo(); |
---|
285 | |
---|
286 | // Show the LodStrips visulization panel. |
---|
287 | void showLodStripSlider(); |
---|
288 | void showLodTreeSlider(); |
---|
289 | |
---|
290 | void hideStripify(); |
---|
291 | void hideEdgeCollapse(); |
---|
292 | void hideLeavesCollapse(); |
---|
293 | void hideOpenMeshSimplification(); |
---|
294 | void hideOpenLeavesSimplification(); |
---|
295 | void hideRightPanel(); |
---|
296 | // Hide the mesh info browser. |
---|
297 | void hideMeshInfo(); |
---|
298 | |
---|
299 | // Hide the LodStrips visualization panel. |
---|
300 | void hideLodStripSlider(); |
---|
301 | void hideLodTreeSlider(); |
---|
302 | |
---|
303 | // Get the number of vertices. |
---|
304 | size_t getVertexCount(Mesh *geoMesh); |
---|
305 | |
---|
306 | // Get the number of triangles. |
---|
307 | size_t getTriangleCount(Mesh *geoMesh); |
---|
308 | |
---|
309 | // Get the number of degenerated triangles. |
---|
310 | size_t getDegeneratedCount(Mesh *geoMesh); |
---|
311 | |
---|
312 | // Get the number of strips. |
---|
313 | size_t getStripCount(Mesh *geoMesh); |
---|
314 | |
---|
315 | int paintMesh(); |
---|
316 | |
---|
317 | // Simplify the mesh object. |
---|
318 | bool simplifyEdgeCollapse(); |
---|
319 | |
---|
320 | // Simplify the mesh object. |
---|
321 | void simplifyLeavesCollapse(); |
---|
322 | |
---|
323 | // Create a siplification sequence of the simplification method. |
---|
324 | void createSimplificationSequence(); |
---|
325 | |
---|
326 | // Create a siplification sequence of the leaves. |
---|
327 | void createLeavesSequence(const std::string &); |
---|
328 | |
---|
329 | // Stripify the mesh object. |
---|
330 | void stripify(); |
---|
331 | |
---|
332 | // Method that undo then mesh changes. |
---|
333 | void undo(); |
---|
334 | |
---|
335 | // Refresh number of vertices, triangles, strips, ... |
---|
336 | void refreshApplicationBar(); |
---|
337 | |
---|
338 | // Open a mesh file. |
---|
339 | void openMeshFile(void); |
---|
340 | |
---|
341 | // Check if file exists. |
---|
342 | bool fileExists(const char *fileNameMesh); |
---|
343 | |
---|
344 | // Set textures to mesh model. |
---|
345 | void setTextures(); |
---|
346 | |
---|
347 | // Write strips into a file. |
---|
348 | void writeStrips(Mesh *geomesh); |
---|
349 | |
---|
350 | public: |
---|
351 | |
---|
352 | // the indexdata for the LOD models |
---|
353 | GeoToolIndexData *lod_index_data; |
---|
354 | |
---|
355 | GeoMeshView *geoMeshView; |
---|
356 | fltk::Window *mMainWindow; |
---|
357 | fltk::Group *MainView; |
---|
358 | fltk::InvisibleBox *cframe; |
---|
359 | fltk::MenuBar *menuBar; |
---|
360 | fltk::ItemGroup *menuFile; |
---|
361 | fltk::Item *menuFileOpen; |
---|
362 | fltk::Item *menuFileSave; |
---|
363 | fltk::Item *menuFileSaveAs; |
---|
364 | fltk::Item *menuMeshInfo; |
---|
365 | fltk::Item *menuMeshExportOBJ; |
---|
366 | fltk::Item *menuFileTransformSharedVertex; |
---|
367 | fltk::ItemGroup *menuLoadTextures; |
---|
368 | fltk::Item *menuFileLoadTexture; |
---|
369 | |
---|
370 | fltk::Item *menuFileQuit; |
---|
371 | fltk::ItemGroup *menuEdit; |
---|
372 | fltk::Item *menuEditUndo; |
---|
373 | fltk::Item *menuEditFit; |
---|
374 | fltk::Item *menuEditRotate; |
---|
375 | fltk::Item *menuEditPan; |
---|
376 | fltk::Item *menuEditZoom; |
---|
377 | fltk::ItemGroup *menuRender; |
---|
378 | fltk::Item *menuRenderWire; |
---|
379 | fltk::Item *menuRenderSolid; |
---|
380 | fltk::Item *menuRenderLighting; |
---|
381 | fltk::Item *menuRenderCW; |
---|
382 | fltk::Item *menuRenderCCW; |
---|
383 | fltk::Item *menuRenderFlat; |
---|
384 | fltk::Item *menuRenderSmooth; |
---|
385 | fltk::Item *menuRenderTextures; |
---|
386 | fltk::Item *menuStripify; |
---|
387 | fltk::ItemGroup *menuSimplify; |
---|
388 | fltk::Item *menuSimplifyEdgeCollapse; |
---|
389 | fltk::Item *menuSimplifyLeavesCollapse; |
---|
390 | fltk::Item *menuSimplifySaveSequence; |
---|
391 | |
---|
392 | fltk::ItemGroup *menuLodStrips; |
---|
393 | fltk::Item *menuLodStripsGenerate; |
---|
394 | fltk::Item *menuLodStripsVisualize; |
---|
395 | fltk::ItemGroup *menuLodTrees; |
---|
396 | fltk::Item *menuLodTreesGenerate; |
---|
397 | fltk::Item *menuLodTreesVisualize; |
---|
398 | |
---|
399 | fltk::Item *menuSelectLeaves; |
---|
400 | fltk::Item *menuLodTreesOpenLodStripTrunk; |
---|
401 | fltk::Item *menuLodTreesOpenLeavesSimplification; |
---|
402 | fltk::Item *menuHelpAbout; |
---|
403 | fltk::InvisibleBox *mLogo; |
---|
404 | fltk::Group *ApplicationBar; |
---|
405 | fltk::Widget *mFPS; |
---|
406 | fltk::Widget *mVertices; |
---|
407 | fltk::Widget *mTriangles; |
---|
408 | fltk::Widget *mDegenerated; |
---|
409 | fltk::Widget *mStrips; |
---|
410 | fltk::Widget *mQuads; |
---|
411 | fltk::Widget *mMB; |
---|
412 | fltk::Button *mButtonProcess; |
---|
413 | fltk::ProgressBar *mProcessBar; |
---|
414 | fltk::Button *mButtonSort; |
---|
415 | fltk::ProgressBar *mSortBar; |
---|
416 | fltk::Button *mButtonBuild; |
---|
417 | fltk::ProgressBar *mBuildBar; |
---|
418 | fltk::Slider *mLodStripSlider; |
---|
419 | fltk::Slider *mLodTreeSlider; |
---|
420 | fltk::CheckButton *mGeometryBased; |
---|
421 | fltk::CheckButton *mViewPointDriven; |
---|
422 | fltk::CheckButton *mChangeVertices; |
---|
423 | fltk::CheckButton *mChangeTexture; |
---|
424 | fltk::CheckButton *mPercent; |
---|
425 | fltk::CheckButton *mVerticesNumber; |
---|
426 | fltk::CheckButton *mOneCacheStrip; |
---|
427 | fltk::CheckButton *mQualityStrips; |
---|
428 | fltk::FloatInput *mMeshReduction; |
---|
429 | fltk::Widget *mProcessTitle; |
---|
430 | fltk::Output *mMetricLabel; |
---|
431 | fltk::Output *mTypeLabel; |
---|
432 | fltk::Output *mMeshReductionLabel; |
---|
433 | fltk::Browser *mMeshInfo; |
---|
434 | fltk::ItemGroup *ogeometry; |
---|
435 | |
---|
436 | // Repaint the FPS label. |
---|
437 | void refreshFPS(int fps); |
---|
438 | |
---|
439 | // Initialize the lodstripslibrary for visualization. |
---|
440 | void setLodStripsLibrary(const Geometry::LodStripsLibraryData *, Mesh *geomesh); |
---|
441 | // Initialize the lodtreelibrary for visualization. |
---|
442 | void setLodTreesLibrary(const Geometry::LodStripsLibraryData *, const Geometry::TreeSimplificationSequence *, Mesh *geomesh/*, uint32 ileafSubMesh*/); |
---|
443 | |
---|
444 | // Indentify the mesh of leaves. |
---|
445 | unsigned short idMeshLeaves; |
---|
446 | |
---|
447 | GeoMeshViewUI(TIPOFUNC fun=NULL); |
---|
448 | ~GeoMeshViewUI(); |
---|
449 | void show(); |
---|
450 | |
---|
451 | TIPOFUNC progress_function; |
---|
452 | float updateProgressBar(float); |
---|
453 | |
---|
454 | void BuildLoadTextureSubMeshMenu(void); |
---|
455 | int numSubMeshNames; |
---|
456 | char **SubMeshNames; |
---|
457 | }; |
---|
458 | |
---|
459 | #endif |
---|
460 | |
---|