// StereoCamera Macro v1.0 (for POVRay 3.5) // Created by Trevor G Quayle // Sept 18, 2001 // // Macro creates a stereogram view of your // object or scene. The objects of the scene // needs to be declared as a single object. // The camera has to be invoked *after* // declaring your object, as the macro applies // extra attributes to the object in order to // work properly. Only one camera is used and // mirrors simulate the multiple views. // // Syntax: StereoCamera(LO,LA,Spac,n,CameraON) // // LO= Camera Location // LA= Look At Location // -these work like the location and // look_at attributes of the camera. When // using more than one view, the camera // is centred at the LO vector // Spac= Spacing between each "camera" in POV // units. // -this is *not* the distance between // each view, but the physical distance // between each camera. Think of it as // the actual distance between your eyes // n= Number of camera views // -the macro automatically scales the image // so that all n views fit across the width // of the output image (while maintaining // aspect ratio). You will need to alter // the output image height and width to // suit the number of views used. // CameraON=(on/off) turns multi-views on/off // -with CameraON set to off, only // the original scene is shown. It // scaled to the same proportions as // it would appear with the selected // number of views though. // // You will need to adjust the variables and // the output image size to get the Stereo view // to work properly. // View final image as you would any stereogram // Try to focus 'behind' the image until the // adjacent views line up. // // Have fun! // Trevor G Quayle // TinCanMan_2000@hotmail.com // #macro StereoCamera (LO,LA,Spac,n,Obj,CameraOn) #local VVec=LO-LA; #if (VVec.y!=0 | VVec.z!=0) #declare zA=degrees(atan2(VVec.y,sqrt(pow(VVec.z,2)+pow(VVec.x,2)))); #else #declare zA=0; #end #if (VVec.x!=0 | VVec.z!=0) #declare yA=degrees(atan2(VVec.z,VVec.x)); #else #declare yA=0; #end #local H=vlength(VVec); #local Ang=degrees(2*asin(Spac/(2*H))); #if (CameraOn) #local cLO=0; #local cLA=H/2*x; #local Mirror=box{<0,-Spac,-Spac/2><0,Spac,Spac/2> pigment{rgb 0} finish{diffuse 0 ambient 0 reflection {1}} no_reflection no_shadow} #local i=-(n-1)/2; union{ #while (i<=(n-1)/2) object{Mirror translate cLA rotate Ang*i*y} #local i=i+1; #end rotate zA*z rotate -yA*y translate LA } #end camera{ cylinder 1 angle Ang*n up 2*pi*Ang*n/360*image_height/image_width*y #if (CameraOn) right -x location LA look_at LO #else right x location LO look_at LA #end } #if (CameraOn) difference{object{Obj} sphere{LA 0.00001 pigment{rgb 0}} no_image} #else object{Obj} #end #end