source: GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h @ 895

Revision 895, 5.9 KB checked in by gumbau, 18 years ago (diff)

Working LODTree constructor and visualizer

Line 
1// generated by Fast Light User Interface Designer (fluid) version 2.0100
2#ifndef GeoMeshView_h
3#define GeoMeshView_h
4
5#include        <fltk/events.h>
6#include        <stdlib.h>
7#include        <time.h>
8#include        <iostream>
9#include        <glut.h>
10#include        <fltk/GlWindow.h>
11#include        <GeoVertexBuffer.h>
12#include        <GeoMesh.h>
13//#ifndef       GeoMeshViewUI_h
14#include        <GeoMeshSaver.h>
15#include        <GeoMeshViewUI.h>
16
17//#endif
18namespace Geometry{ class LodTreeLibrary; }
19
20class GeoMeshView : public fltk::GlWindow
21{
22        friend  class   GeoMeshViewUI;
23
24        public:
25
26        // this value determines the scaling factor used to draw the cube.
27        double  size;
28        double  mScaleFactor;
29        bool            mWire;
30        bool            mSolid;
31        bool            mCW;
32        bool            mCCW;
33        bool            mPan;
34        bool            mRotate;
35        bool            mLodStrip;
36        bool            mLodTree;
37
38        GeoMeshView(int                                         x,
39                        int                                             y,
40                        int                                             w,
41                        int                                             h,
42                        const   char            *l                                                      =       0,
43                        GeoMeshViewUI   *geoMeshViewUI  =       0);
44
45        /*      This function is callalled by the zoom slider
46         *     
47         */
48        void scale(double factor){size  =       factor;};
49
50        /* Set the rotation about the vertical (y ) axis.
51         *
52         * This function is called by the horizontal roller in GeoMeshViewUI
53         * and the initialize button in GeoMeshViewUI.
54         */
55        void v_angle(float angle){vAng=angle;};
56       
57        // Return the rotation about the vertical (y ) axis.
58        float v_angle(){return vAng;};
59       
60        /* Set the rotation about the horizontal (x ) axis.
61         *
62         * This function is called by the vertical roller in GeoMeshViewUI
63         and the
64         * initialize button in GeoMeshViewUI.
65         */
66        void h_angle(float angle){hAng=angle;};
67       
68        // the rotation about the horizontal (x ) axis.
69        float h_angle(){return hAng;};
70       
71        /* Sets the x shift of the cube view camera.
72         *
73         * This function is called by the slider in GeoMeshViewUI and the
74         * initialize button in GeoMeshViewUI.
75         */
76        void panx(float x){xshift=x;};
77       
78        /* Sets the y shift of the cube view camera.
79         *
80         * This function is called by the slider in GeoMeshViewUI and the
81         * initialize button in GeoMeshViewUI.
82         */
83        void pany(float y){yshift=y;};
84
85        //      Wire model.
86        void    activeWire(){mWire      =       true;};
87        void    deactiveWire(){mWire    =       false;};
88
89        //      Solid model.
90        void    activeSolid(){mSolid    =       true;};
91        void    deactiveSolid(){mSolid  =       false;};
92
93        //      Clockwise mode.
94        void    activeCW(){mCW  =       true;};
95        void    deactiveCW(){mCW        =       false;};
96
97        //      Counter Clockwise mode.
98        void    activeCCW(){mCCW        =       true;}
99        void    deactiveCCW(){mCCW      =       false;}
100
101        //      Pan mode.
102        void    activePan(){mPan        =       true;}
103        void    deactivePan(){mPan      =       false;}
104
105        //      Rotate mode.
106        void    activeRotate(){mRotate  =       true;}
107        void    deactiveRotate(){mRotate        =       false;}
108
109        //      LodStrip mode.
110        void    activeLodStrip(){mLodStrip      =       true;}
111        void    deactiveLodStrip(){mLodStrip    =       false;}
112
113        //      LodTree mode.
114        void    activeLodTree(){mLodTree        =       true;}
115        void    deactiveLodTree(){mLodTree      =       false;}
116
117
118        //      Ilumination modes.
119        void    flat(){glShadeModel(GL_FLAT);};
120        void    smooth(){glShadeModel(GL_SMOOTH);};
121
122        //      Fits the object in the window view.
123        void    fit()
124        {
125                vAng            = 0.0;
126                hAng            =       0.0;
127                size            =       0.0;
128                xshift  =       0.0;
129                yshift  =       0.0;
130        };
131
132        /* Sets the Mesh to display.
133        */
134        void    setMesh(Geometry::Mesh  *geomesh);
135
136        /* The widget class draw() override.
137         * The draw() function initialize Gl for another round of
138         * drawing then calls specialized functions for drawing each
139         * of the entities displayed in the cube view.
140         */
141        void draw();
142
143        //      Gets the bounding box.
144        Geometry::GeometryBounds        getBoundingBox();
145
146        //      Store one random color to each strip.
147        void    setStripColors();
148
149        //      Get the number of frames per second.
150        size_t  getFPS();
151
152        //      JGA
153        //      Sets the colorsubmeshi variable
154        void    setColorSubmeshi(int submeshIndex);
155
156        //      Sets the leaves submesh index.
157        void    setLeavesSubmesh(int submeshIndex);
158
159        //      Gets the leaves submesh index.
160        int     getLeavesSubmesh();
161
162        //      Gets the triangle count of the current lod.
163        size_t  getLodStripsTriangleCount();
164       
165        //      Sets the lodstripslibrary object.
166        void    setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips);
167        //      Sets the lodtreeslibrary object.
168        void    setLodTreesLibrary(Geometry::LodTreeLibrary *lodtrees);
169
170        //      Change de Level of detail of the object.
171        void    GoToLod_LodStrip(unsigned int lod);
172        void    GoToLod_LodTree(unsigned int lod);
173
174        private:
175        /* Draw the cube boundaries
176         * Draw the faces of the cube using the boxv[] vertices, using
177         * GL_LINE_LOOP for the faces. The color is #defined by
178         * CUBECOLOR.
179         */
180
181        //      GeoMeshViewUI.
182        GeoMeshViewUI   *mGeoMeshViewUI;
183
184        //      LodStrips library object.
185        Geometry::LodStripsLibrary      *lodStripsLib;
186        //      LodTree library object.
187        Geometry::LodTreeLibrary        *lodTreeLib;
188       
189        //      Flag tha activate / deactivate the color strips.
190        bool    colorStripsFlag;
191
192        // Stores the index of the mesh to paint of red color.
193        int             colorsubmeshi;
194
195        //      Frames per second.
196        size_t  mFPS;
197
198        //      StartTime for FPS.
199        clock_t mStartTime;
200
201        float           xMed;
202        float           yMed;
203        float           zMed;
204
205        int                     leavesSubmesh;
206       
207        //      Submesh count.
208        int                     mSubMeshCount;
209
210        //      Mesh to show.
211        Geometry::Mesh  *geoMesh;
212
213        virtual int     handle(int event);
214
215        //      Paint the mesh object.
216        void    drawGeoMesh(int selectedMesh);
217        void    drawTriangleList(int submesh, bool selectedMesh);
218        void    drawTriangleStrip(int submesh);
219        void    drawLodStrip();
220        void    drawLodTree();
221        void    enableColorStrips();
222        void    disableColorStrips();
223        bool    getColorStrips();
224
225        //      Calculate the number of frames per second.
226        void    calcFPS();
227
228        //      Copy the mesh vertices to the vertex array.
229        void    refreshVertices(Geometry::Mesh  *geomesh);
230
231        float   vAng;
232        float   hAng;
233        float   xshift;
234        float   yshift;
235        int                     mMouseX;
236        int                     mMouseY;
237        int                     mSizeY;
238        GLfloat **mPosArray;
239        GLfloat **mNorArray;
240        GLfloat *mSharedPosArray;
241        GLfloat *mSharedNorArray;
242        GLuint  **mIndexArray;
243
244        struct  ColorElement
245        {
246                float   r;
247                float   g;
248                float   b;
249        };
250
251        ColorElement    **mStripColors;
252        int                                             mStripColorsCount;
253       
254        //      Idetifier of Visualization List.
255        GLuint  mIdVisualList;
256};
257
258#endif
259
Note: See TracBrowser for help on using the repository browser.