Utility dofcam "DOFCAM"
--Depth of Field Faker
(	

--group "Preview"
	--( 
	--bitmap preview images:#( render camera:$cam outputwidth:80 outputheight:60 vfb:off)
	--)
	
group "Properties"
		(
		Button go "MAKE DOFCAM"	
		spinner bluramount "Blur Amount" range:[0,5,0]
		radiobuttons blurtype labels:#("Object Blur","Image Blur") default:0
		)
	
	on go pressed do
		
		(
--creates the camera
 	cam = Targetcamera name:"cam" fov:45 nearclip:1 farclip:1000 nearrange:0 farrange:1000 mpassEnabled:off mpassRenderPerPass:off pos:[0,0,0] target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,100,0]))

--creates the dummy
 	dum = Dummy name:"dum" pos:[0,0,0] 

--creates the path for the camera
 	cir = Circle name:"cir" radius:5.0 transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0]) 
	
--make the camera follow the path
 	cam.pos.controller = path follow:true
 	cam.pos.controller.path = cir

--animates the camera
	selectKeys cam (interval 0 100)
	deleteKeys cam #selection #slide
	
	set animate on 
	
		set time 0f
			cam.pos.controller.percent = 0
		set time 1f
			cam.pos.controller.percent = 100
		
	set animate off

--Using Out-of-Range Types for the Camera
 	setAfterORT cam #cycle
	setbeforeORT cam #cycle
 	enableORTs cam true

--make the dummy look at the focal point	
	dum.rotation.controller = LookAt_Constraint()
	dum.rotation.controller.target_axis = 1
	dum.rotation.controller.upnode_axis = 0
	dum.rotation.controller.StoUP_axis = 0
	dum.rotation.controller.lookat_vector_length = 10
	dum.rotation.controller.appendtarget cam.target 50
	
--parents the circle to the dummy
 	cir.parent = dum
	
		)
		
--Controls the blur types	
	on blurtype changed state do
		(
		case state of
			(
			1:(max select all
			$.motionblur = #object)
		
			2:(max select all
			$.motionblur = #image)
			)
		)
		
--changes the radius of the path to synthesize change fstop on a camera	
	on bluramount changed val do
		(
			$cir.radius = val
		)
--the end		
)

