Controlling Depth of Field (DoF) in Maya - Measure Tools |
Years ago I learned a method which seemed to make a little more sense. It involves the use of measuring tools, the distance tool to be precise, in Maya and connecting a couple attributes. This method involves some thinking outside of the box.
Create a Camera and enable depth of fields (that check box I mentioned earlier).
Create > Cameras > Camera
Create a locator.
Create > Locator
Move the camera back away from the locator. Select the locator THEN select the camera and apply an aim constraint (from the Animation menu).
Constrain > Aim
If the camera is not looking at the locator this is because the aim vector needs to be changed.

Open the AE and adjust the aim vectors. In my case the locator is in the -Z direction from the camera so a value -1 in the Z field fixed the aiming issue.

Now where ever you move the locator the camera will orientate and follow. So now to determine the distance from the camera to the locator. Create a distance tool and click twice anywhere on the grid. Two locators will be created with a line connecting the two. On this line an annotation is visible displaying the distance between the two locators.

Constrain these locators to the existing camera rig. One locator to the camera, and the other locator to the target (aim constraining) locator. Select the camera, THEN select a locator and point constrain.
Constrain > Point

Select the target locator and the second locator of the distance tool and point constrain.
Constrain > Point

Now there is a potential problem here, we have one locator overlapping the other. Select the second locator of the distance tool (from the Outliner may be the easiest) and hide it. Now you can safely select the targeting locator and drag it around. Notice that camera still orientates and follows it as well as the distance value is updating. Lets now create a connection between the distance value and the focus distance of the camera.
In the Outliner RMB and select 'Show Shapes'. The attributes we need are on the shape nodes and we need to be able to directly select the shape nodes to load them into the Connection Editor (CE). Below I outlined the shape nodes we will need to be able to select. They are only visible in the Outliner when you enable 'Show Shapes'.

Open the CE.
Window > General Editors > Connection Editor
Select the distance shape and click 'Reload Left'. Select the camera shape and click 'Reload Right'. The names of the two nodes will be at the very top of the attributes list (see below).

Scroll down the attributes for the distance shape until you locate the 'distance' attribute(should be at the bottom). Then under the camera shape locate the 'focusDistance' attribute. To connect them click on them so they are both highlighted in blue.

Now when you drag the locator the focus distance updates interactively. This same method can be used on a 'Camera and Aim' (or 'Camera, Aim and Up') rig. The aim nodes are also locators but instead of aim constraints they use a series of connected attributes (covered in another lesson) to create the aim effect. The visibility attribute on the locator node has been disabled.

And the rotate pivot icon is enabled (that is what makes the circle icon that you see).

This works OK enough. However I have another method that I prefer which does not include cluttering the scene with additional nodes.