Overview: Reference System
 
 
 

A reference indicates a dependency between two plug-ins, or a 3ds Max object and a plug-in. 3ds Max uses the reference system for several purposes:

  1. Notifying dependent scene objects of changes or events
  2. Managing automatic deletion of objects
  3. Loading and saving the scene graph

Most references can be observed in 3ds Max using the schematic view. Note some references are not shown in the schematic view, such as parameter blocks).

The following diagram demonstrates the reference relationship between a camera, the look-at controller, it's parameter block, and the teapot.

References as Observer-Subject Relations

In its first role the reference system is essentially an implementation of the observer design pattern. Observers derive from the ReferenceMaker class, while subjects derive from the ReferenceTarget class.

The Look-At constraint controller illustrates the purpose of the reference system. The Look-At Constraint is a rotation controller - it controls the rotation of an object in the scene. The Look-At Constraint rotates the item it is assigned to so that it always points towards (or "looks at") another object. For example, you create a Free Camera and assign the Look-At Constraint as the camera's rotation controller; you then pick a Teapot in the scene as the target of the Look-At Constraint. This causes the Free Camera to rotate to remain aimed at the Teapot. If the Teapot moves, the controller adjusts itself to point the camera towards the Teapot. Also, if the Teapot is deleted from the scene, the Camera recognizes this and simply remains stationary.

Now consider that each of these items (the Camera, the Look-At Constraint, and the Teapot) are all plug-ins, each written without any specific knowledge of the other objects, but 3ds Max needs to coordinate them. How does the Camera know that the Teapot moves so it can change the direction it is pointed in? Or how does the Look-At Constraint know that the Teapot has been deleted from the scene? These objects communicate using reference messages.

A reference associates two scene objects. One object is considered to be dependent upon the other. In the above example, the Look-At Constraint is dependent on the Teapot and the Camera is dependent on the Look-At Constraint controller. That is to say, if the Teapot changes in some way it needs to let other objects that might depend on it know it has changed. The controller, via the Reference, is notified that the Teapot has changed. And the controller needs to do the same for those items which depend on it. When the controller changes, it lets those items which may depend on it know. Thus the camera is notified.

In the example above, the Camera is a ReferenceMaker. It references the Look-At Constraint which is the ReferenceTarget of the Camera. The Look-At Constraint is also aReferenceMaker, it references the Teapot. In fact ReferenceTarget derives from ReferenceMaker, because anything that can be an observer, can also be observed.

See Also