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 776 - (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 774 // HEY (want) it would be nice if we could have initializing statements...
29 :     // (though motivation for this here has been resolved)
30 : glk 776 real camDist = |camAt - camEye|;
31 :     real camVspNear = camNear + camDist;
32 :     real camVspFar = camFar + camDist;
33 :     vec3 camN = normalize(camAt - camEye);
34 : glk 774 vec3 camU = normalize(camN × camUp);
35 :     vec3 camV = camN × camU;
36 : glk 697 real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
37 : glk 692 real camUmax = camVmax*real(imgResU)/real(imgResV);
38 :    
39 : glk 689 image(3)[] img = load (dataFile);
40 :     //field#2(3)[] F = img ⊛ bspln3;
41 :     field#0(3)[] F = img ⊛ tent;
42 :    
43 :     strand RayCast (int ui, int vi)
44 :     {
45 : jhr 755 real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
46 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
47 : glk 764 // HEY (BUG) C syntax error;
48 : glk 689 // generated C code looks like "(float)p_ui_0--0.5e0f"
49 : glk 764 //real rayU = 2.0*camUmax*(real(ui) - -0.5)/real(imgResU) - camUmax;
50 :     //real rayV = 2.0*camVmax*(real(vi) - -0.5)/real(imgResV) - camVmax;
51 : glk 692 vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
52 : glk 689
53 :     real rayN = camVspNear;
54 : glk 690 // ########## BEGIN per-ray initialization
55 : glk 689 output real maxval = 0.0;
56 : glk 690 // ########## END per-ray initialization
57 : glk 689
58 :     update
59 :     {
60 : glk 692 vec3 rayPos = camEye + rayN*rayVec;
61 : glk 689 if (inside (rayPos,F)) {
62 : glk 690 // ########## BEGIN per-sample code
63 : glk 689 maxval = max(maxval, F@rayPos);
64 : glk 690 // ########## END per-sample code
65 : glk 689 }
66 :     if (rayN > camVspFar)
67 :     stabilize;
68 :     rayN = rayN + rayStep;
69 :     }
70 :    
71 :     /* render: output maxval */
72 :     }
73 :    
74 :     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