[4] | 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>
|
---|
| 44 | class vPrimitive;
|
---|
| 45 | typedef enum {
|
---|
| 46 | NONE=0,
|
---|
| 47 | AGAVE,
|
---|
| 48 | CROSSEYE
|
---|
| 49 | } vStereoType;
|
---|
| 50 |
|
---|
| 51 | enum STEREOVIEW { LEFT, RIGHT};
|
---|
| 52 |
|
---|
| 53 | struct 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 |
|
---|
| 62 | struct vFrustum {
|
---|
| 63 | float left, right, top, bottom;
|
---|
| 64 | };
|
---|
| 65 |
|
---|
| 66 | struct vViewport {
|
---|
| 67 | float x, y, width, height;
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | struct vStereo {
|
---|
| 71 | float halfEyeSep;
|
---|
| 72 | vStereoType type;
|
---|
| 73 | };
|
---|
| 74 |
|
---|
| 75 | typedef vector<vFrustum> vFrustumList;
|
---|
| 76 | typedef vector<vViewport> vViewportList;
|
---|
| 77 | struct 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 |
|
---|
| 93 | struct vLight{ //lighting information
|
---|
| 94 | float pos[3]; //light position
|
---|
| 95 | float startpos[3];
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | struct 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 |
|
---|
| 107 | struct vTransform{ //rendering transform parameters
|
---|
| 108 | float rotn[16]; //rotation from trackball
|
---|
| 109 | float scale; //isotropic scale value
|
---|
| 110 | float trans[3]; //translation
|
---|
| 111 | };
|
---|
| 112 |
|
---|
| 113 | struct 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 |
|
---|
| 123 | struct 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 |
|
---|
| 131 | struct 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 |
|
---|
| 153 | typedef enum {
|
---|
| 154 | V_ROAM,
|
---|
| 155 | V_PROBE
|
---|
| 156 | } vNav;
|
---|
| 157 |
|
---|
| 158 | struct vUI {
|
---|
| 159 | bool printFPS;
|
---|
| 160 | bool printSlices;
|
---|
| 161 | bool cutEnabled;
|
---|
| 162 | bool bboxEnabled;
|
---|
| 163 | vNav navMode;
|
---|
| 164 | bool animate;
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | typedef 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 |
|
---|
| 179 | typedef 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 |
|
---|
| 189 | typedef enum { //v platforms supported
|
---|
| 190 | GPGineric, //default
|
---|
| 191 | GPNV20, //-nv20 - 3D textures GeForce 3
|
---|
| 192 | GPATI8K //ATI Radeon 8000 (R200)
|
---|
| 193 | } vPlatform;
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 | typedef enum {
|
---|
| 197 | V_NONE,
|
---|
| 198 | V_UNDER,
|
---|
| 199 | V_OVER,
|
---|
| 200 | V_ZERO
|
---|
| 201 | } vBlend;
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | struct 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 |
|
---|
| 225 | void drawText(GLfloat x, GLfloat y, GLfloat z, char *message);
|
---|
| 226 |
|
---|
| 227 | void mouse(int button, int state, int x, int y); //mouse callback
|
---|
| 228 | void passiveMotion(int x, int y) ;
|
---|
| 229 | void motion(int x, int y); //motion callback
|
---|
| 230 | void key(unsigned char key, int x, int y); //key callback
|
---|
| 231 | void special(int key, int x, int y); //special key callback
|
---|
| 232 | void idle(); //idle callback
|
---|
| 233 | void reshape(int w, int h); //reshape callback
|
---|
| 234 | void initGlobal() ;
|
---|
| 235 | void display();
|
---|
| 236 | void displayOneEye(STEREOVIEW eye);
|
---|
| 237 | void displayOneEye(int,int);
|
---|
| 238 | void initGL();
|
---|
| 239 | void parseCmdLine(int, char**);
|
---|
| 240 | void deallocateAll() ;
|
---|
| 241 | void enableTex3D(unsigned int ); //opengl init before the render
|
---|
| 242 | void disableTex3D(); //opengl stuff after the render
|
---|
| 243 |
|
---|
| 244 | void updateAnim(int value);
|
---|
| 245 | void calcFrustum();
|
---|
| 246 |
|
---|
| 247 | extern vGlobal global;
|
---|
| 248 | extern Trackball cutTrack; //global trackball
|
---|
| 249 | extern vector<vPrimitive*> renderList; //all renderables attatch to this one
|
---|
| 250 | extern vector<vPrimitive*> selectList; //all renderables that can be selected
|
---|
| 251 |
|
---|
| 252 | #if defined(V_DISTRIBUTED)
|
---|
| 253 | extern vNet* net;
|
---|
| 254 | #endif
|
---|
| 255 |
|
---|
| 256 | #endif
|
---|
| 257 |
|
---|
| 258 |
|
---|