Public Member Functions | Friends

ReferenceMaker Class Reference

This reference page is linked to from the following overview topics: Lesson 3: the reference system, Lesson 4: Animation Controllers, Major New Features, Incremental Improvements, Plug-in Upgrade Guide, Reference System Changes, SuperClassID Cleanup, Overview: Parameter Blocks, Reference System Best Practices, Saving, Loading, and Deleting Parameter Blocks, Responding to Node Deletion, Recovering an ILayer or ILayerProperties from an INode, Reference System, How Plug-ins Observe Reference Targets, Writing Reference Makers, Creating and Changing References, Deleting References, Loading and Saving of References, Reference Messages, Handling Reference Messages, Strong References, Weak References, Reference Hierarchy Functions, Reference Object Lifetime Management, Guidelines for Changing the Reference Structure, Translation of Texture Map and Materials, Wrapping 3ds Max Objects, Extracting Wrapped Objects, Loading and Saving Plug-in Data, Exposing and Managing References, Implementing Clone in a Plug-in, Remapping References on Load, Supporting Save to Previous, Serializing Controllers, Making Controllers Lockable, Ring Array Classes, Ring Array Creation Process.


Search for all occurrences

Detailed Description

A scene entity that owns other scene entities and listens to messages from them.

See also:
Class SingleRefMaker, Class IRefTargContainer Any scene entity that makes references must be derived from this class. A reference creates a record of the dependency between a ReferenceMaker and a ReferenceTarget. 3ds Max uses a messaging system to notify dependent entities about changes. This class has a method that receives the notifications its targets send when they change. It has methods that return the number of references if has, and methods to get and set these references. Also, there are methods for creating, replacing and deleting the references. File input and output is handled via methods of this class (Load() and Save()).

A reference link is similar to the relationship that exists between an observer and its subjects in an observer design patters, except that reference links also mean ownership, unless otherwise specified.

Note that copying ReferenceMaker instances would not correctly establish reference hierarchy relationships between this destination object and the references held by the source object. Therefore copying of ReferenceMakers is prohibited. For more information, see ReferenceMaker::Clone().

Note that RefMakerHandle is a typename for pointers to an object of type ReferenceMaker.

See the section on References for an overview of the 3ds Max reference architecture.

#include <ref.h>

Inheritance diagram for ReferenceMaker:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void  GetClassName (MSTR &s)
  Retrieves the name of the plugin class.
virtual CoreExport SClass_ID  SuperClassID ()
  Retrieves a constant representing the type of the plugin.
Making / Replacing / Deleting References
CoreExport RefResult  ReplaceReference (int which, RefTargetHandle newtarg, BOOL delOld=TRUE)
  Used when cloning reference makers.
CoreExport RefResult  DeleteAllRefsFromMe ()
  Deletes all references from this ReferenceMaker.
virtual RefResult  DeleteAllRefsToMe ()
  Deletes all refs to this RefMaker/RefTarget.
CoreExport RefResult  DeleteAllRefs ()
  Deletes all references both to and from this item.
CoreExport RefResult  DeleteReference (int i)
  Deletes the specified reference.
virtual BOOL  CanTransferReference (int i)
  Tells whether this reference can be transfered.
Loading and Saving Methods
CoreExport ReferenceSaveManager GetReferenceSaveManager ()
  Access the ReferenceSaveManager of this ReferenceMaker.
virtual CoreExport IOResult  Save (ISave *isave)
  Called for saving data.
virtual CoreExport IOResult  Load (ILoad *iload)
  Called for loading data.
virtual int  RemapRefOnLoad (int iref)
  Used to load old files with references.
virtual CoreExport void  RescaleWorldUnits (float f)
  Rescale size of all world units in reference hierarchy.
Dependent Notification Methods
virtual CoreExport RefResult  NotifyDependents (Interval changeInt, PartID partID, RefMessage message, SClass_ID sclass=NOTIFY_ALL, BOOL propagate=TRUE, RefTargetHandle hTarg=NULL)
  Send a notification all classes that reference this class.
Enumeration Methods
virtual CoreExport void  EnumAuxFiles (AssetEnumCallback &assetEnum, DWORD flags)
  Enumerate auxiliary files (e.g. bitmaps)
virtual CoreExport void  SaveEnum (SaveEnumProc &sep, BOOL isNodeCall=0)
  The default save enumeration.
virtual CoreExport bool  SpecifySaveReferences (ReferenceSaveManager &referenceSaveManager)
  Used to specify reference slot remapping during scene file save.
CoreExport int  DoEnumDependents (DependentEnumProc *dep)
  Begins an enumeration that searches back in the dependency network.
virtual CoreExport int  DoEnumDependentsImpl (DependentEnumProc *dep)
  Method to perform an enumeration on a ReferenceTarget.
CoreExport bool  EnumRefHierarchy (RefEnumProc &proc, bool includeCustAttribs=true, bool includeIndirectRefs=true, bool includeNonPersistentRefs=true, bool preventDuplicatesViaFlag=true)
  This method provides a general purpose reference enumerator.
Finding and Checking Reference Targets
CoreExport int  FindRef (RefTargetHandle rtarg)
  Get the index of the ReferenceTarget.
virtual BOOL  IsRefTarget ()
  Tells whether it is a ReferenceTarget.
virtual BOOL  IsRefMaker ()
  Tells whether it is a ReferenceMaker.
