Friday, March 06, 2009

Control over the camera in povray



I've finally mastered the camera object in povray. The code below shows how one may have complete control over what is on the screen, regardless of the camera angle or image pixel ratio. The attached animation shows how I was able to keep a red box in front of the camera across a wide range of camera angles. This camera is currently "stuck" at the origin looking towards Z, but one could easily apply a transform to the camera and to any other objects you wanted in the scene.
Enjoy.

#declare camang=45; // this is the variable you change

#declare iwih=image_width/image_height;


#declare azee=0.5*iwih/tan(camang/2*pi/180);

camera {

direction z*azee

up y


right x*image_width/image_height


}


box{<-iwih/2+0.01,-1/2+0.01,0>,




translate z*azee*1.0


pigment{Red+Green/4} finish{ambient .1}}




No comments: