Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/vis12/doc/report/vr-lite.tex
ViewVC logotype

Annotation of /branches/vis12/doc/report/vr-lite.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1685 - (view) (download) (as text)

1 : jhr 335 \begin{lstlisting}[mathescape=true]
2 :     input string dataFile; // name of dataset
3 :     input real stepSz = 0.1; // size of steps
4 :     input vec3 eye; // location of eye point
5 :     input vec3 orig; // location of pixel (0,0)
6 :     input vec3 cVec; // vector between pixels horizontally
7 :     input vec3 rVec; // vector between pixels vertically
8 : jhr 371 input real opacMin; // highest value with opacity 0.0
9 :     input real opacMax; // lowest value with opacity 1.0
10 : jhr 335
11 :     image(3)[] img = load (dataFile);
12 : jhr 371 field#1(3)[] F = img $\circledast$ bspln3;
13 : jhr 335
14 : jhr 1116 strand RayCast (int row, int col)
15 : jhr 335 {
16 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
17 :     vec3 dir = (pos - eye)/|pos - eye|;
18 :     real t = 0.0;
19 :     real transp = 1.0;
20 :     real gray = 0.0;
21 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
22 :    
23 :     update {
24 :     pos = pos + stepSz*dir;
25 :     if (inside (pos,F)) {
26 : jhr 1116 real val = F(pos);
27 :     vec3 grad = $\nabla$F(pos);
28 : jhr 335 vec3 norm = -grad/|grad|;
29 : jhr 371 if (val > opacMin) { // we have some opacity
30 :     real opac = 1.0 if (val > opacMax)
31 :     else (val - opacMin)/(opacMax - opacMin);
32 :     gray = gray + transp*opac*max(0.0, -dir $\cdot$ norm);
33 : jhr 335 transp = transp*(1.0 - opac);
34 :     }
35 :     }
36 :     if (transp < 0.01) { // early ray termination
37 :     transp = 0.0;
38 :     stabilize;
39 :     }
40 : jhr 371 else if (t > 40.0)
41 : jhr 335 stabilize;
42 :     t = t + stepSz;
43 :     }
44 :    
45 :     stabilize {
46 :     rgba = [gray, gray, gray, 1.0-transp];
47 :     }
48 :     }
49 :    
50 :     initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];
51 :     \end{lstlisting}%

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0