virtual BOOL  IsRealDependency (ReferenceTarget *rtarg)
  Returns whether this is a "real" (strong) dependency or not.
virtual BOOL  ShouldPersistWeakRef (RefTargetHandle rtarg)
  Specifies whether a weak reference is to be persisted on a partial load or save.
Methods introduced in 3ds Max 4.2

Methods inherited from Animatable.

If your plugin utilizes this new mechanism, be sure that your clients are aware that they must run your plugin with 3ds max version 4.2 or higher.

virtual CoreExport void *  GetInterface (ULONG id)
  Returns a pointer to the interface.
virtual CoreExport BaseInterface GetInterface (Interface_ID id)
  Returns a pointer to the Base Interface.

Protected Member Functions

Dependent Notification

Methods used to respond to notifications

virtual RefResult  NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)=0
  Receives and responds to messages.

Friends

class  DeleteRefRestore
class  MakeRefRestore
class  ReferenceTarget
class  ParamBlock
class  RootNode
class  BaseNode
class  ILoadImp
class  RefMakerPLC
class  RefList
class  LayerManagerRestore
class  RepMtlRest
class  MAXMaterialLibrary

Construction, deletion of instances

virtual CoreExport  ~ReferenceMaker ()=0
  Destructor.
CoreExport  ReferenceMaker ()
  Constructor.
CoreExport void  DeleteMe ()
  Deletes an instance of this class.

Reference Access

3ds Max manages the access to an items references by using a virtual array.ALL classes that make references MUST implement these three methods to handle access to their references
virtual CoreExport void  SetReference (int i, RefTargetHandle rtarg)
  Stores a ReferenceTarget as its 'i-th' reference`.
virtual CoreExport int  NumRefs ()
  Returns the total number of references this ReferenceMaker can hold.
virtual CoreExport RefTargetHandle  GetReference (int i)
  Returns the 'i-th' reference.

Internal Methods

Implemented by the system.These method are used internally.
void  BlockEval ()
void  UnblockEval ()
int  Evaluating ()
CoreExport RefResult  StdNotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID partID, RefMessage message, BOOL propagate=TRUE)

Constructor & Destructor Documentation

virtual CoreExport ~ReferenceMaker ( ) [protected, pure virtual]

Destructor.

Instances of class ReferenceMaker and classes derived from it should be deleted by calling ReferenceMaker::DeleteMe() on them, rather then calling the delete operator. This will ensure that the object drops all references it makes to other objects.

CoreExport ReferenceMaker ( )

Constructor.


Member Function Documentation

CoreExport void DeleteMe ( )

Deletes an instance of this class.

Deletes all references to and from this object, sends REFMSG_TARGET_DELETED messages, and deletes the object. If the undo system is engaged (holding) it ensures that the operation is undo/redo-able. Note that this method should only be called by plugins when they need to delete plugin objects via ReferenceMaker pointers or in case the plugin to be deleted does not allow the system to automatically delete it. See ReferenceTarget::MaybeAutoDelete() and ReferenceTarget::AutoDelete() for more information.

virtual void GetClassName ( MSTR s ) [inline, virtual]

Retrieves the name of the plugin class.

This name is usually used internally for debugging purposes. For Material plug-ins this method is used to put up the material "type" name in the Material Editor.

Parameters:
s Reference to a string filled in with the name of the plugin class

Reimplemented from Animatable.

Reimplemented in EaseCurveList, MultCurveList, DummyObject, SphereGizmoObject, CylGizmoObject, BoxGizmoObject, Texmap, Mtl, MtlLib, MtlBaseLib, LinearShape, SimpleManipulator, PatchObject, PolyObject, ReferenceTarget, SimpleOSMToWSMMod, SimpleOSMToWSMMod2, SimpleObject, SimpleWSMObject, SimpleParticle, SimpleShape, SimpleSpline, SplineShape, TriObject, MSCustAttrib, MSPluginSimpleObject, MSSimpleObjectXtnd, MSPluginSimpleManipulator, MSSimpleManipulatorXtnd, MSPluginModifier, MSModifierXtnd, MSPluginSimpleMod, MSSimpleModXtnd, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, MSPluginTrackViewUtility, PFSimpleAction, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSObjectXtnd< GenCamera, MSPluginCamera >, MSObjectXtnd< HelperObject, MSPluginHelper >, MSObjectXtnd< GeomObject, MSPluginGeomObject >, MSObjectXtnd< ShapeObject, MSPluginShape >, MSObjectXtnd< GenLight, MSPluginLight >, MSPluginSpecialFX< Effect8 >, MSPluginSpecialFX< Atmospheric >, MSSpecialFXXtnd< Effect, MSPluginEffect >, and MSSpecialFXXtnd< Atmospheric, MSPluginAtmos >.

{ s = _M("ReferenceMaker"); }
virtual CoreExport SClass_ID SuperClassID ( ) [virtual]
CoreExport RefResult ReplaceReference ( int  which,
RefTargetHandle  newtarg,
BOOL  delOld = TRUE 
)

Used when cloning reference makers.

This routine is used when cloning reference makers, to delete old reference and make a new one. In max r9, additional checks have have been added to ReplaceReference. If parameter which is < 0, REF_FAIL will be immediately returned. If parameter which is >= NumRefs, an attempt will be made to set the reference, and then another check will is made to see if which is >= NumRefs, and if so REF_FAIL is returned. There are 2 additional tests that can be enabled in order to ensure that plugins set up their references correctly. Both are executed at run-time when a plugin calls ReplaceReference:

1. The first test ensures that all references of a plugin are initialized to NULL before it establishes its first reference. Whether to perform this check defaults to TRUE for Hybrid and Debug builds, false for Release builds. The 3DSMAX_REFCHECK_ENABLED environment variable can be used to overwrite the default behaviour. See bool UtilityInterface::GetBoolEnvironmentVariable() for the values this environment variable can take.

2. The second test ensures that all references of a plugin have been set up correctly. This test can also detect "dangling" references, i.e. references that are non-NULL but point to non-existent reference targets. Whether to perform this check defaults to FALSE for all build configurations (Debug, Hybrid and Release). The 3DSMAX_REFCHECK_PARANOID_ENABLED environment variable, can be used to overwrite the default behaviour. See bool UtilityInterface::GetBoolEnvironmentVariable() for the values this environment variable can take.

Parameters:
which - The virtual array index of the reference to replace.
newtarg - The new reference target
delOld - If TRUE, the old reference is deleted.
Returns:
This is usually REF_SUCCEED indicating the reference was replaced, otherwise REF_FAIL.
CoreExport RefResult DeleteAllRefsFromMe ( )

Deletes all references from this ReferenceMaker.

Implemented by the System.

Returns:
This is always REF_SUCCEED indicating the references were deleted.
virtual RefResult DeleteAllRefsToMe ( ) [inline, virtual]

Deletes all refs to this RefMaker/RefTarget.

Implemented by the System. This method deletes all the references to this reference maker/reference target. This also sends the REFMSG_TARGET_DELETED message to all dependents.

Returns:
This is REF_SUCCEED if the references were deleted; otherwise it is REF_FAIL.

Reimplemented in ReferenceTarget.

{ return REF_SUCCEED; }
CoreExport RefResult DeleteAllRefs ( )

Deletes all references both to and from this item.

Implemented by the System. Deletes all references both to and from this item.

Returns:
This is REF_SUCCEED if the references were deleted; otherwise it is REF_FAIL.
CoreExport RefResult DeleteReference ( int  i )

Deletes the specified reference.

Implemented by the System. This method deletes the reference whose virtual array index is passed. The other reference indices are not affected, i.e. the number of references is not reduced nor are they reordered in any way. Note the system calls SetReference(i, NULL) to set that reference to NULL. Also, if this is the last reference to the item, the item itself is deleted by calling its DeleteThis() method.

Parameters:
i - The virtual array index of the reference to delete.
Returns:
This is REF_SUCCEED if the reference was deleted; otherwise it is REF_FAIL.

Reimplemented in RefMgr< T >.

virtual BOOL CanTransferReference ( int  i ) [inline, virtual]

Tells whether this reference can be transfered.

A ReferenceMaker can choose not to let ReferenceTarget::TransferReferences() affect it. Note that plugins probably should not use this. It is used by certain system objects that have references.

Parameters:
i - Currently not used.
Returns:
Default to return TRUE

Reimplemented in SingleRefMaker, and RefMgrAddDeleteRestore< T >.

{ UNUSED_PARAM(i); return TRUE; }
virtual CoreExport int NumRefs ( ) [virtual]

Returns the total number of references this ReferenceMaker can hold.

The plugin implements this method to indicate the total number of of references it can make. This includes all references whether they are NULL (inactive) or non-NULL (active) at the time when this method is called. A plugin can hold a variable number of references, thus the return value of this method is not to be cached and reused by client code.

Returns:
The total number of references this plugin can hold. The default implementation is return 0.

Reimplemented in EaseCurveList, MultCurveList, Control, CollisionPlane, CollisionSphere, CollisionMesh, MtlLib, MtlBaseLib, RefTargMonitorRefMaker, GizmoClass, SimpleManipulator, ShapeObject, PatchObject, SingleRefMaker, RefMgrAddDeleteRestore< T >, RefMgr< T >, SimpleMod, SimpleWSMMod, SimpleObject, SimpleWSMObject, SimpleOSMToWSMObject, SimpleParticle, SimpleShape, SimpleSpline, SplineShape, Wrangler, MSCustAttrib, MSPluginSimpleObject, MSSimpleObjectXtnd, MSPluginSimpleManipulator, MSSimpleManipulatorXtnd, MSPluginModifier, MSModifierXtnd, MSPluginSimpleMod, MSSimpleModXtnd, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, MSPluginTrackViewUtility, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSObjectXtnd< GenCamera, MSPluginCamera >, MSObjectXtnd< HelperObject, MSPluginHelper >, MSObjectXtnd< GeomObject, MSPluginGeomObject >, MSObjectXtnd< ShapeObject, MSPluginShape >, MSObjectXtnd< GenLight, MSPluginLight >, MSPluginSpecialFX< Effect8 >, MSPluginSpecialFX< Atmospheric >, MSSpecialFXXtnd< Effect, MSPluginEffect >, and MSSpecialFXXtnd< Atmospheric, MSPluginAtmos >.

virtual CoreExport RefTargetHandle GetReference ( int  i ) [virtual]

Returns the 'i-th' reference.

The plugin implements this method to return its 'i-th' reference. The plug-in simply keeps track of its references using an integer index for each one. This method is normally called by the system.

Parameters:
i - The index of the reference to retrieve. Valid values are from 0 to NumRefs()-1.
Returns:
The reference handle of the 'i-th' reference. Note that different calls to this method with the same 'i' value can result in different reference handles being retrieved, as the plugin changes the scene objects it references as its 'i-th' reference.

Reimplemented in EaseCurveList, MultCurveList, Control, CollisionPlane, CollisionSphere, CollisionMesh, MtlLib, MtlBaseLib, RefTargMonitorRefMaker, GizmoClass, SimpleManipulator, ShapeObject, PatchObject, SingleRefMaker, RefMgrAddDeleteRestore< T >, RefMgr< T >, SimpleMod, SimpleMod2, SimpleWSMMod, SimpleWSMMod2, SimpleObject, SimpleObject2, SimpleWSMObject, SimpleWSMObject2, SimpleOSMToWSMObject, SimpleParticle, SimpleShape, SimpleSpline, SplineShape, MSCustAttrib, MSPluginSimpleObject, MSSimpleObjectXtnd, MSPluginSimpleManipulator, MSSimpleManipulatorXtnd, MSPluginModifier, MSModifierXtnd, MSPluginSimpleMod, MSSimpleModXtnd, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, MSPluginTrackViewUtility, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSObjectXtnd< GenCamera, MSPluginCamera >, MSObjectXtnd< HelperObject, MSPluginHelper >, MSObjectXtnd< GeomObject, MSPluginGeomObject >, MSObjectXtnd< ShapeObject, MSPluginShape >, MSObjectXtnd< GenLight, MSPluginLight >, MSPluginSpecialFX< Effect8 >, MSPluginSpecialFX< Atmospheric >, MSSpecialFXXtnd< Effect, MSPluginEffect >, and MSSpecialFXXtnd< Atmospheric, MSPluginAtmos >.

virtual CoreExport void SetReference ( int  i,
RefTargetHandle  rtarg 
) [protected, virtual]

Stores a ReferenceTarget as its 'i-th' reference`.

