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

SCM Repository

[diderot] Annotation of /trunk/test/mip-cam.diderot
ViewVC logotype

Annotation of /trunk/test/mip-cam.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2636 - (view) (download)

1 : jhr 1115 // mip-cam
2 :     //
3 :     // initial demo of what could be boilerplate camera code,
4 :     // for maximum intensity projection
5 :     // process output with:
6 :     // unu reshape -i mip.txt -s 320 240 | unu quantize -b 8 -o mip-cam.png
7 :    
8 :    
9 :     //string dataFile = "../data/txs-pad3.nrrd";
10 :     //vec3 camEye = [25.0, 15.0, 10.0];
11 :     //vec3 camAt = [3.0, 3.0, 3.0];
12 :     //vec3 camUp = [0.0, 0.0, 1.0];
13 :     //real camNear = -5.0;
14 :     //real camFar = 5.0;
15 :     //real camFOV = 18.0;
16 :     //int imgResU = 320;
17 :     //int imgResV = 240;
18 :     //real rayStep = 0.1;
19 :    
20 :     string dataFile = "../data/vfrhand-nohip.nhdr";
21 :     vec3 camEye = [127.331, -1322.05, 272.53];
22 :     vec3 camAt = [63.0, 82.6536, 101.999];
23 :     vec3 camUp = [0.9987, 0.0459166, -0.0221267];
24 :     real camNear = -78.0;
25 :     real camFar = 78.0;
26 :     real camFOV = 5.0;
27 :     int imgResU = 320;
28 :     int imgResV = 240;
29 :     real rayStep = 1.0;
30 :    
31 :     // HEY (want) it would be nice if we could have initializing statements...
32 :     // (though motivation for this here has been resolved)
33 :     real camDist = |camAt - camEye|;
34 :     real camVspNear = camNear + camDist;
35 :     real camVspFar = camFar + camDist;
36 :     vec3 camN = normalize(camAt - camEye);
37 :     vec3 camU = normalize(camN × camUp);
38 :     vec3 camV = camN × camU;
39 :     real camVmax = tan(camFOV*π/360.0)*camDist;
40 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
41 :    
42 : jhr 2636 image(3)[] img = image (dataFile);
43 : jhr 1115 //field#2(3)[] F = img ⊛ bspln3;
44 :     field#0(3)[] F = img ⊛ tent;
45 :    
46 :     strand RayCast (int ui, int vi)
47 :     {
48 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
49 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
50 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
51 :    
52 :     real rayN = camVspNear;
53 :     // ########## BEGIN per-ray initialization
54 :     output real maxval = 0.0;
55 :     // ########## END per-ray initialization
56 :    
57 :     update
58 :     {
59 :     vec3 rayPos = camEye + rayN*rayVec;
60 :     if (inside (rayPos,F)) {
61 :     // ########## BEGIN per-sample code
62 :     maxval = max(maxval, F(rayPos));
63 :     // ########## END per-sample code
64 :     }
65 :     if (rayN > camVspFar)
66 :     stabilize;
67 :     rayN = rayN + rayStep;
68 :     }
69 :    
70 :     /* render: output maxval */
71 :     }
72 :    
73 :     initially [ RayCast(ui, vi) | vi in 0..(imgResV-1), ui in 0..(imgResU-1) ];

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