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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/mip-cam.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/mip-cam.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 964 - (view) (download)

1 : glk 689 // mip-cam
2 :     //
3 :     // initial demo of what could be boilerplate camera code,
4 :     // for maximum intensity projection
5 : glk 908 // process output with:
6 :     // unu reshape -i mip.txt -s 320 240 | unu quantize -b 8 -o mip-cam.png
7 : glk 689
8 : glk 908
9 : glk 689 //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 : glk 774 // HEY (want) it would be nice if we could have initializing statements...
32 :     // (though motivation for this here has been resolved)
33 : glk 776 real camDist = |camAt - camEye|;
34 :     real camVspNear = camNear + camDist;
35 :     real camVspFar = camFar + camDist;
36 :     vec3 camN = normalize(camAt - camEye);
37 : glk 774 vec3 camU = normalize(camN × camUp);
38 :     vec3 camV = camN × camU;
39 : glk 697 real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
40 : glk 692 real camUmax = camVmax*real(imgResU)/real(imgResV);
41 :    
42 : glk 689 image(3)[] img = load (dataFile);
43 :     //field#2(3)[] F = img ⊛ bspln3;
44 :     field#0(3)[] F = img ⊛ tent;
45 :    
46 :     strand RayCast (int ui, int vi)
47 :     {
48 : jhr 755 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 : glk 692 vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
51 : glk 689
52 :     real rayN = camVspNear;
53 : glk 690 // ########## BEGIN per-ray initialization
54 : glk 689 output real maxval = 0.0;
55 : glk 690 // ########## END per-ray initialization
56 : glk 689
57 :     update
58 :     {
59 : glk 692 vec3 rayPos = camEye + rayN*rayVec;
60 : glk 689 if (inside (rayPos,F)) {
61 : glk 690 // ########## BEGIN per-sample code
62 : glk 914 maxval = max(maxval, F(rayPos));
63 : glk 690 // ########## END per-sample code
64 : glk 689 }
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