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 697 - (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 : glk 697 real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
42 : glk 692 real camUmax = camVmax*real(imgResU)/real(imgResV);
43 :    
44 : glk 689 image(3)[] img = load (dataFile);
45 :     //field#2(3)[] F = img ⊛ bspln3;
46 :     field#0(3)[] F = img ⊛ tent;
47 :    
48 :     strand RayCast (int ui, int vi)
49 :     {
50 :     // HEY (want) would like to say:
51 :     // real rayU = lerp(-0.5, ui, imgResU-0.5, -camUmax, camUmax)
52 :     // HEY (BUG) C syntax error with "real(ui) - -0.5" vs "real(ui) + 0.5";
53 :     // generated C code looks like "(float)p_ui_0--0.5e0f"
54 :     real rayU = 2.0*camUmax*(real(ui) + 0.5)/real(imgResU) - camUmax;
55 :     real rayV = 2.0*camVmax*(real(vi) + 0.5)/real(imgResV) - camVmax;
56 : glk 692 vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
57 : glk 689
58 :     real rayN = camVspNear;
59 : glk 690 // ########## BEGIN per-ray initialization
60 : glk 689 output real maxval = 0.0;
61 : glk 690 // ########## END per-ray initialization
62 : glk 689
63 :     update
64 :     {
65 : glk 692 vec3 rayPos = camEye + rayN*rayVec;
66 : glk 689 if (inside (rayPos,F)) {
67 : glk 690 // ########## BEGIN per-sample code
68 : glk 689 maxval = max(maxval, F@rayPos);
69 : glk 690 // ########## END per-sample code
70 : glk 689 }
71 :     if (rayN > camVspFar)
72 :     stabilize;
73 :     rayN = rayN + rayStep;
74 :     }
75 :    
76 :     /* render: output maxval */
77 :     }
78 :    
79 :     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