// Camera placement // Last edited on 2010-04-01 23:06:03 by stolfi // Places the camera and a light source. // Assumes defined // scene = the scene object to be rendered (minus axes, sky, etc.) #macro put_camera(focus,wd,ht,dir,dist,upp) // focus = point of interest in scene. // wd = nominal width of scene around {focus}. // ht = nominal height of scene around {focus}. // dir = direction of camera from {focus} (length is immaterial). // dist = distance from focus along {dir}. // upp = sky direction. // If {dist = 0} the camera is #local udir = vnormalize(dir); #local pos = focus + dist * udir; #local slop = 1.10; #if (wd/image_width > ht/image_height) #local cwd = wd/dist; #local cht = cwd*image_height/image_width; #else #local cht = ht/dist; #local cwd = cht*image_width/image_height; #end camera { location pos right - slop * cwd * x up + slop * cht * y sky upp look_at focus } #end #local scene_min = min_extent(scene); #local scene_max = max_extent(scene); #local scene_ctr = (scene_max + scene_min)/2; #local scene_wd = scene_max.x - scene_min.x; #local scene_ht = scene_max.y - scene_min.y; #local scene_radius = sqrt(scene_wd*scene_wd + scene_ht*scene_ht); #debug concat("total scene width = ", str(scene_wd,7,4), "\n") #debug concat("total scene height = ", str(scene_ht,7,4), "\n") light_source{ 500*<1,2,3> color rgb 1.1*<1,1,1> } put_camera(scene_ctr, scene_wd, scene_ht, z, 500*scene_radius, y)