Class RemapDir

3DS Max Plug-In SDK

Class RemapDir

See Also: Class ReferenceTarget.

class RemapDir

Description:

This class is used for remapping references during a Clone. It is used when cloning items that are instanced so that the plug-in can maintain the same instance relationship within the clone. All methods of this class are implemented by the system.

Methods:

Prototype:

virtual RefTargetHandle CloneRef(RefTargetHandle oldTarg);

Remarks:

In the ReferenceTarget::Clone() procedure when an item is cloning itself it should clone all its references. Instead of calling Clone() on all of its references it should instead call this method passing it the item to copy. This method will return a copy of the item or a pointer to a copy of the item if it was already copied.

Parameters:

RefTargetHandle oldTarg

This is the item that is to be copied.

Return Value:

A copy of the item or a pointer to a copy of the item if it was already copied.

Prototype:

virtual void PatchPointer(RefTargetHandle* patchThis, RefTargetHandle oldTarg)=0;

Remarks:

This method is used to patch the pointer for cloned items. This method is used by system plug-ins for example. The Ring Array system has an array of nodes it maintains. When the system is cloned this method is used to clone the table of nodes. The new ring array master controller will also have a table of nodes, but it does not want the pointer to point to the old nodes, it should point to the new cloned nodes. The nodes may not be cloned yet at the time the master controller was cloned however. This method allows the pointer to be changed to point at the new nodes.

Parameters:

RefTargetHandle* patchThis

The pointer should point at this item.

RefTargetHandle oldTarg

The original target.

Sample Code:

The following sample code demonstrates the use of this method to patch the pointer to the table of nodes maintained by the ring array system.

RefTargetHandle RingMaster::Clone(RemapDir& remap) {

 int i;

RingMaster* newm = new RingMaster();

 newm->ReplaceReference(0,pblock->Clone(remap));

 newm->numNodes = numNodes;

 newm->nodeTab.SetCount(numNodes);

 for (i=0; i<numNodes; i++) newm->nodeTab[i] = NULL;

 for (i=0; i<numNodes; i++) {

  remap.PatchPointer((RefTargetHandle*)&newm->nodeTab[i],

   (RefTargetHandle)nodeTab[i]);

  }

 return(newm);

 }

Prototype:

virtual RefTargetHandle FindMapping(RefTargetHandle from)=0;

Remarks:

If an item has been cloned, this method will return the cloned copy of it. If it has not been cloned, NULL will be returned.

Parameters:

RefTargetHandle from

The item to check.

Prototype:

virtual void AddEntry(RefTargetHandle hfrom, RefTargetHandle hto)=0;

Remarks:

This method is used internally.

Prototype:

virtual void Backpatch()=0;

Remarks:

This method is used internally.

Prototype:

virtual void Clear()=0;

Remarks:

This method is used internally.

Prototype:

virtual void DeleteThis()=0;

Remarks:

This method is used internally.