-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNV20VolRen3D-2-old.h
137 lines (112 loc) · 5.75 KB
/
NV20VolRen3D-2-old.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// ________ ____ ___
// | \ / | / /
// +---+ \/ |/ /
// +--+| |\ /| <
// | || | \ / | |\ \
// | | \/ | | \ \
// \_____| |__| \__\
// Copyright 2001
// Joe Michael Kniss
// << jmk@cs.utah.edu >>
// "All Your Base are Belong to Us"
//-------------------------------------------------------------------------
// NV20VolRen3D.h: interface for the NV20VolRen3D class.
// Basic shadowing volume renderer
//////////////////////////////////////////////////////////////////////
#ifndef NV20VolRen3D2_DOT_H
#define NV20VolRen3D2_DOT_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "gluvvPrimitive.h"
#include "gluvv.h"
#include "pbuffer.h"
class NV20VolRen3D2 : public gluvvPrimitive
{
public:
NV20VolRen3D2();
virtual ~NV20VolRen3D2();
void init(); //primitive call-back
void draw(); //primitive call-back
void createVolumes(); //load volumes
private:
//void createTrexVols(); //old version, do not use
void createBricks(); //use this one, handles multiple bricks & single volumes
void loadTex1B(unsigned char *tex, unsigned int name, int sx, int sy, int sz);
void loadTex2B(unsigned char *tex, unsigned int name, int sx, int sy, int sz);
void loadTex4B(unsigned char *tex, unsigned int name, int sx, int sy, int sz);
void create2DDepTex(); //creates the dependant textures
void loadDepTex(unsigned char *dtex); //loads a dependant texture [deptex name]
void loadDepTex(unsigned char *dtex, unsigned int name); //loads data into texture name
void createShadowTex(); //creates the shadow texture
void scaleAlpha(float nsr, float osr, unsigned char *dtex); //rescale alpha values to sample rate
void copyScale(float sr, unsigned char *dtex); //scale and copy to a 2d texture
//----------- test render -
void renderSlice(); //tests dependant textures
//----------- real renderer -
void renderVolume(); //sets up volume rendering and then renders
void renderSlice(float corners[4][3], int vol); //render slice with constant alpha
void setupShaders(); //sets up texture shaders, tex-units & dep tex reads
void resetShaders(); //resets tex-units and turns off texture shaders
void setupRegComb(float ftb); //sets up register combiners for shading and blending (<0 ftb, >0 btf)
void resetRegComb(); //turns off register combiners
void setupPBuff(); //prepare pbuffer for rendering
//----------- clipping planes
void setupClips(int vol,float vo[8][3], float tx[8][3]); //orthogonal clipping, changes volume dims
void drawClip(int vol, float dotv, //draws clip slice
float wmv[16]); //world model view
void resetClips(); //turns off clipping
//the axis in this has a 4th value which is the dotproduct of the light and view directions
void renderBricks(GLdouble mv[16], GLfloat axis[4]); //renders multiple sub vols & single vol
//----------- gineric slice allong axis volume renderer
void render3DVA(float sampleFrequency,
GLdouble mv[16], //Model View Matrix
unsigned int v, //3D textures name
float vo[8][3], //volume vertex coords model-space coords
float tx[8][3], //texture vertex coords tex-space coords
float axis[4]); //axis to slice along world-space coords axis[3] = dot(view, light)
//----------- interect for render3DVA
inline int intersect(
const float p0[3], const float p1[3], //line end points
const float t0[3], const float t1[3], //texture points
const float v0[3], const float v1[3], //view coord points
const float sp[3], const float sn[3], //plane point & norm
float pnew[3], float tnew[3], float vnew[3]); //new values
//----------- an inner loop renderer for render3DVA
inline void volSlice(int edges,
float tc[6][3],
float pc[6][3],
int order[6]);
inline void volShadow(int edges,
float tc[6][3],
float pc[6][3],
int order[6],
float ltxf[16],
int vol);
int go; //if everything is ok, you can render
int sx, sy, sz; //not used anymore, get info from meta volume
unsigned int *texNames; //bricked data names
unsigned int *shadeNames; //bricked shade names
unsigned int shadowName; //shadow texture
unsigned int *qnNames; //not used qn sucks
unsigned int deptexName; //VG dep tex [gb]
unsigned int deptex2Name; //H dep tex [ar]
unsigned int qnDeptexName; //not used qn sucks
unsigned char *deptex; //dep tex data [gb]
unsigned char *deptex2; //dep tex2 data [ar]
unsigned char *gDeptex; //dep tex scaled to good sample rate [gb]
unsigned char *iDeptex; //dep tex scaled to interactive sample rate [gb]
unsigned char *qnDeptex; //not used qn sucks
float *qnRef; //again not used...
float lastSamp; //last sample rate rendered
float lastGoodSamp; //last good sample rate
float lastInteSamp; //last interactive sample rate
PBuffer *pbuff; //pbuffer for rendering light's point of view
void MakeCurrent();
//----- some shadow data ------
float xscale;
float yscale;
float xbias;
float ybias;
};
#endif // !defined(AFX_NV20VOLREN3D_H__F0928F0F_2C8C_47F5_95AD_59CBF70749C9__INCLUDED_)