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 strips. |
---|
310 | size_t getStripCount(Mesh *geoMesh); |
---|
311 | |
---|
312 | int paintMesh(); |
---|
313 | |
---|
314 | // Simplify the mesh object. |
---|
315 | bool simplifyEdgeCollapse(); |
---|
316 | |
---|
317 | // Simplify the mesh object. |
---|
318 | void simplifyLeavesCollapse(); |
---|
319 | |
---|
320 | // Create a siplification sequence of the simplification method. |
---|
321 | void createSimplificationSequence(); |
---|
322 | |
---|
323 | // Create a siplification sequence of the leaves. |
---|
324 | void createLeavesSequence(const std::string &); |
---|
325 | |
---|
326 | // Stripify the mesh object. |
---|
327 | void stripify(); |
---|
328 | |
---|
329 | // Method that undo then mesh changes. |
---|
330 | void undo(); |
---|
331 | |
---|
332 | // Refresh number of vertices, triangles, strips, ... |
---|
333 | void refreshApplicationBar(); |
---|
334 | |
---|
335 | // Open a mesh file. |
---|
336 | void openMeshFile(void); |
---|
337 | |
---|
338 | // Check if file exists. |
---|
339 | bool fileExists(const char *fileNameMesh); |
---|
340 | |
---|
341 | // Set textures to mesh model. |
---|
342 | void setTextures(); |
---|
343 | |
---|
344 | public: |
---|
345 | |
---|
346 | // the indexdata for the LOD models |
---|
347 | GeoToolIndexData *lod_index_data; |
---|
348 | |
---|
349 | GeoMeshView *geoMeshView; |
---|
350 | fltk::Window *mMainWindow; |
---|
351 | fltk::Group *MainView; |
---|
352 | fltk::InvisibleBox *cframe; |
---|
353 | fltk::MenuBar *menuBar; |
---|
354 | fltk::ItemGroup *menuFile; |
---|
355 | fltk::Item *menuFileOpen; |
---|
356 | fltk::Item *menuFileSave; |
---|
357 | fltk::Item *menuFileSaveAs; |
---|
358 | fltk::Item *menuMeshInfo; |
---|
359 | fltk::Item *menuMeshExportOBJ; |
---|
360 | fltk::Item *menuFileTransformSharedVertex; |
---|
361 | fltk::ItemGroup *menuLoadTextures; |
---|
362 | fltk::Item *menuFileLoadTexture; |
---|
363 | |
---|
364 | fltk::Item *menuFileQuit; |
---|
365 | fltk::ItemGroup *menuEdit; |
---|
366 | fltk::Item *menuEditUndo; |
---|
367 | fltk::Item *menuEditFit; |
---|
368 | fltk::Item *menuEditRotate; |
---|
369 | fltk::Item *menuEditPan; |
---|
370 | fltk::Item *menuEditZoom; |
---|
371 | fltk::ItemGroup *menuRender; |
---|
372 | fltk::Item *menuRenderWire; |
---|
373 | fltk::Item *menuRenderSolid; |
---|
374 | fltk::Item *menuRenderLighting; |
---|
375 | fltk::Item *menuRenderCW; |
---|
376 | fltk::Item *menuRenderCCW; |
---|
377 | fltk::Item *menuRenderFlat; |
---|
378 | fltk::Item *menuRenderSmooth; |
---|
379 | fltk::Item *menuRenderTextures; |
---|
380 | fltk::Item *menuStripify; |
---|
381 | fltk::ItemGroup *menuSimplify; |
---|
382 | fltk::Item *menuSimplifyEdgeCollapse; |
---|
383 | fltk::Item *menuSimplifyLeavesCollapse; |
---|
384 | fltk::Item *menuSimplifySaveSequence; |
---|
385 | |
---|
386 | fltk::ItemGroup *menuLodStrips; |
---|
387 | fltk::Item *menuLodStripsGenerate; |
---|
388 | fltk::Item *menuLodStripsVisualize; |
---|
389 | fltk::ItemGroup *menuLodTrees; |
---|
390 | fltk::Item *menuLodTreesGenerate; |
---|
391 | fltk::Item *menuLodTreesVisualize; |
---|
392 | |
---|
393 | fltk::Item *menuSelectLeaves; |
---|
394 | fltk::Item *menuLodTreesOpenLodStripTrunk; |
---|
395 | fltk::Item *menuLodTreesOpenLeavesSimplification; |
---|
396 | fltk::Item *menuHelpAbout; |
---|
397 | fltk::InvisibleBox *mLogo; |
---|
398 | fltk::Group *ApplicationBar; |
---|
399 | fltk::Widget *mFPS; |
---|
400 | fltk::Widget *mVertices; |
---|
401 | fltk::Widget *mTriangles; |
---|
402 | fltk::Widget *mStrips; |
---|
403 | fltk::Widget *mQuads; |
---|
404 | fltk::Widget *mMB; |
---|
405 | fltk::Button *mButtonProcess; |
---|
406 | fltk::ProgressBar *mProcessBar; |
---|
407 | fltk::Button *mButtonSort; |
---|
408 | fltk::ProgressBar *mSortBar; |
---|
409 | fltk::Button *mButtonBuild; |
---|
410 | fltk::ProgressBar *mBuildBar; |
---|
411 | fltk::Slider *mLodStripSlider; |
---|
412 | fltk::Slider *mLodTreeSlider; |
---|
413 | fltk::CheckButton *mGeometryBased; |
---|
414 | fltk::CheckButton *mViewPointDriven; |
---|
415 | fltk::CheckButton *mChangeVertices; |
---|
416 | fltk::CheckButton *mChangeTexture; |
---|
417 | fltk::CheckButton *mPercent; |
---|
418 | fltk::CheckButton *mVerticesNumber; |
---|
419 | fltk::CheckButton *mOneCacheStrip; |
---|
420 | fltk::CheckButton *mQualityStrips; |
---|
421 | fltk::FloatInput *mMeshReduction; |
---|
422 | fltk::Widget *mProcessTitle; |
---|
423 | fltk::Output *mMetricLabel; |
---|
424 | fltk::Output *mTypeLabel; |
---|
425 | fltk::Output *mMeshReductionLabel; |
---|
426 | fltk::Browser *mMeshInfo; |
---|
427 | fltk::ItemGroup *ogeometry; |
---|
428 | |
---|
429 | // Repaint the FPS label. |
---|
430 | void refreshFPS(int fps); |
---|
431 | |
---|
432 | // Initialize the lodstripslibrary for visualization. |
---|
433 | void setLodStripsLibrary(const Geometry::LodStripsLibraryData *, Mesh *geomesh); |
---|
434 | // Initialize the lodtreelibrary for visualization. |
---|
435 | void setLodTreesLibrary(const Geometry::LodStripsLibraryData *, const Geometry::TreeSimplificationSequence *, Mesh *geomesh/*, uint32 ileafSubMesh*/); |
---|
436 | |
---|
437 | // Indentify the mesh of leaves. |
---|
438 | unsigned short idMeshLeaves; |
---|
439 | |
---|
440 | GeoMeshViewUI(TIPOFUNC fun=NULL); |
---|
441 | ~GeoMeshViewUI(); |
---|
442 | void show(); |
---|
443 | |
---|
444 | TIPOFUNC progress_function; |
---|
445 | float updateProgressBar(float); |
---|
446 | |
---|
447 | void BuildLoadTextureSubMeshMenu(void); |
---|
448 | int numSubMeshNames; |
---|
449 | char **SubMeshNames; |
---|
450 | }; |
---|
451 | |
---|
452 | #endif |
---|
453 | |
---|