Dof from object

(ideasman42) #1

This little script is used so an object can be used to set the camera’s focus
Use it as an object scriptlink on an empty, redraw event.
Then you can move it about to set what you focus on.

This is a simple scriptlink, maybe people would like to mess with it and do some more interesting stuff.

import Blender as B; Vector = B.Mathutils.Vector
target = # the object that started the scriptlink.
if type(target) != B.Types.ObjectType:
        B.Draw.PupMenu('Can only assign this scriptlink to an object')
else: # target is an Object
        scn = B.Scene.GetCurrent()
        cam = scn.getCurrentCamera()
        if cam and cam.type == 'Camera': # scene may have no camera or use a non camera object AS a camera.
                  (Vector(cam.getLocation('worldspace')) - Vector(target.getLocation('worldspace'))).length


(JiriH) #2

This is really great. Thank you idesman very much for your work. It would be great to have it besides other standard scripts in official Blender release. I have seen number of Blender users call for this, because actually it was not possible to parent camera focus to an object (mainly needed for animations). Thank you very much.


(ideasman42) #3

thanks for reminding me, wrote in C, heres the patch


(ideasman42) #4

Update, commited this patch to blender, get a recent build and set the Dof Object in the camera edit buttons.


(JiriH) #5

Thank you once more. This is great enhancement for smooth animation work-flow. I hope you do not mind I have make announcement thread on more popular general forum -