The plugin implements this method to store the reference handle passed to it as its 'i-th' reference. In its implementation of this method, the plugin should simply assign the reference handle passed in as a parameter to the member variable that holds the 'i-th' reference. Other reference handling methods such as ReferenceMaker::DeleteReference(), or ReferenceMaker::ReplaceReference() should not be called from within this method. The plugin itself or other plugins should not call this method directly. The system will call this method when a new reference is created or an existing one is replaced by calling ReferenceMaker::ReplaceReference().

Parameters:
i - The index of the reference to store. Valid values are from 0 to NumRefs()-1.
rtarg - The reference handle to store.

Reimplemented in EaseCurveList, MultCurveList, Control, GizmoObject, CollisionPlane, CollisionSphere, CollisionMesh, MtlLib, MtlBaseLib, RefTargMonitorRefMaker, GizmoClass, SimpleManipulator, ShapeObject, PatchObject, SingleRefMaker, RefMgrAddDeleteRestore< T >, RefMgr< T >, SimpleMod, SimpleMod2, SimpleWSMMod, SimpleWSMMod2, SimpleObject, SimpleObject2, SimpleWSMObject, SimpleWSMObject2, SimpleOSMToWSMObject, SimpleParticle, SimpleShape, SimpleSpline, SplineShape, MSCustAttrib, MSPluginSimpleObject, MSSimpleObjectXtnd, MSPluginSimpleManipulator, MSSimpleManipulatorXtnd, MSPluginModifier, MSModifierXtnd, MSPluginSimpleMod, MSSimpleModXtnd, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, MSPluginTrackViewUtility, PFSimpleAction, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSObjectXtnd< GenCamera, MSPluginCamera >, MSObjectXtnd< HelperObject, MSPluginHelper >, MSObjectXtnd< GeomObject, MSPluginGeomObject >, MSObjectXtnd< ShapeObject, MSPluginShape >, MSObjectXtnd< GenLight, MSPluginLight >, MSPluginSpecialFX< Effect8 >, MSPluginSpecialFX< Atmospheric >, MSSpecialFXXtnd< Effect, MSPluginEffect >, and MSSpecialFXXtnd< Atmospheric, MSPluginAtmos >.

CoreExport ReferenceSaveManager& GetReferenceSaveManager ( )

Access the ReferenceSaveManager of this ReferenceMaker.

The ReferenceSaveManager is used to specify and enumerate the save reference hierarchy for the ReferenceMaker. If a plugin needed to specify a save reference hierarchy different than its normal reference hierarchy, it would implement SpecifySaveReferences() and specify the save reference hierarchy through the ReferenceSaveManager in that implementation.

Returns:
the ReferenceSaveManager for the ReferenceMaker.
virtual CoreExport IOResult Save ( ISave isave ) [virtual]

Called for saving data.

Called by the system to allow the plugin to save its data.

Parameters:
isave - This pointer may be used to call methods to write data to disk. See the section on Loading and Saving for an overview of the load/save process.
Returns:
The default implementation is return IO_OK.
  • IO_OK means the result was acceptable, with no errors.
  • IO_ERROR This should be returned if an error occurred.

