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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 697 - (download) (annotate)
Fri Mar 25 18:29:35 2011 UTC (8 years, 9 months ago) by glk
File size: 2518 byte(s)
now using tan()
// mip-cam
//
// initial demo of what could be boilerplate camera code, 
// for maximum intensity projection

//string dataFile = "../data/txs-pad3.nrrd";
//vec3 camEye = [25.0, 15.0, 10.0];
//vec3 camAt = [3.0, 3.0, 3.0];
//vec3 camUp = [0.0, 0.0, 1.0];
//real camNear = -5.0;
//real camFar = 5.0;
//real camFOV = 18.0;
//int imgResU = 320;
//int imgResV = 240;
//real rayStep = 0.1;

string dataFile = "../data/vfrhand-nohip.nhdr";
vec3 camEye = [127.331, -1322.05, 272.53];
vec3 camAt = [63.0, 82.6536, 101.999];
vec3 camUp = [0.9987, 0.0459166, -0.0221267];
real camNear = -78.0;
real camFar = 78.0;
real camFOV = 5.0;
int imgResU = 320;
int imgResV = 240;
real rayStep = 1.0;

real camDist = |camAt - camEye|;
real camVspNear = camDist + camNear;
real camVspFar = camDist + camFar;
vec3 camN = (camAt - camEye)/camDist;
// HEY (want) camN × camUp;
vec3 camTmpV = cross(camN,camUp); 
// HEY (want) it would be nice if we could have initializing statements
// here; I had to create camTmpV to normalize the cross product, having
// chosen not to use "cross(camN,camUp)/|cross(camN,camUp)|".
// In this particular case, could also use
// "vec3 camU = normalize(cross(camN,camUp))"
vec3 camU = camTmpV/|camTmpV|;
vec3 camV = cross(camN,camU);
real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
real camUmax = camVmax*real(imgResU)/real(imgResV);

image(3)[] img = load (dataFile);
//field#2(3)[] F = img ⊛ bspln3;
field#0(3)[] F = img ⊛ tent;

strand RayCast (int ui, int vi)
{
    // HEY (want) would like to say:
    // real rayU = lerp(-0.5, ui, imgResU-0.5, -camUmax, camUmax)
    // HEY (BUG) C syntax error with "real(ui) - -0.5" vs "real(ui) + 0.5";
    // generated C code looks like "(float)p_ui_0--0.5e0f"
    real rayU = 2.0*camUmax*(real(ui) + 0.5)/real(imgResU) - camUmax;
    real rayV = 2.0*camVmax*(real(vi) + 0.5)/real(imgResV) - camVmax;
    vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;

    real rayN = camVspNear;
    // ########## BEGIN per-ray initialization
    output real maxval = 0.0; 
    // ##########  END  per-ray initialization

    update
    {
        vec3 rayPos = camEye + rayN*rayVec;
        if (inside (rayPos,F)) {
         // ########## BEGIN per-sample code
          maxval = max(maxval, F@rayPos);
         // ##########  END  per-sample code
	}
        if (rayN > camVspFar)
            stabilize;
        rayN = rayN + rayStep;
    }

    /* render: output maxval */
}

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