source: trunk/src/testing/app/volvis/global.h @ 4

Revision 4, 8.5 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/********************************************************************************
2 * Volatile - Volume Visualization Software for SAGE
3 * Copyright (C) 2004 Electronic Visualization Laboratory,
4 * University of Illinois at Chicago
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above
14 *    copyright notice, this list of conditions and the following disclaimer
15 *    in the documentation and/or other materials provided with the distribution.
16 *  * Neither the name of the University of Illinois at Chicago nor
17 *    the names of its contributors may be used to endorse or promote
18 *    products derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Direct questions, comments etc about Volatile to www.evl.uic.edu/cavern/forum
33 *********************************************************************************/
34
35//Contains the global windowing parameters for the vol-a-tile app
36#ifndef __GLOBAL_H
37#define __GLOBAL_H
38
39#include "glUE.h"
40#include "vVolume.h"
41#include "Trackball.h"
42#include "vNet.h"
43#include <vector>
44class vPrimitive;
45typedef enum {
46        NONE=0,
47        AGAVE,
48        CROSSEYE
49} vStereoType;
50
51enum STEREOVIEW { LEFT, RIGHT};
52
53struct vWindow {  //Window size and location attributes
54        unsigned int    width;
55        unsigned int    displayWidth;  //for stereo etc
56        unsigned int    height;
57        unsigned int    xPos;
58        unsigned int    yPos;
59        float aspect;
60};
61
62struct vFrustum {
63        float left, right, top, bottom;
64};
65
66struct vViewport {
67        float x, y, width, height;
68};
69
70struct vStereo {
71        float                   halfEyeSep;
72        vStereoType             type;
73};
74
75typedef vector<vFrustum> vFrustumList;
76typedef vector<vViewport> vViewportList;
77struct vEnv {     //GL rendering Environment parameters
78        float                 eye[3];    // eye location
79        float                 at[3];     // lookat point
80        float                 up[3];     // up vector
81        // frustum[0] = left,   frustum[1] = right frustum[2] = bottom, frustum[3] = top
82        vFrustumList            frustumList;
83        vViewportList           viewportList;
84        float                 clip[2];   // clip[0] = front, clip[1] = back
85        float                 diff[4];   // diffuse color (material)
86        float                 spec[4];   // speculare color (material)
87        int                   bgColor;   // background color? 0==white 1==black
88        vStereoType     stereoType; //type of stereo, NONE, AGAVE, CROSSEYED
89        bool            renderOn;
90        bool            gameMode;
91};
92
93struct vLight{   //lighting information
94        float                 pos[3];    //light position
95        float                 startpos[3];
96};
97
98struct vCutTransform {
99        double rotn[16]; //just rotation
100        double transform[16]; //cumulative transform(with the volume)
101        double user[4]; //eqn of the cut plane
102        bool update;
103        float axis[3];
104        float angle;
105};
106
107struct vTransform{   //rendering transform parameters
108        float                 rotn[16];    //rotation from trackball
109        float                 scale;        //isotropic scale value
110        float                 trans[3];     //translation
111};
112
113struct vMouse{   //mouse state information
114        int                   button;  //GLUT mouse button
115        int                   state;   //GLUT mouse state
116        int                   pos[2];  //x,y
117        int                   last[2]; //last mouse position
118        int                   shift;   //is shift down
119        int                   ctrl;    //is control down
120        int                   alt;     //is alt down
121};
122
123struct vKey {     //key board state
124        unsigned char         key;     //GLUT key
125        int                   shift;   //is shift down
126        int                   ctrl;    //is control down
127        int                   alt;     //is alt down
128};
129
130
131struct vRen {  //volume rendering paramters
132        float                 sampleRate;   //current sample rate for rendering
133        float                 interactSamp; //interactive sample rate
134        float                 goodSamp;     //high quality sample rate
135        int                     lowRes;         //low res rendering
136        unsigned char        *deptex;       //2d dependent texture 256x256xRGBA [gb]
137        unsigned char* gDeptex; //this is recalculated from deptex above, alpha values are recalculated based on no of slices
138        unsigned char* iDeptex; //this is recalculated from deptex above
139        unsigned char* nDeptex; //this is recalculated from deptex above
140
141        float lastSamp;                 //last sample rate rendered
142        float lastGoodSamp;             //last good sample rate
143        float lastInteSamp;              //last interactive sample rate
144
145        int                   loadTLUT;     //reload the LUT if flag == 1
146        int                     loadVolume; //reload the volume if == 1
147        int                   scaleAlphas;  //scale alphas with sample rate
148        float                 gamma;        //constant alpha scale
149        int                     probe[3]; //the 3 points corresponding to the probe ptr
150        unsigned int    scaledDeptexName, origDeptexName;
151};
152
153typedef enum {
154        V_ROAM,
155        V_PROBE
156} vNav;
157
158struct vUI {
159        bool printFPS;
160        bool printSlices;
161        bool cutEnabled;
162        bool bboxEnabled;
163        vNav navMode;
164        bool animate;
165};
166
167
168typedef enum {  //Major axies of volume coords
169        V_Unknown,
170                V_XPos,
171                V_XNeg,
172                V_YPos,
173                V_YNeg,
174                V_ZPos,
175                V_ZNeg
176} VolRenMajorAxis;
177
178
179typedef enum {  //v Shade modes (shadows are handled by the light struct)
180                V_UNKNOWN,
181                V_AMBIENT,     //ambient
182                V_DIFFUSE,    //diffuse
183                V_DSPEC,   //diffuse + specular
184                V_FAUX,    //Faux shading
185                V_ARB,     //arbitrary shading via pixel texture
186                V_MIP
187} vShade;
188
189typedef enum {       //v platforms supported
190        GPGineric,         //default
191                GPNV20,            //-nv20 - 3D textures GeForce 3
192                GPATI8K            //ATI Radeon 8000 (R200)
193} vPlatform;
194
195
196typedef enum {
197        V_NONE,
198                V_UNDER,
199                V_OVER,
200                V_ZERO
201} vBlend;
202
203
204struct vGlobal {
205        int                     debug;
206        vWindow         win;    //window
207        vEnv            env;    //environment
208        vLight          light;  //light
209        vVolume         *volume ;//pointer to the data to be rendered
210        vVolume         *fullVolume;//pointer to the full volume
211        vMouse          mouse;  //mouse
212        vPlatform       plat;   //plaform
213        vRen            volren; //volume rendering stuff
214        int                     mainWindow;  //mainWindow Identifier
215        int                     tfWindow;  //mainWindow Identifier
216//      vShade          shade;       //shading enable/disable flag
217//      vBlend          reblend;     //re-render scene with blend
218        vStereo         stereo; //stereo params
219        vUI                     ui;
220        vCutTransform           cut;
221        float           pointerPos[3]; //posn of the pointer in world coords
222        int             curPrimIdx; //index of the primitive thats currently selected, -1 if nothing is selected
223};
224
225void drawText(GLfloat x, GLfloat y, GLfloat z, char *message);
226
227void    mouse(int button, int state, int x, int y); //mouse callback
228void    passiveMotion(int x, int y) ;
229void    motion(int x, int y);                       //motion callback
230void    key(unsigned char key, int x, int y);   //key callback
231void    special(int key, int x, int y);         //special key callback
232void    idle();                                 //idle callback
233void    reshape(int w, int h);                      //reshape callback
234void    initGlobal() ;
235void    display();
236void    displayOneEye(STEREOVIEW eye);
237void    displayOneEye(int,int);
238void    initGL();
239void    parseCmdLine(int, char**);
240void deallocateAll() ;
241void enableTex3D(unsigned int ); //opengl init before the render
242void disableTex3D(); //opengl stuff after the render
243
244void updateAnim(int value);
245void calcFrustum();
246
247extern vGlobal     global;
248extern Trackball        cutTrack;       //global trackball
249extern vector<vPrimitive*>   renderList; //all renderables attatch to this one
250extern vector<vPrimitive*>   selectList; //all renderables that can be selected
251
252#if defined(V_DISTRIBUTED)
253extern vNet* net;
254#endif
255
256#endif
257
258
Note: See TracBrowser for help on using the repository browser.