Reimplemented in EaseCurveList, MultCurveList, Control, DummyObject, MtlBase, MtlLib, MtlBaseLib, IProjectionModType, RefTargMonitorRefMaker, GizmoClass, LinearShape, DefNoteTrack, ShapeObject, Modifier, PatchObject, PolyObject, RadiosityEffect, IRenderElement, Sampler, SpecialFX, Atmospheric, Effect, FilterKernel, BaseShader, SimpleShape, SimpleSpline, SplineShape, ToneOperator, TriObject, Wrangler, MSCustAttrib, MSPluginShape, MSShapeXtnd, MSPluginSimpleObject, MSPluginSimpleManipulator, MSPluginModifier, MSPluginSimpleMod, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, PFSimpleAction, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSPluginSpecialFX< Effect8 >, and MSPluginSpecialFX< Atmospheric >.

virtual CoreExport IOResult Load ( ILoad iload ) [virtual]

Called for loading data.

Called by the system to allow the plug-in to load its data. See the section on Loading and Saving for an overview of the load - save process.

Parameters:
iload - This interface pointer may be used to call methods to read data from disk.
Returns:
The default implementation is return IO_OK.
  • IO_OK means the result was acceptable, with no errors.
  • IO_ERROR This should be returned if an error occurred.

Reimplemented in EaseCurveList, MultCurveList, Control, DummyObject, MtlBase, MtlLib, MtlBaseLib, IProjectionModType, RefTargMonitorRefMaker, GizmoClass, LinearShape, DefNoteTrack, ShapeObject, Modifier, PatchObject, PolyObject, RadiosityEffect, IRenderElement, Sampler, SpecialFX, Atmospheric, Effect, FilterKernel, BaseShader, SimpleOSMToWSMObject, SimpleShape, SimpleSpline, SplineShape, ToneOperator, TriObject, Wrangler, MSCustAttrib, MSPluginShape, MSShapeXtnd, MSPluginSimpleObject, MSPluginSimpleManipulator, MSPluginModifier, MSPluginSimpleMod, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, MSMtlXtnd, PFSimpleAction, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSPluginSpecialFX< Effect8 >, and MSPluginSpecialFX< Atmospheric >.

virtual int RemapRefOnLoad ( int  iref ) [inline, virtual]

Used to load old files with references.

Implement this if you have added or deleted references and are loading an old file that needs to have its references remapped. This method is used when you have modified a ReferenceMaker to add or delete references, and are loading old files. It gets called during the reference mapping process, after the Load() method is called. You determine what version is loading in the Load(), and store the version in a variable which you can look at in RemapRefOnLoad() to determine how to remap references. The default implementation of this method just returns the same value it is passed, so you don't need to implement it unless you have added or deleted references from your class. This method makes it a lot easier to load old files when the reference topology has changed.

Parameters:
iref - The input index of the reference.
Returns:
The output index of the reference.

Reimplemented in ShapeObject, PatchObject, SplineShape, and PFSimpleAction.

{ return iref; }
virtual CoreExport void RescaleWorldUnits ( float  f ) [virtual]

Rescale size of all world units in reference hierarchy.

This method is available in release 2.0 and later only. Must call ClearAFlagInHierarchy(rm, A_WORK1) or ClearAFlagInAllAnimatables(A_WORK1) before doing this on a reference hierarchy. This may be implemented to rescale the size of all world units in a reference hierarchy. Developers must call

        if (TestAFlag(A_WORK1))
            return;
        SetAFlag(A_WORK1);

before doing this on a reference hierarchy.

Parameters:
f - The scale factor.

Reimplemented in DummyObject, LinearShape, ShapeObject, PatchObject, PolyObject, SplineShape, TriObject, MSPluginShape, and MSShapeXtnd.

virtual CoreExport RefResult NotifyDependents ( Interval  changeInt,
PartID  partID,
RefMessage  message,
SClass_ID  sclass = NOTIFY_ALL,
BOOL  propagate = TRUE,
RefTargetHandle  hTarg = NULL 
) [virtual]

Send a notification all classes that reference this class.

Since a ReferenceMaker cannot have dependents, ReferenceMaker::NotifyDependents() is implemented to simply return REF_SUCCEED.

See also:
ReferenceTarget::NotifyDependents for a detailed description of this method.

Reimplemented in ReferenceTarget.

virtual CoreExport void EnumAuxFiles ( AssetEnumCallback assetEnum,
DWORD  flags 
) [virtual]

Enumerate auxiliary files (e.g. bitmaps)

Enumerate auxiliary files (e.g. bitmaps). The default implementation just calls itself on all references and calls Animatable::EnumAuxFiles to pick up Custom Attributes Entities which actually need to load aux files must implement this, possibly calling ReferenceMaker::EnumAuxFiles also to recurse. If you don't call ReferenceMaker::EnumAuxFiles call Animatable::EnumAuxFiles.

Parameters:
assetEnum - The Callback object that gets called on all Auxiliary files.
flags - Flags.

Reimplemented from Animatable.

Reimplemented in MtlBase, MSPluginTexmap, MSTexmapXtnd, MSPluginMtl, and MSMtlXtnd.

virtual CoreExport void SaveEnum ( SaveEnumProc sep,
BOOL  isNodeCall = 0 
) [virtual]

The default save enumeration.

This method is used internally.

virtual CoreExport bool SpecifySaveReferences ( ReferenceSaveManager referenceSaveManager ) [virtual]

Used to specify reference slot remapping during scene file save.

