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 | #ifndef _VRENDERER_H
|
---|
36 | #define _VRENDERER_H
|
---|
37 | #if _MSC_VER > 1000
|
---|
38 | #pragma once
|
---|
39 | #endif // _MSC_VER > 1000
|
---|
40 |
|
---|
41 | #include "global.h"
|
---|
42 | #include "vVolume.h"
|
---|
43 | #include "vCut.h"
|
---|
44 | #include "vPrimitive.h"
|
---|
45 | #include "vSliceView.h"
|
---|
46 | #define depX 256
|
---|
47 | #define depY 256
|
---|
48 | class vRenderer :public vPrimitive
|
---|
49 | {
|
---|
50 | public:
|
---|
51 | vRenderer();
|
---|
52 | virtual ~vRenderer();
|
---|
53 | //the volume to render
|
---|
54 | void setVolume(vVolume* theVolume) {
|
---|
55 | myVolume = theVolume;
|
---|
56 | }
|
---|
57 |
|
---|
58 | void init(); //primitive call-back
|
---|
59 | void draw(); //primitive call-back
|
---|
60 | void update(); //update the variables here - called every loop
|
---|
61 | int select() ;
|
---|
62 | inline void enableCut() {
|
---|
63 | cutEnabled = true;
|
---|
64 | }
|
---|
65 |
|
---|
66 | inline void disableCut() {
|
---|
67 | cutEnabled = false;
|
---|
68 | }
|
---|
69 | inline void enableShowOverview() {
|
---|
70 | showOverview = true;
|
---|
71 | }
|
---|
72 |
|
---|
73 | inline void disableShowOverview() {
|
---|
74 | showOverview = false;
|
---|
75 | }
|
---|
76 | void prev();
|
---|
77 | void next();
|
---|
78 |
|
---|
79 | private:
|
---|
80 | //loads the buffer to the texture mem
|
---|
81 | void loadTexture3D(unsigned char *tex, int sx, int sy, int sz);
|
---|
82 | //draw the bounding box
|
---|
83 | void drawBoundBox();
|
---|
84 | //draw the bounding box for the subvolume if any
|
---|
85 | void drawSubvolBoundBox();
|
---|
86 | //draws the 3 orthogonal slice views
|
---|
87 | void drawSliceView();
|
---|
88 | void renderAll(); //renders 3d texture, slice views, clip plane, bound box etc
|
---|
89 |
|
---|
90 |
|
---|
91 | //generic slice allong axis volume renderer
|
---|
92 | void renderTexture3D(float sampleFrequency,
|
---|
93 | GLdouble mv[16], //Model View Matrix
|
---|
94 | float vo[8][3], //volume vertex coords model-space coords
|
---|
95 | float tx[8][3], //texture vertex coords tex-space coords
|
---|
96 | float axis[3]); //axis to slice along world-space coords
|
---|
97 | //to render one slice -called in the loop from renderTexture3D
|
---|
98 | inline void renderSlice(int edges, float tc[6][3],float pc[6][3],int order[6]);
|
---|
99 | //does the intersection between a slice plane and the texture3D
|
---|
100 | inline int intersect(const float p0[3], const float p1[3], //line end points
|
---|
101 | const float t0[3], const float t1[3], //texture points
|
---|
102 | const float v0[3], const float v1[3], //view coord points
|
---|
103 | const float sp[3], const float sn[3], //plane point & norm
|
---|
104 | float pnew[3], float tnew[3], float vnew[3]); //new values
|
---|
105 |
|
---|
106 | //Dependant texture related functions
|
---|
107 | //loads a dependant texture(interactive or good) for CG to handle the map
|
---|
108 | void loadDepTex(unsigned int deptexName, unsigned char *dtex);
|
---|
109 | //takes the data from the 2d texture sent from the UI and copies it to the dependant texture(1D)
|
---|
110 | //that will be passed to CG
|
---|
111 | //For now, just extract the first row of the UI 2d texture to the dependant texture
|
---|
112 | //scale the alpha values depending on the sample rate
|
---|
113 | void copyScale(float sampleRate, unsigned char *cgTex);
|
---|
114 |
|
---|
115 | //---------------------member variables--------------
|
---|
116 | vVolume* myVolume; //pointer to the volume Im supposed to render
|
---|
117 | vCut cut; //cutting plane
|
---|
118 | vProbe volProbe; //probe for the volume
|
---|
119 | float xptr, yptr, zptr; //location of the probe in the volume
|
---|
120 | bool cutEnabled; //whether cutplane is enabled
|
---|
121 | bool showOverview; //show the subvolumes that are rendered
|
---|
122 | };
|
---|
123 |
|
---|
124 | #endif
|
---|