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 | class GeoToolIndexData : public Geometry::IndexData |
---|
91 | { |
---|
92 | public: |
---|
93 | GeoToolIndexData(unsigned int submeshes):Geometry::IndexData(){ |
---|
94 | submeshcount = submeshes; |
---|
95 | indices=new unsigned int*[submeshcount]; |
---|
96 | indexCount=new unsigned int[submeshcount]; |
---|
97 | for (int i=0; i<submeshcount; i++) |
---|
98 | { |
---|
99 | indices[i]=NULL; |
---|
100 | indexCount[i]=0; |
---|
101 | } |
---|
102 | } |
---|
103 | virtual ~GeoToolIndexData(void){ |
---|
104 | for (int i=0; i<submeshcount; i++) |
---|
105 | if (indices[i]) |
---|
106 | delete[] indices[i]; |
---|
107 | delete[] indices; |
---|
108 | delete[] indexCount; |
---|
109 | } |
---|
110 | |
---|
111 | virtual void Begin(unsigned int submesh, unsigned int numinds){ |
---|
112 | if (indices[submesh]) |
---|
113 | delete[] indices[submesh]; |
---|
114 | indices[submesh] = new unsigned int[numinds]; |
---|
115 | indexCount[submesh] = numinds; |
---|
116 | modifySubmesh=submesh; |
---|
117 | } |
---|
118 | |
---|
119 | virtual void SetIndex(unsigned int i, unsigned int index){ |
---|
120 | assert(i<indexCount[modifySubmesh]); |
---|
121 | indices[modifySubmesh][i] = index; |
---|
122 | } |
---|
123 | |
---|
124 | virtual void End(void){} |
---|
125 | virtual void BorrowIndexData(const IndexData *){} |
---|
126 | |
---|
127 | unsigned int submeshcount; |
---|
128 | unsigned int **indices; |
---|
129 | unsigned int *indexCount; |
---|
130 | unsigned int modifySubmesh; |
---|
131 | }; |
---|
132 | |
---|
133 | class GeoMeshViewUI |
---|
134 | { |
---|
135 | friend class GeoMeshView; |
---|
136 | |
---|
137 | private: |
---|
138 | |
---|
139 | // File name Selected. |
---|
140 | char *mFileName; |
---|
141 | |
---|
142 | // The state of the application menus. |
---|
143 | ProcessState mApplicationState; |
---|
144 | |
---|
145 | // Mesh object(Model). |
---|
146 | Mesh *mGeoMesh; |
---|
147 | |
---|
148 | // Mesh for undo operation. |
---|
149 | Mesh *mUndoMesh; |
---|
150 | |
---|
151 | // Lod strips object. |
---|
152 | LodStripsLibrary *lodStripsLib; |
---|
153 | // Lod tree object. |
---|
154 | LodTreeLibrary *lodTreeLib; |
---|
155 | |
---|
156 | MeshSimplifier *mMeshSimplifier; |
---|
157 | TreeSimplifier *mTreeSimplifier; |
---|
158 | char *nombremesh; |
---|
159 | SimplificationType simplificationState; |
---|
160 | ProgressBarType progressBarType; |
---|
161 | |
---|
162 | MeshSimplificationSequence *oMeshSimpSequence; |
---|
163 | LodStripsConstructor *oLodStrip; |
---|
164 | GeoMeshLoader *geoMeshLoader; |
---|
165 | |
---|
166 | inline void cb_menuFileOpen_i(fltk::Item*, void*); |
---|
167 | static void cb_menuFileOpen(fltk::Item*, void*); |
---|
168 | inline void cb_menuFileSave_i(fltk::Item*, void*); |
---|
169 | static void cb_menuFileSave(fltk::Item*, void*); |
---|
170 | inline void cb_menuFileSaveAs_i(fltk::Item*, void*); |
---|
171 | static void cb_menuFileSaveAs(fltk::Item*, void*); |
---|
172 | inline void cb_menuFileLoadTexture_i(fltk::Item*, void*); |
---|
173 | static void cb_menuFileLoadTexture(fltk::Item*, void*); |
---|
174 | inline void cb_menuFileLoadTextureSubMesh_i(fltk::Item*, void*); |
---|
175 | static void cb_menuFileLoadTextureSubMesh(fltk::Item*, void*); |
---|
176 | |
---|
177 | inline void cb_menuMeshInfo_i(fltk::Item*, void*); |
---|
178 | static void cb_menuMeshInfo(fltk::Item*, void*); |
---|
179 | inline void cb_menuMeshExportOBJ_i(fltk::Item*, void*); |
---|
180 | static void cb_menuMeshExportOBJ(fltk::Item*, void*); |
---|
181 | inline void cb_menuTransformSharedVertex_i(fltk::Item*, void*); |
---|
182 | static void cb_menuFileTransformSharedVertex(fltk::Item* o, void* v); |
---|
183 | |
---|
184 | inline void cb_menuFileQuit_i(fltk::Item*, void*); |
---|
185 | static void cb_menuFileQuit(fltk::Item*, void*); |
---|
186 | inline void cb_menuEditUndo_i(fltk::Item*, void*); |
---|
187 | static void cb_menuEditUndo(fltk::Item*, void*); |
---|
188 | inline void cb_menuEditFit_i(fltk::Item*, void*); |
---|
189 | static void cb_menuEditFit(fltk::Item*, void*); |
---|
190 | inline void cb_menuEditRotate_i(fltk::Item*, void*); |
---|
191 | static void cb_menuEditRotate(fltk::Item*, void*); |
---|
192 | inline void cb_menuEditPan_i(fltk::Item*, void*); |
---|
193 | static void cb_menuEditPan(fltk::Item*, void*); |
---|
194 | inline void cb_menuEditZoom_i(fltk::Item*, void*); |
---|
195 | static void cb_menuEditZoom(fltk::Item*, void*); |
---|
196 | inline void cb_menuRenderWire_i(fltk::Item*, void*); |
---|
197 | static void cb_menuRenderWire(fltk::Item*, void*); |
---|
198 | inline void cb_menuRenderSolid_i(fltk::Item*, void*); |
---|
199 | static void cb_menuRenderSolid(fltk::Item*, void*); |
---|
200 | inline void cb_menuRenderCW_i(fltk::Item*, void*); |
---|
201 | static void cb_menuRenderCW(fltk::Item*, void*); |
---|
202 | inline void cb_menuRenderCCW_i(fltk::Item*, void*); |
---|
203 | static void cb_menuRenderCCW(fltk::Item*, void*); |
---|
204 | inline void cb_menuRenderFlat_i(fltk::Item*, void*); |
---|
205 | static void cb_menuRenderFlat(fltk::Item*, void*); |
---|
206 | inline void cb_menuRenderSmooth_i(fltk::Item*, void*); |
---|
207 | static void cb_menuRenderSmooth(fltk::Item*, void*); |
---|
208 | inline void cb_menuRenderTextures_i(fltk::Item*, void*); |
---|
209 | static void cb_menuRenderTextures(fltk::Item*, void*); |
---|
210 | inline void cb_menuStripify_i(fltk::Item*, void*); |
---|
211 | static void cb_menuStripify(fltk::Item*, void*); |
---|
212 | inline void cb_menuSimplify_i(fltk::ItemGroup*, void*); |
---|
213 | static void cb_menuSimplify(fltk::ItemGroup*, void*); |
---|
214 | inline void cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*); |
---|
215 | static void cb_menuSimplifyEdgeCollapse(fltk::Item*, void*); |
---|
216 | inline void cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*); |
---|
217 | static void cb_menuSimplifyLeavesCollapse(fltk::Item*, void*); |
---|
218 | |
---|
219 | inline void cb_menuLodStripsGenerate_i(fltk::Item*, void*); |
---|
220 | static void cb_menuLodStripsGenerate(fltk::Item*, void*); |
---|
221 | inline void cb_menuLodStripsVisualize_i(fltk::Item*, void*); |
---|
222 | static void cb_menuLodStripsVisualize(fltk::Item*, void*); |
---|
223 | |
---|
224 | inline void cb_menuSelectLeaves_i(fltk::Item*, void*); |
---|
225 | static void cb_menuSelectLeaves(fltk::Item*, void*); |
---|
226 | inline void cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*); |
---|
227 | static void cb_menuLodTreesOpenLodStripTrunk(fltk::Item*, void*); |
---|
228 | inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); |
---|
229 | static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); |
---|
230 | inline void cb_menuLodTreesGenerate_i(fltk::Item*, void*); |
---|
231 | static void cb_menuLodTreesGenerate(fltk::Item*, void*); |
---|
232 | inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); |
---|
233 | static void cb_menuLodTreesVisualize(fltk::Item*, void*); |
---|
234 | inline void cb_menuHelpAbout_i(fltk::Item*, void*); |
---|
235 | static void cb_menuHelpAbout(fltk::Item*, void*); |
---|
236 | |
---|
237 | inline void cb_mButtonProcess_i(fltk::Button*, void*); |
---|
238 | static void cb_mButtonProcess(fltk::Button*, void*); |
---|
239 | inline void cb_mButtonSort_i(fltk::Button*, void*); |
---|
240 | static void cb_mButtonSort(fltk::Button*, void*); |
---|
241 | inline void cb_mButtonBuild_i(fltk::Button*, void*); |
---|
242 | static void cb_mButtonBuild(fltk::Button*, void*); |
---|
243 | inline void cb_mMeshInfo_i(fltk::Browser*, void*); |
---|
244 | static void cb_mMeshInfo(fltk::Browser*, void*); |
---|
245 | inline void cb_mLodStripSlider_i(fltk::Slider*, void*); |
---|
246 | static void cb_mLodStripSlider(fltk::Slider*, void*); |
---|
247 | inline void cb_mLodTreeSlider_i(fltk::Slider*, void*); |
---|
248 | static void cb_mLodTreeSlider(fltk::Slider*, void*); |
---|
249 | |
---|
250 | // Logo's callback. |
---|
251 | inline void cb_mLogo_i(fltk::InvisibleBox*, void*); |
---|
252 | static void cb_mLogo(fltk::InvisibleBox*, void*); |
---|
253 | |
---|
254 | // Shows build process. |
---|
255 | void activeBuildProcess(); |
---|
256 | |
---|
257 | // Shows the stripify panel. |
---|
258 | void showStripify(); |
---|
259 | |
---|
260 | // Shows the simplify panels. |
---|
261 | void showEdgeCollapse(); |
---|
262 | void showLeavesCollapse(); |
---|
263 | |
---|
264 | // Shows the LodStrips panels. |
---|
265 | void showOpenMeshSimplification(); |
---|
266 | void showAutoGenerateLodStrips(); |
---|
267 | void showAutoGenerateLodTrees(); |
---|
268 | |
---|
269 | // Shows the LodTrees panel. |
---|
270 | void showOpenLeavesSimplification(); |
---|
271 | |
---|
272 | // Show the mesh info browser. |
---|
273 | void showMeshInfo(); |
---|
274 | |
---|
275 | // Show the LodStrips visulization panel. |
---|
276 | void showLodStripSlider(); |
---|
277 | void showLodTreeSlider(); |
---|
278 | |
---|
279 | void hideStripify(); |
---|
280 | void hideEdgeCollapse(); |
---|
281 | void hideLeavesCollapse(); |
---|
282 | void hideOpenMeshSimplification(); |
---|
283 | void hideOpenLeavesSimplification(); |
---|
284 | void hideRightPanel(); |
---|
285 | // Hide the mesh info browser. |
---|
286 | void hideMeshInfo(); |
---|
287 | |
---|
288 | // Hide the LodStrips visualization panel. |
---|
289 | void hideLodStripSlider(); |
---|
290 | void hideLodTreeSlider(); |
---|
291 | |
---|
292 | // Get the number of vertices. |
---|
293 | size_t getVertexCount(Mesh *geoMesh); |
---|
294 | |
---|
295 | // Get the number of triangles. |
---|
296 | size_t getTriangleCount(Mesh *geoMesh); |
---|
297 | |
---|
298 | // Get the number of strips. |
---|
299 | size_t getStripCount(Mesh *geoMesh); |
---|
300 | |
---|
301 | int paintMesh(); |
---|
302 | |
---|
303 | // Simplify the mesh object. |
---|
304 | bool simplifyEdgeCollapse(); |
---|
305 | |
---|
306 | // Simplify the mesh object. |
---|
307 | void simplifyLeavesCollapse(); |
---|
308 | |
---|
309 | // Create a siplification sequence of the simplification method. |
---|
310 | void createSimplificationSequence(); |
---|
311 | |
---|
312 | // Create a siplification sequence of the leaves. |
---|
313 | void createLeavesSequence(const std::string &); |
---|
314 | |
---|
315 | // Stripify the mesh object. |
---|
316 | void stripify(); |
---|
317 | |
---|
318 | // Method that undo then mesh changes. |
---|
319 | void undo(); |
---|
320 | |
---|
321 | // Refresh number of vertices, triangles, strips, ... |
---|
322 | void refreshApplicationBar(); |
---|
323 | |
---|
324 | // Open a mesh file. |
---|
325 | void openMeshFile(void); |
---|
326 | |
---|
327 | // Check if file exists. |
---|
328 | bool fileExists(const char *fileNameMesh); |
---|
329 | |
---|
330 | // Set textures to mesh model. |
---|
331 | void setTextures(); |
---|
332 | |
---|
333 | public: |
---|
334 | |
---|
335 | // the indexdata for the LOD models |
---|
336 | GeoToolIndexData *lod_index_data; |
---|
337 | |
---|
338 | GeoMeshView *geoMeshView; |
---|
339 | fltk::Window *mMainWindow; |
---|
340 | fltk::Group *MainView; |
---|
341 | fltk::InvisibleBox *cframe; |
---|
342 | fltk::MenuBar *menuBar; |
---|
343 | fltk::ItemGroup *menuFile; |
---|
344 | fltk::Item *menuFileOpen; |
---|
345 | fltk::Item *menuFileSave; |
---|
346 | fltk::Item *menuFileSaveAs; |
---|
347 | fltk::Item *menuMeshInfo; |
---|
348 | fltk::Item *menuMeshExportOBJ; |
---|
349 | fltk::Item *menuFileTransformSharedVertex; |
---|
350 | fltk::ItemGroup *menuLoadTextures; |
---|
351 | fltk::Item *menuFileLoadTexture; |
---|
352 | |
---|
353 | fltk::Item *menuFileQuit; |
---|
354 | fltk::ItemGroup *menuEdit; |
---|
355 | fltk::Item *menuEditUndo; |
---|
356 | fltk::Item *menuEditFit; |
---|
357 | fltk::Item *menuEditRotate; |
---|
358 | fltk::Item *menuEditPan; |
---|
359 | fltk::Item *menuEditZoom; |
---|
360 | fltk::ItemGroup *menuRender; |
---|
361 | fltk::Item *menuRenderWire; |
---|
362 | fltk::Item *menuRenderSolid; |
---|
363 | fltk::Item *menuRenderCW; |
---|
364 | fltk::Item *menuRenderCCW; |
---|
365 | fltk::Item *menuRenderFlat; |
---|
366 | fltk::Item *menuRenderSmooth; |
---|
367 | fltk::Item *menuRenderTextures; |
---|
368 | fltk::Item *menuStripify; |
---|
369 | fltk::ItemGroup *menuSimplify; |
---|
370 | fltk::Item *menuSimplifyEdgeCollapse; |
---|
371 | fltk::Item *menuSimplifyLeavesCollapse; |
---|
372 | fltk::Item *menuSimplifySaveSequence; |
---|
373 | |
---|
374 | fltk::ItemGroup *menuLodStrips; |
---|
375 | fltk::Item *menuLodStripsGenerate; |
---|
376 | fltk::Item *menuLodStripsVisualize; |
---|
377 | fltk::ItemGroup *menuLodTrees; |
---|
378 | fltk::Item *menuLodTreesGenerate; |
---|
379 | fltk::Item *menuLodTreesVisualize; |
---|
380 | |
---|
381 | fltk::Item *menuSelectLeaves; |
---|
382 | fltk::Item *menuLodTreesOpenLodStripTrunk; |
---|
383 | fltk::Item *menuLodTreesOpenLeavesSimplification; |
---|
384 | fltk::Item *menuHelpAbout; |
---|
385 | fltk::InvisibleBox *mLogo; |
---|
386 | fltk::Group *ApplicationBar; |
---|
387 | fltk::Widget *mFPS; |
---|
388 | fltk::Widget *mVertices; |
---|
389 | fltk::Widget *mTriangles; |
---|
390 | fltk::Widget *mStrips; |
---|
391 | fltk::Widget *mQuads; |
---|
392 | fltk::Widget *mMB; |
---|
393 | fltk::Button *mButtonProcess; |
---|
394 | fltk::ProgressBar *mProcessBar; |
---|
395 | fltk::Button *mButtonSort; |
---|
396 | fltk::ProgressBar *mSortBar; |
---|
397 | fltk::Button *mButtonBuild; |
---|
398 | fltk::ProgressBar *mBuildBar; |
---|
399 | fltk::Slider *mLodStripSlider; |
---|
400 | fltk::Slider *mLodTreeSlider; |
---|
401 | fltk::CheckButton *mGeometryBased; |
---|
402 | fltk::CheckButton *mViewPointDriven; |
---|
403 | fltk::CheckButton *mChangeVertices; |
---|
404 | fltk::CheckButton *mChangeTexture; |
---|
405 | fltk::CheckButton *mPercent; |
---|
406 | fltk::CheckButton *mVerticesNumber; |
---|
407 | fltk::CheckButton *mOneCacheStrip; |
---|
408 | fltk::CheckButton *mQualityStrips; |
---|
409 | fltk::FloatInput *mMeshReduction; |
---|
410 | fltk::Widget *mProcessTitle; |
---|
411 | fltk::Output *mMetricLabel; |
---|
412 | fltk::Output *mTypeLabel; |
---|
413 | fltk::Output *mMeshReductionLabel; |
---|
414 | fltk::Browser *mMeshInfo; |
---|
415 | fltk::ItemGroup *ogeometry; |
---|
416 | |
---|
417 | // Repaint the FPS label. |
---|
418 | void refreshFPS(int fps); |
---|
419 | |
---|
420 | // Initialize the lodstripslibrary for visualization. |
---|
421 | void setLodStripsLibrary(const Geometry::LodStripsLibraryData *, Mesh *geomesh); |
---|
422 | // Initialize the lodtreelibrary for visualization. |
---|
423 | void setLodTreesLibrary(const Geometry::LodStripsLibraryData *, const Geometry::TreeSimplificationSequence *, Mesh *geomesh/*, uint32 ileafSubMesh*/); |
---|
424 | |
---|
425 | // Indentify the mesh of leaves. |
---|
426 | unsigned short idMeshLeaves; |
---|
427 | |
---|
428 | GeoMeshViewUI(TIPOFUNC fun=NULL); |
---|
429 | ~GeoMeshViewUI(); |
---|
430 | void show(); |
---|
431 | |
---|
432 | TIPOFUNC progress_function; |
---|
433 | float updateProgressBar(float); |
---|
434 | |
---|
435 | void BuildLoadTextureSubMeshMenu(void); |
---|
436 | int numSubMeshNames; |
---|
437 | char **SubMeshNames; |
---|
438 | }; |
---|
439 | |
---|
440 | #endif |
---|
441 | |
---|