Collection Mapping (SDK)

3DS Max Plug-In SDK

Collection Mapping (SDK)

For Object Sets, Pathnames, Modifer/Key/NodeChildren Arrays and Arrays.

The following virtual functions are defined on Value and implemented by those classes that support them to provide a collection mapping mechanism. Those that support mapping return true from the virtual function predicate is_collection(). The MAXScript 'for x in y ...' loop statement relies on these mapping functions, for example. Attempting to map a non-collection results in a descriptive MAXScript runtime error.

Some of the functions are driven by a mapping structure, 'node_map', defined below.

Only PathNames, ObjectSets and Nodes implement the '_path' variants. Mapping over a scene node Value (MAXNode instance), effectively maps over its descendants.

class Value

Value* map(node_map& m);

map node structure over collection

Value* map_path(PathName* path, node_map& m);

map node collection over values matching pathname

Value* find_first(BOOL (*test_fn)(INode* node, int level, void* arg),

void* test_arg); 

find first node matching test

Value* get_path(PathName* path);

get the non-wild-card pathname-specified node

struct node_map

{

value_vfvfn_ptr; // virtual fn to map 

value_cfcfn_ptr; // or, c fn to map (one or the other must be null) 

Value**arg_list; // args to pass on... 

intcount; 

BOOL(*selector)(INode*, int, void*); // set selector fn 

void*sel_arg; // arg for the selector 

intget_index; // index if we are doing an indexed get 

intget_count; // local running traverse count during get 

Value**get_result_p; // ptr to result holder for indexed get 

Array*collection; // append map results here if non-null (used 

// in for ... collect) 

shortflags; // control flags 

};

 

#define NM_INVERT0x0001 // invert map order, map parents last on

// the way out of the recursion 

#define NM_SELECT0x0002 // applying a select, adjust clear flag

#define NM_GET 0x0004 // doing a get, return get_index'th item