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 692 - (view) (download)

1 : glk 689 // mip-cam
2 :     //
3 :     // initial demo of what could be boilerplate camera code,
4 :     // for maximum intensity projection
5 :    
6 :     //string dataFile = "../data/txs-pad3.nrrd";
7 :     //vec3 camEye = [25.0, 15.0, 10.0];
8 :     //vec3 camAt = [3.0, 3.0, 3.0];
9 :     //vec3 camUp = [0.0, 0.0, 1.0];
10 :     //real camNear = -5.0;
11 :     //real camFar = 5.0;
12 :     //real camFOV = 18.0;
13 :     //int imgResU = 320;
14 :     //int imgResV = 240;
15 :     //real rayStep = 0.1;
16 :    
17 :     string dataFile = "../data/vfrhand-nohip.nhdr";
18 :     vec3 camEye = [127.331, -1322.05, 272.53];
19 :     vec3 camAt = [63.0, 82.6536, 101.999];
20 :     vec3 camUp = [0.9987, 0.0459166, -0.0221267];
21 :     real camNear = -78.0;
22 :     real camFar = 78.0;
23 :     real camFOV = 5.0;
24 :     int imgResU = 320;
25 :     int imgResV = 240;
26 :     real rayStep = 1.0;
27 :    
28 : glk 692 real camDist = |camAt - camEye|;
29 :     real camVspNear = camDist + camNear;
30 :     real camVspFar = camDist + camFar;
31 :     vec3 camN = (camAt - camEye)/camDist;
32 :     // HEY (want) camN × camUp;
33 :     vec3 camTmpV = cross(camN,camUp);
34 :     // HEY (want) it would be nice if we could have initializing statements
35 :     // here; I had to create camTmpV to normalize the cross product, having
36 :     // chosen not to use "cross(camN,camUp)/|cross(camN,camUp)|".
37 :     // In this particular case, could also use
38 :     // "vec3 camU = normalize(cross(camN,camUp))"
39 :     vec3 camU = camTmpV/|camTmpV|;
40 :     vec3 camV = cross(camN,camU);
41 :     // HEY (want) sin()/cos() --> tan(), when tan() exists
42 :     real camTmpR = camFOV*3.1415926536/360.0;
43 :     real camVmax = sin(camTmpR)/cos(camTmpR)*camDist;
44 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
45 :    
46 : glk 689 image(3)[] img = load (dataFile);
47 :     //field#2(3)[] F = img ⊛ bspln3;
48 :     field#0(3)[] F = img ⊛ tent;
49 :    
50 :     strand RayCast (int ui, int vi)
51 :     {
52 :     // HEY (want) would like to say:
53 :     // real rayU = lerp(-0.5, ui, imgResU-0.5, -camUmax, camUmax)
54 :     // HEY (BUG) C syntax error with "real(ui) - -0.5" vs "real(ui) + 0.5";
55 :     // generated C code looks like "(float)p_ui_0--0.5e0f"
56 :     real rayU = 2.0*camUmax*(real(ui) + 0.5)/real(imgResU) - camUmax;
57 :     real rayV = 2.0*camVmax*(real(vi) + 0.5)/real(imgResV) - camVmax;
58 : glk 692 vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
59 : glk 689
60 :     real rayN = camVspNear;
61 : glk 690 // ########## BEGIN per-ray initialization
62 : glk 689 output real maxval = 0.0;
63 : glk 690 // ########## END per-ray initialization
64 : glk 689
65 :     update
66 :     {
67 : glk 692 vec3 rayPos = camEye + rayN*rayVec;
68 : glk 689 if (inside (rayPos,F)) {
69 : glk 690 // ########## BEGIN per-sample code
70 : glk 689 maxval = max(maxval, F@rayPos);
71 : glk 690 // ########## END per-sample code
72 : glk 689 }
73 :     if (rayN > camVspFar)
74 :     stabilize;
75 :     rayN = rayN + rayStep;
76 :     }
77 :    
78 :     /* render: output maxval */
79 :     }
80 :    
81 :     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