//Get "projector" data on a "light detector" // povray dual.pov +h1 +w1 +A0.0 +AM2 +R6 +KI1.0 +KF3600.0 +KFI1 +KFF3600 //Resolution of the projector #declare Nx = 60 ; #declare Ny = 60 ; //Type of image to be rendered // 0 -> Primary image // povray dual.pov +w600 +h600 -oprimary.png // 1 -> Dual (reference) image // povray dual.pov +w(Nx) +h(Ny) -oreference.png // 2 -> Projector + photosensor // povray dual.pov +w1 +h1 +A0.0 +AM2 +R7 +KFF(Nx)*(Ny) // 3 -> Reconstruction // povray dual.pov +w600 +h600 -oreconstructed.png #declare Type = 2 ; #default { #if (Type = 3) texture { finish { ambient 1 } } #else texture { finish { ambient 0 } } #end } #switch (Type) #case (1) camera { location <-5, 0, 0> direction <6, 0, 0> right <0, 0, -6> up <0, 6, 0>*Ny/Nx } light_source { <-3, 0, -3>, 1 } #break #case (3) camera { location <7.5, 0, 5> direction <-6, 0, 0> right <0, 0, -6> up <0, -6, 0>*Ny/Nx } #break #else camera { direction <6, 0, 0> right <0, 0, -6> up <0, 6, 0> rotate -45*y translate <-3, 0, -3> } light_source { #if (Type = 2) <-5, 0, 0>, Nx*Ny #else <-5, 0, 0>, 1 #end } #end //Projector mask #if (Type = 2) #declare Start = 1.0 ; #declare End = Nx*Ny ; #declare My_Clock = int(Start+(End-Start)*clock+0.5) ; #declare A = mod(My_Clock-1,Nx) ; #declare B = int((My_Clock-1)/Nx) ; intersection { plane { -x, -6 } plane { x, 6.01 } box { 0, 1 inverse translate 5.5*x scale <1, 6/Ny, 6/Nx> translate <0, B*6/Ny-3, A*6/Nx-3> } scale 0.01 translate -5*x } #end //Reconstructed image #if (Type = 3) #declare My_Clock = 0 ; #while (My_Clock < Nx*Ny) #declare My_Clock = My_Clock+1 ; #declare A = mod(My_Clock-1,Nx) ; #declare B = int((My_Clock-1)/Nx) ; #declare File = concat("dual",str(My_Clock,-4,0),".png") ; box { 0, 1 pigment { image_map { png File } rotate 90*y } translate 0.5*x scale <1, 6/Ny, 6/Nx> translate <0, B*6/Ny-3, +A*6/Nx+2> } #end #end plane { -z, -1 pigment { checker color rgb <1, 1, 0> color rgb <0.8, 0.8, 0> } } plane { -x, -1 pigment { checker color rgb 1 color rgb 0.8 } } sphere { 0, 1 pigment { color rgb <1, 0, 0> } }