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

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

Added LodTreeLibrary? working only for trunks

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(unsigned int lod);
172
173        private:
174        /* Draw the cube boundaries
175         * Draw the faces of the cube using the boxv[] vertices, using
176         * GL_LINE_LOOP for the faces. The color is #defined by
177         * CUBECOLOR.
178         */
179
180        //      GeoMeshViewUI.
181        GeoMeshViewUI   *mGeoMeshViewUI;
182
183        //      LodStrips library object.
184        Geometry::LodStripsLibrary      *lodStripsLib;
185        //      LodTree library object.
186        Geometry::LodTreeLibrary        *lodTreeLib;
187       
188        //      Flag tha activate / deactivate the color strips.
189        bool    colorStripsFlag;
190
191        // Stores the index of the mesh to paint of red color.
192        int             colorsubmeshi;
193
194        //      Frames per second.
195        size_t  mFPS;
196
197        //      StartTime for FPS.
198        clock_t mStartTime;
199
200        float           xMed;
201        float           yMed;
202        float           zMed;
203
204        int                     leavesSubmesh;
205       
206        //      Submesh count.
207        int                     mSubMeshCount;
208
209        //      Mesh to show.
210        Geometry::Mesh  *geoMesh;
211
212        virtual int     handle(int event);
213
214        //      Paint the mesh object.
215        void    drawGeoMesh(int selectedMesh);
216        void    drawTriangleList(int submesh, bool selectedMesh);
217        void    drawTriangleStrip(int submesh);
218        void    drawLodStrip();
219        void    drawLodTree();
220        void    enableColorStrips();
221        void    disableColorStrips();
222        bool    getColorStrips();
223
224        //      Calculate the number of frames per second.
225        void    calcFPS();
226
227        //      Copy the mesh vertices to the vertex array.
228        void    refreshVertices(Geometry::Mesh  *geomesh);
229
230        float   vAng;
231        float   hAng;
232        float   xshift;
233        float   yshift;
234        int                     mMouseX;
235        int                     mMouseY;
236        int                     mSizeY;
237        GLfloat **mPosArray;
238        GLfloat **mNorArray;
239        GLfloat *mSharedPosArray;
240        GLfloat *mSharedNorArray;
241        GLuint  **mIndexArray;
242
243        struct  ColorElement
244        {
245                float   r;
246                float   g;
247                float   b;
248        };
249
250        ColorElement    **mStripColors;
251        int                                             mStripColorsCount;
252       
253        //      Idetifier of Visualization List.
254        GLuint  mIdVisualList;
255};
256
257#endif
258
Note: See TracBrowser for help on using the repository browser.