void preparation(){ cn2=midPosition-eye; cn2.Normalize(); cn0=cn00.GetNormalized(); cn1=cn0.Cross(cn2); // left hand coordinate iniPosition=midPosition-Sx/2*cn0-Sy/2*cn1; }
void PopulateImageParams() { _f = camera.dir; _f.Normalize(); _s = _f.Cross(camera.up); _s.Normalize(); _u = _s.Cross(_f); cout<<"Populating ImageParams..."<<endl; float alpha = camera.fov; float l = camera.focaldist; float h = l * tan(alpha/2.0 *(M_PI/180.0)); float aspectRatio = (float)camera.imgWidth/camera.imgHeight; float s = aspectRatio * abs(h); float dx = (2 * abs(s))/camera.imgWidth; float dy = -(2 * abs(h))/camera.imgHeight; float dxx = dx/2.0 , dyy=dy/2.0; Point3 K(-s,h,-l); K.x += (dxx ); K.y += (dyy ); for(int i = 0; i< camera.imgHeight ; i++){ for(int j = 0; j< camera.imgWidth; j++){ K.x += dx; Matrix3 RotMat; const float pts[9]={_s.x,_u.x,-_f.x,_s.y,_u.y,-_f.y,_s.z,_u.z,-_f.z}; RotMat.Set(pts); // K = RotMat*K; Cone r = Cone(camera.pos, K); r.dir = r.dir * RotMat; r.dir.Normalize(); r.radius = 0.0; r.tanAngle = tan(abs(dyy)/(float)l); /* Populating the Struct */ Point2 pixLoc = Point2(j,i); imageParams.K.push_back(K); imageParams.rendered.push_back(false); imageParams.PixLocation.push_back(pixLoc); imageParams.PixIndex.push_back( i * camera.imgWidth + j); imageParams.Ray.push_back(r); Point2 pixDimensions = Point2(dx,dy); imageParams.PixParams.push_back(pixDimensions); vector<Point3> ConfCirclePts; float randAng = rand()/ (float) RAND_MAX; randAng *= M_PI * 2.0; for(int i = 1; i<=MAX_N_SAMPLES; i++){ float hx = camera.dof * Halton(i, H_BASE_1); float hy = Halton(i, H_BASE_2); float r = sqrtf(hx); float theta = hy * M_PI * 2.0 + randAng; float x = r * cosf(theta); float y = r * sinf(theta); Point3 newCamPos(x, y, 0); newCamPos = newCamPos * RotMat; newCamPos += camera.pos; ConfCirclePts.push_back(newCamPos); } imageParams.ConfusionCirclePoints.push_back(ConfCirclePts); } K.x = -s; K.x += dxx; K.y += dy; } }