Reference System
The 3ds Max reference system is primarily a mechanism for scene objects and plug-ins to communicate. A reference between two objects models the subject-observer pattern.
When talking about a "reference" the SDK documentation is talking about a reference link from a reference maker to a reference target. A reference maker manages the references and exposes them via the function ReferenceMaker::GetReference(). Each reference managed by a reference maker is identified by an integer value called the reference index.
Objects that wish to be notified of changes in target objects (i.e. observers) are called reference makers and must derive from ReferenceMaker. The target object (i.e. subject) is called the reference target and must derived from ReferenceTarget. In 3ds Max all subjects can also be observers so ReferenceTarget derives from ReferenceMaker .
Strong references are used by 3ds Max to manage the lifetime of scene objects.
There are three kinds of references:
- Strong References - Strong references are the most common kind of references, and are usually what is meant when referring to simply "references". Strong references add ownership semantics to subject-observer relations. This means that when a strong reference exists between an observer and its subject, the subject is considered to be owned by the observer. 3ds Max will prevent deletion of ReferenceTarget objects (except nodes) when a strong direct reference exists to it. When a ReferenceTarget has no more strong direct references it will be automatically deleted by 3ds Max.
- Weak References - Weak references model a simple observer-subject relationship. A ReferenceMaker that depends on a ReferenceTarget, but can function properly without it, should create a weak reference to it. A weak reference does not prevent a ReferenceTarget from being deleted. When the ReferenceTarget is deleted the dependent ReferenceMaker is notified.
- Indirect References - Indirect references are similar to weak references but prevent the propagation of message sent from the ReferenceMaker to the ReferenceTarget to other observers of that target. The purpose of an indirect reference is to model reciprocal subject-observer relationships between scene elements, and prevent loops.
Reference relationships themselves are not represented by a specific class, but are managed through methods of ReferenceMaker.