Indirect Reference Example
 
 
 

The following MAXScript code and diagram illustrate an example when a reference hierarchy would need to be circular. The MAXScript code creates a references that point upwards in the reference hierarchy using indirect references. A diagram of the various scene entities and their relationships follows. The dashed lines in the diagram represent indirect references. If these indirect references were assumed to be ordinary or strong references, code that followed the reference tree would find itself in an infinite loop.

-- Createtwo spheres
s1 = sphere pos:[100,100,0  
s2 = sphere pos:[-100,100,0
 
-- Createa floatcontoller forthe radius
rc = float_script()
s2.radius.controller = rc  
 
-- Createa teapot
t1 = teapot()
rc.AddNode "teapot" t1
 
-- Createand assigna positioncontroller tothe teapot
sc = Position_Script()
t.pos.controller = sc
 
-- Displaythe controllerdialogs
displayControlDialogrc "sphere radius"
displayControlDialogsc "teapotpos"
 
-- Add the sphere as a node to the script controller
sc.AddNode "s1_Node_Node" s1
rtm = RefTargMonitor
refTarg:s2.baseobject sc.AddObject "s_base_object"
 
-- Post load
sc = $teapot01.pos.controller
rc = $sphere02.radius.controller
displayControlDialogrc "sphere radius"
displayControlDialogsc "teapotpos"
rtm = sc.getVarValue "s_base_object"
rtm.reftarg

The 3ds Max SDK provides the following indirect reference makers that plug-in developers can use: INodeMonitor, INodeTransformMonitor, IRefTargMonitorClass, and IIndirectRefTargContainer.