Plugins that want to add, remove, or change the references held by the ReferenceMaker as stored to the scene file implement this method. The method implementation would modify the stored reference hierarchy through the specified ReferenceSaveManager. Plugins that implement this method must call SpecifySaveReferences() on their parent class after they have finished performing operations on the ReferenceSaveManager. The ReferenceSaveManager modifies the save hierarchy in the order that operations are performed on it, so operations on higher-indexed reference target slots should occur before operations on lower-indexed reference target slots. Otherwise, the indexing on the higher-indexed reference target slots may point at an incorrect slot. For example, if the plugin currently had slots 1,2,3 and then inserted slot 4 at position 3 and then removed slot 2, the plugin would end up with slots 1,4,3. If the order of the operations was reversed, the plugin would end up with slots 1,3,4. The ReferenceMaker level implementation finalizes the preparation of the ReferenceSaveManager to support the scene file save reference slot remapping.

            // If using CopyParamBlock2ToParamBlock copy of values/controllers from pb2 to a new pb1
            bool Swirl::SpecifySaveReferences(ReferenceSaveManager& referenceSaveManager)
            {
                // if saving to previous version that used pb1 instead of pb2...
                DWORD saveVersion = GetSavingVersion();
                if (saveVersion != 0 && saveVersion <= MAX_RELEASE_R13)
                {
                    // create the pb1 instance
                    IParamBlock* paramBlock1 = CreateParameterBlock( pbdesc,swirl_num_params_ver1,1);
                    DbgAssert(paramBlock1 != NULL);
                    if (paramBlock1)
                    {
                        // copy data from the pb2 to the pb1
                        int numParamsCopied = CopyParamBlock2ToParamBlock(pblock,paramBlock1,pbdesc,swirl_num_params_ver1);
                        DbgAssert(numParamsCopied == swirl_num_params_ver1);
                        // register the reference slot replacement
                        referenceSaveManager.ReplaceReferenceSlot(PBLOCK_REF,paramBlock1);
                    }
                }
                return Texmap::SpecifySaveReferences(referenceSaveManager);
            }

            // If doing manual copy of values/controllers from pb2 to a new pb1
            bool Swirl::SpecifySaveReferences(ReferenceSaveManager& referenceSaveManager)
            {
                // if saving to previous version that used pb1 instead of pb2...
                DWORD saveVersion = GetSavingVersion();
                if (saveVersion != 0 && saveVersion <= MAX_RELEASE_R13)
                {
                    SuspendAll suspendAll(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
                    // create the pb1 instance
                    IParamBlock* paramBlock1 = CreateParameterBlock( pbdesc,swirl_num_params_ver1,1);
                    DbgAssert(paramBlock1);
                    if (paramBlock1)
                    {
                        // copy over each parameter value/controller
                        int color_params[] = {swirl_col1, swirl_col2};
                        for (int i = 0; i < _countof(color_params); i++)
                        {
                            int id = color_params[i];
                            Control* pb2Controller = pblock->GetController(ParamID(id));
                            if (pb2Controller)
                                paramBlock1->SetController(id, pb2Controller, FALSE);
                            else
                            {
                                // Note: Swirl pb2 params are TYPE_FRGBA, PB1 params are TYPE_RGBA
                                AColor pb2Color = pblock->GetAColor(id);
                                Color pb1Color = pb2Color;
                                paramBlock1->SetValue(id, 0, pb1Color);
                            }
                        }
                        int float_params[] = {swirl_hs, swirl_vs, swirl_cv, swirl_vg, swirl_hg, swirl_ls, swirl_rs};
                        for (int i = 0; i < _countof(float_params); i++)
                        {
                            int id = float_params[i];
                            Control* pb2Controller = pblock->GetController(ParamID(id));
                            if (pb2Controller)
                                paramBlock1->SetController(id, pb2Controller, FALSE);
                            else
                            {
                                float pb2Float = pblock->GetFloat(id);
                                paramBlock1->SetValue(id, 0, pb2Float);
                            }
                        }
                        int int_params[] = {swirl_h, swirl_lock};
                        for (int i = 0; i < _countof(int_params); i++)
                        {
                            int id = int_params[i];
                            Control* pb2Controller = pblock->GetController(ParamID(id));
                            if (pb2Controller)
                                paramBlock1->SetController(id, pb2Controller, FALSE);
                            else
                            {
                                int pb2Int = pblock->GetInt(id);
                                paramBlock1->SetValue(id, 0, pb2Int);
                            }
                        }

                        // register the reference slot replacement
                        referenceSaveManager.ReplaceReferenceSlot(PBLOCK_REF,paramBlock1);
                    }
                }
                return Texmap::SpecifySaveReferences(referenceSaveManager);
            }
Parameters:
referenceSaveManager The ReferenceSaveManager for the object
Returns:
true if no errors processing any add, remove, or change operations registered with the ReferenceSaveManager. An error will occur if the reference slot index specified for an operation is invalid after performing any previously registered operations.
CoreExport int DoEnumDependents ( DependentEnumProc dep )

Begins an enumeration that searches back in the dependency network.

Implemented by the System. See the documentation for ReferenceTarget for more details. When called on instances that derive from ReferenceTarget, the call is passed along to the ReferenceTarget::DoEnumDependents method. Otherwise this method returns 0.

See also:
ReferenceTarget::DoEnumDependents(DependentEnumProc* dep)
Parameters:
dep - The callback object called for each dependent.
Returns:
Return 1 to stop the enumeration and 0 to continue. The default implementation for ReferenceMaker is return 0;

Reimplemented in ReferenceTarget.

virtual CoreExport int DoEnumDependentsImpl ( DependentEnumProc dep ) [virtual]

Method to perform an enumeration on a ReferenceTarget.

Implemented by the System. See the documentation for ReferenceTarget for more details.

Parameters:
dep - The callback object called for each dependent.
Returns:
Return 1 to stop the enumeration and 0 to continue.
See also:
ReferenceTarget::DoEnumDependentsImpl(DependentEnumProc* dep)

Reimplemented in RefTargMonitorRefMaker, and ReferenceTarget.

CoreExport bool EnumRefHierarchy ( RefEnumProc proc,
bool  includeCustAttribs = true,
bool  includeIndirectRefs = true,
bool  includeNonPersistentRefs = true,
bool  preventDuplicatesViaFlag = true 
)

This method provides a general purpose reference enumerator.

This method provides a general purpose reference enumerator that calls RefEnumProc::proc() on each element in a reference hierarchy. This function walks down the reference hierarchy, recursively calling RefEnumProc::proc() on the references held by a reference, This function ensures that RefEnumProc::proc() is called only once on each reference. Processing each reference only once improves efficiency, and prevents potential infinite recursive loops when processing indirect references. To enumerate the up the reference hierarchy, see ReferenceTarget::DoEnumDependents.

Parameters:
proc - The callback object whose proc() method is called for each element.
includeCustAttribs - Added in 3ds Max 6 SDK. Defaults to true. With includeCustAttribs set to true, RefEnumProc::proc will be called for the custom attributes applied to the reference maker.
includeIndirectRefs - Added in 3ds Max 9 SDK. Defaults to true. With includeIndirectRefs set to true, RefEnumProc::proc will be called for the indirect references held by the reference maker.
includeNonPersistentRefs - Added in 3ds Max 9 SDK. Defaults to true. With includeNonPersistentRefs set to false, RefEnumProc::proc will not be called on direct references from the reference maker unless IsRealDependency or ShouldPersistWeakRef returns true for that reference; and the proc method will not be called on indirect references from the reference maker unless ShouldPersistIndirectRef returns true for that indirect reference.
preventDuplicatesViaFlag - Added in 3ds Max 9 SDK. Defaults to true. With preventDuplicatesViaFlag set to true, processing of a duplicate reference is detected by requesting and clearing a flag bit on all animatables, and then testing/setting the flag bit prior to calling the proc on each reference maker. When set to false, a list of reference makers visited is maintained. If you expect to enumerate only a small number of references, this argument should be set to false. Note however that you do not know what references are held by the references you may enumerate into, so in most cases this argument should be true.
Returns:
Returns false if the enumeration was terminated because the RefEnumProc's proc returned REF_ENUM_HALT, true otherwise
See also:
Class RefEnumProc
ReferenceMaker::IsRealDependency(ReferenceTarget *rtarg)
ReferenceMaker::ShouldPersistWeakRef(RefTargetHandle rtarg)
IIndirectReferenceMaker::ShouldPersistIndirectRef(RefTargetHandle rtarg)
ReferenceTarget::DoEnumDependents(DependentEnumProc* dep)
CoreExport int FindRef ( RefTargetHandle  rtarg )

Get the index of the ReferenceTarget.

Implemented by the System. This method returns the virtual array index of the reference target passed.

Parameters:
rtarg - The reference target to find the index of.
Returns:
The virtual array index of the reference target to find. If the reference target is not found, -1 is returned.
virtual BOOL IsRefTarget ( ) [inline, virtual]

Tells whether it is a ReferenceTarget.

This function differentiates things sub classed from ReferenceMaker from subclasses of ReferenceTarget. The implementation of this method (in ReferenceMaker) returns FALSE and its implementation in ReferenceTarget returns TRUE. This can be useful when tracing back up the reference hierarchy, to know when you run into something that was sub classed directly off of ReferenceMaker, and hence to stop the traversal at that point.

Returns:
Default of FALSE.

Reimplemented in ReferenceTarget.

{ return FALSE; }
virtual BOOL IsRefMaker ( ) [inline, virtual]

Tells whether it is a ReferenceMaker.

This function differentiates things sub classed from Animatable from subclasses of ReferenceMaker. The implementation of this method (in Animatable) returns FALSE and its implementation in ReferenceMaker returns TRUE.

Returns:
Returns TRUE.

Reimplemented from Animatable.

{ return TRUE; }
virtual BOOL IsRealDependency ( ReferenceTarget rtarg ) [inline, virtual]

Returns whether this is a "real" (strong) dependency or not.

Used Internally. When a reference target's last "real" (strong) reference is deleted the target is deleted. Any leftover "non-real" (weak) reference makers will receive a REFMSG_TARGET_DELETED notification. This method returns TRUE if the reference dependency is "real" (strong). Otherwise it returns FALSE. Certain references are not considered "real" (strong) dependencies. For instance, internally there are certain reference makers such as the object that handles editing key information in the motion branch. This object implements this method to return FALSE because it is not a "real" strong) reference dependency. It's just needed while the editing is taking place. Plugin developers don't need to concern themselves with this method because it is used internally.

Parameters:
rtarg - A pointer to the reference target.
Returns:
TRUE if the reference dependency is "real". Otherwise it returns FALSE. Default implementation is TRUE.

Reimplemented in RefTargMonitorRefMaker, and SingleWeakRefMaker.

{ UNUSED_PARAM(rtarg); return TRUE;}
virtual BOOL ShouldPersistWeakRef ( RefTargetHandle  rtarg ) [inline, virtual]

Specifies whether a weak reference is to be persisted on a partial load or save.

This method specifies the partial load/save behavior of a weak reference. This method will only be called if IsRealDependency returns FALSE. If this method returns true, and this ref maker is loaded/saved, the weak reference will be forced to be loaded/saved. If false, the reference will not be forced to be loaded/saved, but will be hooked back up if it is loaded.

The default implementation is to return FALSE. Otherwise, it is possible that on a partial load that this reference maker would hold the only reference to the target. If something else temporarily referenced the target, then the target will be deleted when that reference is dropped. From the user's perspective, this is a randomly occurring event.

Typical cases where an implementation of this method would return TRUE is when post load callbacks are used to check and process the references, checking for things like owner-less parameter blocks.

Parameters:
rtarg - The weak reference.
Returns:
Whether to force the load/save of the weak reference if this reference maker is saved.
{ UNUSED_PARAM(rtarg); return FALSE; }
virtual CoreExport void* GetInterface ( ULONG  id ) [virtual]
virtual CoreExport BaseInterface* GetInterface ( Interface_ID  id ) [virtual]
void BlockEval ( ) [inline, protected]
void UnblockEval ( ) [inline, protected]
int Evaluating ( ) [inline, protected]
CoreExport RefResult StdNotifyRefChanged ( Interval  changeInt,
RefTargetHandle  hTarget,
PartID  partID,
RefMessage  message,
BOOL  propagate = TRUE 
) [protected]
virtual RefResult NotifyRefChanged ( Interval  changeInt,
RefTargetHandle  hTarget,
PartID partID,
RefMessage  message 
) [protected, pure virtual]

Receives and responds to messages.

A plugin which makes references must implement a method to receive and respond to messages broadcast by its dependents. This is done by implementing NotifyRefChanged(). The plugin developer usually implements this method as a switch statement where each case is one of the messages the plugin needs to respond to. The Method StdNotifyRefChanged calls this, which can change the partID to new value. If it doesn't depend on the particular message& partID, it should return REF_DONTCARE.

  • For developer that need to update a dialog box with data about an object you reference note the following related to this method: This method may be called many times. For instance, say you have a dialog box that displays data about an object you reference. This method will get called many time during the drag operations on that object. If you updated the display every time you'd wind up with a lot of 'flicker' in the dialog box. Rather than updating the dialog box each time, you should just invalidate the window in response to the NotifyRefChanged() call. Then, as the user drags the mouse your window will still receive paint messages. If the scene is complex the user may have to pause (but not let up on the mouse) to allow the paint message to go through since they have a low priority. This is the way many windows in 3ds Max work.
Parameters:
changeInt - This is the interval of time over which the message is active. Currently, all plug-ins will receive FOREVER for this interval.
hTarget - This is the handle of the reference target the message was sent by. The reference maker uses this handle to know specifically which reference target sent the message.
partID - This contains information specific to the message passed in. Some messages don't use the partID at all. See the section List of Reference Messages for more information about the meaning of the partID for some common messages.
message - The message parameters passed into this method is the specific message which needs to be handled.
Returns:
The return value from this method is of type RefResult. This is usually REF_SUCCEED indicating the message was processed. Sometimes, the return value may be REF_STOP. This return value is used to stop the message from being propagated to the dependents of the item.

Implemented in EaseCurveList, MultCurveList, GizmoObject, CollisionPlane, CollisionSphere, CollisionMesh, MtlLib, MtlBaseLib, DADBitmapCarrier, INodeTransformed, IProjectionModType, RefTargMonitorRefMaker, GizmoClass, LinearShape, SimpleManipulator, MCDeviceBinding, DefNoteTrack, IMultiPassCameraEffect, ShapeObject, PatchObject, SingleRefMakerPatchNode, SingleRefMakerPatchMtl, PolyObject, RadiosityEffect, SingleRefMaker, RefMgrAddDeleteRestore< T >, RefMgr< T >, IRenderElement, Sampler, Atmospheric, Effect, FilterKernel, BaseShader, SimpleMod, SimpleWSMMod, SimpleObject, SimpleWSMObject, SimpleParticle, SimpleShape, SimpleSpline, SingleWeakRefMaker, SplineShape, SingleRefMakerSplineNode, SingleRefMakerSplineMtl, ToneOperator, TriObject, MSCustAttrib, MSPluginSimpleObject, MSPluginSimpleManipulator, MSPluginModifier, MSPluginSimpleMod, MSPluginTexmap, MSPluginMtl, MSPluginTrackViewUtility, PFSimpleAction, MSPluginObject< ShapeObject >, MSPluginObject< HelperObject >, MSPluginObject< GeomObject >, MSPluginObject< GenCamera >, MSPluginObject< GenLight >, MSPluginSpecialFX< Effect8 >, and MSPluginSpecialFX< Atmospheric >.


Friends And Related Function Documentation

friend class DeleteRefRestore [friend]
friend class MakeRefRestore [friend]
friend class ReferenceTarget [friend]
friend class ParamBlock [friend]
friend class RootNode [friend]
friend class BaseNode [friend]
friend class ILoadImp [friend]
friend class RefMakerPLC [friend]
friend class RefList [friend]
friend class LayerManagerRestore [friend]
friend class RepMtlRest [friend]
friend class MAXMaterialLibrary [friend]

ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker
ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker ReferenceMaker