mxsobjects.h

Go to the documentation of this file.
00001 /*  
00002  *      MAXObject.h - MAX object wrapper classes in MAXScript
00003  *
00004  *          Copyright (c) John Wainwright 1996
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\kernel\value.h"
00011 #include "..\foundation\collection.h"
00012 #include "..\..\3dsmaxport.h"
00013 #include "..\..\buildver.h"
00014 #include "..\..\object.h" // for idTM
00015 #include "..\..\surf_api.h"
00016 #include "..\..\tvnode.h"
00017 #include "..\..\triobj.h"
00018 
00019 // forward declarations
00020 class ScaleValue;
00021 class MNMesh;
00022 class GenericNamedSelSetList;
00023 class IMeshSelectData;
00024 class PatchObject;
00025 class IPatchSelectData;
00026 class ClassDesc2;
00027 struct ParamDef;
00028 class TrackViewUtility;
00029 class CustAttrib;
00030 class Array;
00031 class HashTable;
00032 
00033 extern ScripterExport Interface* MAXScript_interface;
00034 extern ScripterExport Interface7* MAXScript_interface7;
00035 extern ScripterExport Interface8* MAXScript_interface8;
00036 extern ScripterExport Interface9* MAXScript_interface9;
00037 extern ScripterExport Interface11* MAXScript_interface11;
00038 extern ScripterExport Interface13* MAXScript_interface13;
00039 class MAXControl;
00040 
00041 #define MESH_READ_ACCESS    0  // mesh access modes
00042 #define MESH_WRITE_ACCESS   1
00043 #define MESH_BASE_OBJ       2
00044 
00045 /* --------------------- base wrapper class ------------------------ */
00046 
00047 /* subclasses of MAXWrapper act as MAXScript-side proxies for MAX-side objects,
00048  * such as nodes, modifiers, materials, etc.  The prime purpose of MAXWrapper is
00049  * to maintain MAX referenced to the MAX-side objects it wraps & process delete notify messages
00050  *
00051  * subclasses should all do a ReplaceReference for each ref on creation & check for 
00052  * any ref deletion on the MAX side by using the check_for_deletion() macro.
00053  */
00054 
00055 extern ScripterExport MCHAR* get_deleted_obj_err_message();
00056 
00057 #define check_for_deletion_test()                                           \
00058     (   ref_deleted ||                                                      \
00059         (   NumRefs() > 0 && (GetReference(0) == NULL) ) ||                 \
00060         (   NumRefs() > 0 &&                                                \
00061             GetReference(0)->TestAFlag(A_IS_DELETED) &&                     \
00062             (   (GetReference(0)->GetInterface(INODE_INTERFACE)==NULL) ||   \
00063                 (((INode*)GetReference(0))->GetTMController() == NULL) ||   \
00064                 (((INode*)GetReference(0))->GetParentNode() == NULL)        \
00065             )                                                               \
00066         )                                                                   \
00067     )
00068 #define check_for_deletion()  if (check_for_deletion_test()) throw RuntimeError (get_deleted_obj_err_message(), class_name());
00069 #define deletion_check_test(val)                                                    \
00070     (   (val)->ref_deleted ||                                                       \
00071         (   (val)->NumRefs() > 0 && ((val)->GetReference(0) == NULL) ) ||           \
00072         (   (val)->NumRefs() > 0 &&                                                 \
00073             (val)->GetReference(0)->TestAFlag(A_IS_DELETED) &&                      \
00074             (   ((val)->GetReference(0)->GetInterface(INODE_INTERFACE)==NULL) ||    \
00075                 (((INode*)(val)->GetReference(0))->GetTMController() == NULL) ||    \
00076                 (((INode*)(val)->GetReference(0))->GetParentNode() == NULL)         \
00077             )                                                                       \
00078         )                                                                           \
00079     )
00080 #define deletion_check(val)  if (deletion_check_test(val)) throw RuntimeError (get_deleted_obj_err_message(), (val)->class_name());
00081 
00082 
00083 
00084 
00085 visible_class (MAXWrapper)
00086 
00087 class MAXWrapper : public Value, public ReferenceTarget // ReferenceMaker
00088 {
00089 public:
00090     Tab<RefTargetHandle> refs;      /* reference array      */
00091     short       ref_deleted;         
00092 
00093     ScripterExport          MAXWrapper();
00094     ScripterExport virtual ~MAXWrapper();
00095     
00096     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
00097     using Collectable::operator new;
00098     using Collectable::operator delete;
00099         
00100     ScripterExport Value*       classOf_vf(Value** arg_list, int count);
00101     ScripterExport Value*       superClassOf_vf(Value** arg_list, int count);
00102     ScripterExport Value*       isKindOf_vf(Value** arg_list, int count);
00103     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXWrapper)) ? 1 : Value::is_kind_of(c); }
00104     ScripterExport BOOL     not_on_undo_stack();
00105     void                    collect() { if (not_on_undo_stack()) delete this; }
00106     ScripterExport void     gc_trace();
00107     virtual MCHAR* class_name() = 0;
00108     virtual ReferenceTarget* get_max_object() { return (NumRefs()) ? GetReference(0) : NULL; } // LAM - 7/18/01
00109     ScripterExport Value*       copy_no_undo(Value** arg_list, int count);
00110     BOOL        derives_from_MAXWrapper()  { return TRUE; } // LAM - 7/8/03 - defect 504956
00111 
00112     ScripterExport void make_ref(int ref_no, ReferenceTarget* ref);
00113     void        drop_MAX_refs() { DeleteAllRefsFromMe(); }
00114 
00115     bool        can_collect_in_gc_light(); // returns true if can collect maxwrapper during gc light:true
00116 
00117     // Animatable
00118     Class_ID ClassID() { return Class_ID(MAXSCRIPT_WRAPPER_CLASS_ID, 0); }
00119     SClass_ID SuperClassID() { return MAXSCRIPT_WRAPPER_CLASS_ID; }     
00120 
00121     // ReferenceMaker
00122     int         NumRefs() { return refs.Count(); }
00123     RefTargetHandle GetReference(int i) { return refs[i]; }
00124 protected:
00125     ScripterExport virtual void         SetReference(int i, RefTargetHandle rtarg);
00126 public:
00127     ScripterExport RefResult    NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID,  RefMessage message);
00128     ScripterExport void         DeleteThis();
00129     #pragma warning(push)
00130     #pragma warning(disable:4100)
00131     BOOL CanTransferReference(int i) { return FALSE; } 
00132 
00133     // For adding special cases for wrappers of object that we want to allow to be deleted
00134     // even though MAXScript may hold a reference to them.
00135     ScripterExport BOOL     IsRealDependency(ReferenceTarget *rtarg);
00136 
00137     // generic property accessors (operate on ref(0))
00138     ScripterExport Value*       get_property(Value** arg_list, int count);
00139     ScripterExport Value*       set_property(Value** arg_list, int count);
00140 
00141     // direct property access, when no wrapper exists, but we have the MAX-side ref
00142     static ScripterExport Value* get_property(ReferenceTarget* ref, Value* prop, Value* owner);
00143     static ScripterExport Value* set_property(ReferenceTarget* ref, Value* prop, Value* val);
00144 
00145 #ifdef def_generic
00146 #   undef def_generic
00147 #   undef def_generic_debug_ok
00148 #   undef def_property
00149 #   undef def_2_prop_path
00150 #   undef def_nested_prop
00151 #endif
00152 #ifdef def_prop_getter
00153 #   undef def_prop_getter
00154 #   undef def_prop_setter
00155 #endif
00156 
00157 #define def_generic(fn, name)   \
00158             ScripterExport Value* fn##_vf(Value** arglist, int arg_count)
00159 
00160 #define def_generic_debug_ok(fn, name)  \
00161     ScripterExport Value* fn##_vf(Value** arglist, int arg_count)
00162 
00163 #define def_property(p)                                     \
00164             ScripterExport Value*   get_##p(Value** arg_list, int count);   \
00165             ScripterExport Value*   set_##p(Value** arg_list, int count)
00166 #define def_prop_getter(p)                                  \
00167             ScripterExport Value*   get_##p(Value** arg_list, int count)
00168 #define def_prop_setter(p)                                  \
00169             ScripterExport Value*   set_##p(Value** arg_list, int count)
00170 #define def_2_prop_path(p1, p2)                                     \
00171             ScripterExport Value*   get_##p1##_##p2(Value** arg_list, int count);   \
00172             ScripterExport Value*   set_##p1##_##p2(Value** arg_list, int count)
00173 #define def_nested_prop(p1)                                         \
00174             ScripterExport Value*   get_nested_##p1(Value** arg_list, int count);   \
00175             ScripterExport Value*   set_nested_##p1(Value** arg_list, int count)
00176 
00177             def_generic( eq,        "=");
00178             def_generic( ne,        "!=");
00179 
00180             def_generic (coerce, "coerce"); // allow coercion to MAXRefTarg. Use for handling things like medit_materials as a reftarg
00181 
00182             def_generic (show_props, "showProperties");
00183             def_generic (get_props,  "getPropNames");
00184             def_generic (copy,       "copy");
00185             def_generic (isDeleted,  "isDeleted");
00186             def_generic (exprForMAXObject,  "exprForMAXObject");
00187 //          def_generic (dependsOn,  "dependsOn");
00188             def_generic (show_interfaces, "showInterfaces");
00189             def_generic (get_interfaces, "getInterfaces");
00190             def_generic (get_interface, "getInterface");
00191 
00192             // the standard transform subanim properties
00193             def_property    ( pos );
00194             def_2_prop_path ( pos, controller );
00195             def_2_prop_path ( pos, isAnimated );
00196             def_2_prop_path ( pos, keys );
00197             def_2_prop_path ( pos, track );
00198             def_2_prop_path ( pos, x );
00199             def_2_prop_path ( pos, y );
00200             def_2_prop_path ( pos, z );
00201             def_property    ( rotation );
00202             def_2_prop_path ( rotation, angle );
00203             def_2_prop_path ( rotation, x_rotation );
00204             def_2_prop_path ( rotation, y_rotation );
00205             def_2_prop_path ( rotation, z_rotation );
00206             def_2_prop_path ( rotation, axis );
00207             def_2_prop_path ( rotation, controller );
00208             def_2_prop_path ( rotation, isAnimated );
00209             def_2_prop_path ( rotation, keys );
00210             def_2_prop_path ( rotation, track );
00211             def_property    ( scale );
00212             def_2_prop_path ( scale, controller );
00213             def_2_prop_path ( scale, isAnimated );
00214             def_2_prop_path ( scale, keys );
00215             def_2_prop_path ( scale, track );
00216             def_2_prop_path ( scale, x );
00217             def_2_prop_path ( scale, y );
00218             def_2_prop_path ( scale, z );
00219             def_property    ( controller );
00220             def_property    ( transform );
00221             def_property    ( isAnimated );
00222             def_property    ( numsubs );
00223 
00224             def_nested_prop ( angle );
00225             def_nested_prop ( x_rotation );
00226             def_nested_prop ( y_rotation );
00227             def_nested_prop ( z_rotation );
00228             def_nested_prop ( axis );
00229             def_nested_prop ( controller );
00230             def_nested_prop ( isAnimated );
00231             def_nested_prop ( keys );
00232             def_nested_prop ( x );
00233             def_nested_prop ( y );
00234             def_nested_prop ( z );
00235             def_nested_prop ( w );
00236 
00237     // utility methods for the above subanim property accessors, implemented by 
00238     // those that have standard transform subsanims
00239     virtual Control* get_max_pos_controller(ParamDimension** pdim) { return NULL; }
00240     virtual Control* get_max_scale_controller(ParamDimension** pdim) { return NULL; }
00241     virtual Control* get_max_rotation_controller(ParamDimension** pdim) { return NULL; }
00242     virtual Control* get_max_tm_controller(ParamDimension** pdim) { return NULL; }
00243     virtual Control* get_max_controller(ParamDimension** pdim) { return NULL; }
00244     ScripterExport virtual Control* get_max_prop_controller(Value* prop, ParamDimension** pdim);
00245     virtual BOOL     set_max_pos_controller(MAXControl* c) { return FALSE; }
00246     virtual BOOL     set_max_scale_controller(MAXControl* c) { return FALSE; }
00247     virtual BOOL     set_max_rotation_controller(MAXControl* c) { return FALSE; }
00248     virtual BOOL     set_max_tm_controller(MAXControl* c) { return FALSE; }
00249     virtual BOOL     set_max_controller(MAXControl* c) { return FALSE; }
00250     ScripterExport virtual BOOL  set_max_prop_controller(Value* prop, MAXControl* c);
00251 
00252     static ScripterExport Control* get_max_prop_controller(ReferenceTarget* ref, Value* prop, ParamDimension** pdim);
00253     static ScripterExport BOOL     set_max_prop_controller(ReferenceTarget* ref, Value* prop, MAXControl* c);
00254 
00255     ScripterExport virtual BOOL is_max_prop_animatable(Value* prop);
00256 
00257     ScripterExport Value*       get_container_property(Value* prop, Value* cur_prop);
00258     ScripterExport Value*       set_container_property(Value* prop, Value* val, Value* cur_prop);
00259 
00260     // coordsystem mappers, default is no mapping
00261     virtual void    object_to_current_coordsys(Point3& p, int mode=0) { }
00262     virtual void    object_from_current_coordsys(Point3& p, int mode=0) { }
00263     virtual void    world_to_current_coordsys(Point3& p, int mode=0) { }
00264     virtual void    world_from_current_coordsys(Point3& p, int mode=0) { }
00265     virtual void    world_to_current_coordsys(Quat& q) { }
00266     virtual void    world_from_current_coordsys(Quat& q) { }
00267 
00268     // map to & from controller value coordsys, eg, parent for nodes, modcontext for modifiers, etc.
00269     virtual void    ctrl_to_current_coordsys(Point3& p, int mode=0) { }
00270     virtual void    ctrl_from_current_coordsys(Point3& p, int mode=0) { }
00271     virtual void    ctrl_to_current_coordsys(Quat& q) { }
00272     virtual void    ctrl_from_current_coordsys(Quat& q) { }
00273     virtual void    ctrl_to_current_coordsys(ScaleValue& s) { }
00274     virtual void    ctrl_from_current_coordsys(ScaleValue& s) { }
00275     #pragma warning(pop)
00276 
00277     virtual Matrix3& local_tm() { return idTM; }
00278     virtual Matrix3  local_tm_inv() { return Inverse(local_tm()); }
00279 
00280     // recursive time functions
00281     #undef def_time_fn
00282     #define def_time_fn(_fn) ScripterExport Value* _fn##_vf(Value** arglist, int arg_count)
00283     #include "..\protocols\timefunctions.inl"
00284     #undef def_time_fn
00285     #define def_time_fn(_fn) ScripterExport Value* _fn(Animatable* anim, Value** arglist, int arg_count)
00286     #include "..\protocols\timefunctions.inl" 
00287 
00288     // mesh & mesh-sub-object access setup
00289     ScripterExport virtual Mesh* set_up_mesh_access(int access, ReferenceTarget** owner = NULL);
00290     ScripterExport virtual Mesh* set_up_mesh_face_access(int index, int access, ReferenceTarget** owner = NULL);
00291     ScripterExport virtual Mesh* set_up_mesh_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00292     ScripterExport virtual MNMesh* set_up_mnmesh_access(int access, ReferenceTarget** owner = NULL);
00293     ScripterExport virtual MNMesh* set_up_mnmesh_face_access(int index, int access, ReferenceTarget** owner = NULL);
00294     ScripterExport virtual MNMesh* set_up_mnmesh_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00295     ScripterExport virtual BitArray get_vertsel();
00296     ScripterExport virtual BitArray get_facesel();
00297     ScripterExport virtual BitArray get_edgesel();
00298     ScripterExport virtual void set_vertsel(BitArray &sel);
00299     ScripterExport virtual void set_facesel(BitArray &sel);
00300     ScripterExport virtual void set_edgesel(BitArray &sel);
00301     ScripterExport virtual GenericNamedSelSetList& get_named_vertsel_set();
00302     ScripterExport virtual GenericNamedSelSetList& get_named_facesel_set();
00303     ScripterExport virtual GenericNamedSelSetList& get_named_edgesel_set();
00304     virtual void update_sel() { NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE); }
00305     ScripterExport virtual bool isPolyObject(int access);
00306     ScripterExport virtual IMeshSelectData* set_up_IMeshSelectData_access(int access, ReferenceTarget** owner);
00307 #ifndef NO_PATCHES
00308     ScripterExport virtual bool isPatchObject(int access);
00309     ScripterExport virtual PatchObject* set_up_patch_access(int access, ReferenceTarget** owner = NULL);
00310     ScripterExport virtual PatchObject* set_up_patch_face_access(int index, int access, ReferenceTarget** owner = NULL);
00311     ScripterExport virtual PatchObject* set_up_patch_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00312     ScripterExport virtual IPatchSelectData* set_up_IPatchSelectData_access(int access, ReferenceTarget** owner);
00313 #endif // NO_PATCHES
00314 
00315     def_property   ( category );
00316     def_prop_getter( classID );
00317     def_prop_getter( superclassID );
00318 
00319     def_generic ( get,               "get" );                   // <mw>[i] => subAnim[i]
00320     def_generic ( getSubAnim,        "getSubAnim" );            // equivalent 
00321     def_generic ( getSubAnimName,    "getSubAnimName" );
00322     def_generic ( getSubAnimNames,   "getSubAnimNames" );
00323     def_generic ( getAppData,        "getAppData");
00324     def_generic ( setAppData,        "setAppData");
00325     def_generic ( deleteAppData,     "deleteAppData");
00326     def_generic ( clearAllAppData,   "clearAllAppData");
00327     def_generic ( addPluginRollouts, "addPluginRollouts");
00328 
00329     ReferenceTarget* to_reftarg() { return get_max_object(); }
00330     void             to_fpvalue(FPValue& v) { v.r = get_max_object(); v.type = TYPE_REFTARG; }
00331 
00332     // scene I/O 
00333     ScripterExport IOResult Save(ISave* isave);
00334     static ScripterExport Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00335 
00336     // FPInterface access
00337     using ReferenceTarget::GetInterface;
00338     ScripterExport BaseInterface* GetInterface(Interface_ID id);
00339 };
00340 
00341 // coordsys mappers defines..
00342 #define NO_TRANSLATE    0x0001
00343 #define NO_SCALE        0x0002
00344 
00345 #define ctrl_to_current_coordsys_rotate(p)          ctrl_to_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00346 #define ctrl_from_current_coordsys_rotate(p)        ctrl_from_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00347 #define object_to_current_coordsys_rotate(p)        object_to_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00348 #define object_from_current_coordsys_rotate(p)      object_from_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00349 #define world_to_current_coordsys_rotate(p)         world_to_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00350 #define world_from_current_coordsys_rotate(p)       world_from_current_coordsys(p, NO_TRANSLATE + NO_SCALE)
00351 #define object_to_current_coordsys_scaleRotate(p)   object_to_current_coordsys(p, NO_TRANSLATE)
00352 #define object_from_current_coordsys_scaleRotate(p) object_from_current_coordsys(p, NO_TRANSLATE)
00353 
00354 /* ---------------------- MAXClass ----------------------- */
00355 
00356 #pragma warning(push)
00357 #pragma warning(disable:4201)
00358 
00359  /* this is the class that provides a runtime representation for
00360  * the classes of MAX objects.  It is essentially the MAXScript 
00361  * equivalent of the ClassDesc instance with extra metadata
00362  * about creation parameters, ec. */
00363 // parameter descriptor struct
00364 struct parm_desc            
00365 {
00366     Value*      name;           // parameter name
00367     MCHAR       desc_type;      // descriptor type... paramblock/fn/etc.
00368     MCHAR       flags;
00369     union
00370     {
00371         struct                  // paramblock entry descriptor
00372         {
00373             int     parm_id;    
00374         };
00375         struct                  // fn entry descriptor
00376         {
00377             max_getter_cf getter;
00378             max_setter_cf setter;
00379         };
00380         struct                  // subanim entry descriptor
00381         {
00382             int     subanim_num;    
00383         };
00384         struct                  // paramblockn - paramblock at given refno
00385         {
00386             int     refno;
00387             int     pbn_id;
00388         };
00389     };
00390     ParamType   type;           // common type code & initval
00391     union
00392     {
00393         float       fval;
00394         int         ival;
00395         BOOL            bval;
00396         INT_PTR     pval;
00397         struct      {float x, y, z, w;};
00398         struct      {float r, g, b, a;};
00399         struct      {float h, s, v;};
00400         struct      {int btn_min, btn_max, btn_val;};
00401     } init_val;
00402 } ;
00403 
00404 #pragma warning(pop) // 4201
00405 
00406 #define PD_NO_INIT          0x01    // flags this property as reqiring no init
00407 #define PD_LOCAL_DUP        0x02    // this is a duplicate local translation
00408 #define PD_HAS_LOCAL_DUPS   0x04    // this has duplicate local translations
00409 #define PD_SHOWN            0x08    // temp flag to mark already shown props in showProps()
00410 
00411 class MAXClass;
00412 class MAXSuperClass;
00413 
00414 struct superclass_table                 // entries in the superclass table
00415 {
00416     SClass_ID       key;
00417     MAXSuperClass*  mx_superclass;
00418 };
00419 
00420 typedef Value* (*maker_fn)(MAXClass* cls, ReferenceTarget* obj, Value** arglist, int count);
00421 
00422 visible_class_debug_ok (MAXSuperClass)
00423 
00424 class MAXSuperClass : public Value
00425 {
00426 public:
00427     Value*      name;
00428     SClass_ID   sclass_id;
00429     Value*      superclass;
00430     maker_fn    maker;
00431     short       n_parms;
00432     short       flags;
00433     parm_desc*  parms;
00434 
00435 // LAM 4/1/00 - exporting the following...
00436                 ScripterExport MAXSuperClass(MCHAR* cname, SClass_ID sid, Value* superClass, maker_fn maker, ...);
00437                 ScripterExport ~MAXSuperClass();
00438     void        complete_init();
00439 
00440     static superclass_table* superclasses;      // lookup table of all superclasses by SClass_ID
00441     static short             n_superclasses;
00442     static BOOL              superclass_table_dirty;
00443     static void              free_classes();    // deallocates superclasses memory and cleans up statics
00444     static MAXSuperClass*    lookup_superclass(SClass_ID sid);
00445 
00446     Value*      classOf_vf(Value** arg_list, int count);
00447     Value*      superClassOf_vf(Value** arg_list, int count);
00448     Value*      isKindOf_vf(Value** arg_list, int count);
00449 //  BOOL        is_kind_of(ValueMetaClass* c) { return ((c == class_tag(MAXWrapper)) ? 1 : Value::is_kind_of(c)); } // LAM: 2/23/01
00450     BOOL        is_kind_of(ValueMetaClass* c) { return ((c == class_tag(MAXSuperClass)) ? 1 : Value::is_kind_of(c)); }
00451 #   define is_maxsuperclass(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXSuperClass))
00452     void        collect() { delete this; }
00453     void        gc_trace();
00454     ScripterExport void sprin1(CharStream* s);
00455     void        export_to_scripter();
00456 
00457     ScripterExport short getNumSuperclasses ();
00458     ScripterExport MAXSuperClass* getSuperclass (int index);
00459 
00460     ScripterExport void apply_keyword_parms(ReferenceTarget* obj, Value** key_arg_list, int count);
00461 
00462                 def_generic (get_props, "getPropNames");
00463                 def_generic (show_interfaces, "showInterfaces"); // LAM - 6/29/00
00464                 def_generic (get_interfaces, "getInterfaces");
00465                 def_generic (get_interface, "getInterface");
00466 
00467     def_property( categories );
00468     def_property( classes );
00469 };
00470 
00471 extern ScripterExport MAXSuperClass* lookup_MAXSuperClass (SClass_ID scid);
00472 
00473 #define SC_SUPERCLASS_INITED    0x0001
00474 #define SC_NON_REFTARG          0x0002
00475 
00476 struct class_key
00477 {
00478     Class_ID    cid;
00479     SClass_ID   scid;
00480 };
00481 
00482 struct class_table              // entries in the class table
00483 {
00484     class_key   key;
00485     MAXClass*   mx_class;
00486 };
00487 
00488 enum metadata_flags
00489 {
00490     md_use_getref  = 0x0001,        /* class flags */
00491     md_use_getref0 = 0x0002,
00492     md_use_getref1 = 0x0004,
00493     md_no_create   = 0x0008,
00494     md_no_access   = 0x0010,
00495     md_direct_index = 0x0020,
00496     md_new_plugin  = 0x0040,
00497     md_auto_parms  = 0x0080,
00498     md_name_clash  = 0x0100,
00499     md_initialized  = 0x0200,
00500 };
00501 
00502 enum metadata_flag
00503 {
00504 //  end         = 0,                /* metadata vararg tags */
00505     getters     = 1,
00506     setters,
00507     accessors,
00508     path_getters,
00509     path_setters,
00510     path_accessors,
00511     fns,
00512     paramblock,
00513     subanims,
00514     paramblockn,
00515     subanimparamblock
00516 };
00517 
00518 enum
00519 {
00520     TYPE_POINT3_ANGLE   = TYPE_USER + 128,      /* MAXScript special paramblock types... */
00521     TYPE_POINT3_PCNT,
00522 
00523 };
00524 
00525 
00526 visible_class_debug_ok (MAXClass)
00527 
00528 class MAXClass : public Value
00529 {
00530 public:
00531     Value*          name;
00532     Class_ID        class_id;
00533     SClass_ID       sclass_id;
00534     ClassDesc*      cd;     
00535     ClassDesc2*     cd2;                // for now, pointer to ClassDesc2 if this class is PB2-based
00536     short           md_flags;
00537     int             n_parms;
00538     parm_desc*      parms;
00539     MAXSuperClass*  superclass;
00540     short           paramblock_ref_no;
00541     Value*          category;
00542     HashTable*      interfaces;         // plugin's FnPub published functions
00543 
00544     static class_table* classes;        // lookup table of all classes by Class_ID
00545     static int          n_classes;
00546     static BOOL         class_table_dirty;
00547     static void         free_classes(); // Free's up the classes member, and clears statics
00548     static ScripterExport MAXClass* lookup_class(Class_ID* cid, SClass_ID scid, bool make_new_if_missing = true);
00549 
00550                                    MAXClass() { }
00551                     ScripterExport MAXClass(MCHAR* cname, Class_ID cid, SClass_ID sid, MAXSuperClass* sclass, short cflags, ...);
00552                     ScripterExport ~MAXClass();
00553     ClassDesc*      complete_init();
00554 
00555     static void     setup();
00556     Value*          classOf_vf(Value** arg_list, int count);
00557     Value*          superClassOf_vf(Value** arg_list, int count);
00558     Value*          isKindOf_vf(Value** arg_list, int count);
00559     BOOL            is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXClass)) ? 1 : Value::is_kind_of(c); }
00560 #   define is_maxclass(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXClass))
00561     void            collect() { delete this; }
00562     void            gc_trace();
00563     ScripterExport void sprin1(CharStream* s);
00564     void            export_to_scripter();
00565 
00566     ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL);      // object creation by applying class object
00567 
00568     static ScripterExport Value* make_wrapper_for(ReferenceTarget* ref);
00569     static ScripterExport Value* make_node_for(ReferenceTarget* ref);
00570 
00571     parm_desc*      get_parm_desc(ReferenceTarget* ref, Value* key);
00572     BOOL            build_parm_descs(ReferenceTarget* ref);
00573     ScripterExport void apply_keyword_parms(ReferenceTarget* ref, Value** key_arg_list, int count);
00574     ScripterExport void initialize_object(ReferenceTarget* ref);
00575     Value*          get_max_property(ReferenceTarget* ref, parm_desc* pd, TimeValue t, Interval& valid);
00576     void            set_max_property(ReferenceTarget* ref, parm_desc* pd, TimeValue t, Value* val);
00577 
00578     // PB2-related
00579     ParamDef*       get_parm_def(Value* prop, ParamBlockDesc2*& pbd, int& tabIndex, ReferenceTarget* ref = NULL);
00580     void            set_max_property(ReferenceTarget* ref, ParamDef* pd, int tabIndex, ParamBlockDesc2* pbd, TimeValue t, Value* val);
00581     Value*          get_max_property(ReferenceTarget* ref, ParamDef* pd, int tabIndex, ParamBlockDesc2* pbd, TimeValue t, Interval& valid);
00582     static Value*   get_pb2_property(IParamBlock2* pb, ParamDef* pd, int tabIndex, TimeValue t, Interval& valid);
00583     static void     set_pb2_property(IParamBlock2* pb, ParamDef* pd, int tabIndex, TimeValue t, Value* val);
00584     static ParamDef* get_parm_def(ClassDesc2* cd2, Value* prop, ParamBlockDesc2*& pbd, int& tabIndex, ReferenceTarget* ref = NULL);
00585 
00586                     def_generic (get_props,        "getPropNames");
00587                     def_generic (create_instance,  "createInstance");
00588                     def_generic (show_interfaces,  "showInterfaces"); // LAM - 6/29/00
00589                     def_generic (get_interfaces, "getInterfaces");
00590                     def_generic (get_interface, "getInterface");
00591 
00592     Class_ID        get_max_class_id() { return class_id; }
00593 
00594     def_property   ( category );
00595     def_prop_getter( classID );
00596     def_prop_getter( superclassID );
00597     def_property    ( creatable );
00598 
00599     void            to_fpvalue(FPValue& v);
00600 
00601     Value*          Category();
00602 
00603     Value*          get_property(Value** arg_list, int count);
00604     Value*          set_property(Value** arg_list, int count);
00605 };
00606 
00607 /* MAX object makers... */
00608 
00609 Value* make_max_node(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00610 Value* make_max_object(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00611 Value* make_max_light(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00612 Value* make_max_camera(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00613 Value* make_max_modifier(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00614 Value* make_max_material(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00615 Value* make_max_texturemap(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00616 Value* make_max_mtlbase(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00617 Value* make_max_system(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00618 Value* make_max_helper(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00619 Value* make_max_controller(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00620 Value* make_max_atmospheric(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00621 Value* make_max_effect(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00622 Value* make_max_mpassCamEffect(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00623 Value* make_max_filter(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00624 Value* make_max_shadow(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00625 Value* make_max_reftarg(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00626 Value* no_max_maker(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count);
00627 Value* make_max_renderer(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00628 Value* make_max_custattrib(MAXClass* cls, ReferenceTarget* obj, Value** arg_list, int count); 
00629 
00630 extern ScripterExport MAXClass* lookup_MAXClass (Class_ID* cid, SClass_ID scid, bool make_new_if_missing = false);
00631 
00632 /* ------------------  MAXWrapper instance cache -----------------*/
00633 // MAXWrapper instance cache - it's critical we don't wind up generating a million
00634 // MAXWrappers with References to the same MAX-side object as this KILLS the collector
00635 // during the DeleteAllRefsFromMe() which seems to do a linear search through its refs
00636 
00637 // if object not found in cache, use FindMAXWrapperEnum (below) to search dependents
00638 // of the ReferenceTarget for a wrapper value
00639 
00640 #define MAXWRAPPER_CACHE_SIZE 2048          // must be power of 2
00641 extern ScripterExport MAXWrapper* maxwrapper_cache[];
00642 
00643 //#define MAXWRAPPER_CACHE_STATS  // uncomment to get maxwrapper cache hit/miss stats
00644 
00645 #ifndef MAXWRAPPER_CACHE_STATS
00646 
00647 inline BOOL
00648 _maxwrapper_cache_get(LONG_PTR index_ptr, MAXWrapper*** pw)
00649 {
00650     // compute cache index - fold halfwords & fold to cache size, get cache entry
00651     int index = DL_abs((int)((PointerLoPart(index_ptr) ^ PointerHiPart(index_ptr)))) % MAXWRAPPER_CACHE_SIZE;
00652     *pw = &maxwrapper_cache[index];
00653     // we match initially if entry contains a non-deleted MAXWrapper
00654     MAXWrapper* w = **pw;
00655     return (w && !w->ref_deleted);
00656 }
00657 
00658 // a macro for implementing MAXWrapper interning member functions
00659 #define maxwrapper_cache_get(_mw_class, _mw_ref, _mw_var, _ce_var)                                  \
00660     (_maxwrapper_cache_get((LONG_PTR)(_mw_ref) ^ (LONG_PTR)class_tag(_mw_class), (MAXWrapper***)&_ce_var) &&  \
00661     (_mw_var = *_ce_var)->tag == class_tag(_mw_class))
00662 
00663 #else
00664 
00665 static long _maxwrapper_cache_hit = 0;
00666 static long _maxwrapper_cache_miss = 0;
00667 static long _maxwrapper_cache_clash = 0;
00668 
00669 static BOOL
00670 _maxwrapper_cache_get(LONG_PTR index_ptr, MAXWrapper*** pw, ValueMetaClass* tag)
00671 {
00672     // compute cache index - fold halfwords & fold to cache size, get cache entry
00673     int index = DL_abs((UINT)((PointerLoPart(index_ptr) ^ PointerHiPart(index_ptr)))) % MAXWRAPPER_CACHE_SIZE;
00674     *pw = &maxwrapper_cache[index];
00675     // we match initially if entry contains a non-deleted MAXWrapper
00676     MAXWrapper* w = **pw;
00677     BOOL res_h = w && !w->ref_deleted;
00678     BOOL res_nc =  res_h && (w->tag == tag);
00679     if (res_h)
00680     {
00681         if (res_nc) 
00682             _maxwrapper_cache_hit++;
00683         else 
00684             _maxwrapper_cache_clash++;
00685     }
00686     else
00687         _maxwrapper_cache_miss++;
00688     return res_h;
00689 }
00690 
00691 #define maxwrapper_cache_get(_mw_class, _mw_ref, _mw_var, _ce_var)                                  \
00692     (_maxwrapper_cache_get((LONG_PTR)(_mw_ref) ^ (LONG_PTR)class_tag(_mw_class), (MAXWrapper***)&_ce_var, class_tag(_mw_class)) &&  \
00693     (_mw_var = *_ce_var)->tag == class_tag(_mw_class))
00694 
00695 #endif
00696 
00697 // We sometime combine a pointer to an object with another value and then send this to 
00698 // maxwrapper_cache_get.  This little inlined function takes care of the nitty-gritty
00699 // of Win64-correctness.
00700 inline LONG_PTR maxwrapper_genref(void* pObject, LONG_PTR index)
00701 {
00702    return(reinterpret_cast<LONG_PTR>(pObject) ^ index);
00703 }
00704 
00705 inline LONG_PTR maxwrapper_genref(void* pObject1, void* pObject2)
00706 {
00707    return(maxwrapper_genref(pObject1, reinterpret_cast<LONG_PTR>(pObject2)));
00708 }
00709 
00710 // Use the following in MAXWrapper-derived intern methods to determine if
00711 // a MXS value already wraps the ReferenceTarget, and return that value.
00712 // intern method should then that value. This guarantees a single MXS wrapper
00713 // value per ReferenceTarget
00714 // 
00715 class FindMAXWrapperEnum : public DependentEnumProc
00716 {
00717     ValueMetaClass* mytag;  // the type of MAXWrapper being created
00718     ReferenceTarget* myref; // the ReferenceTarget being searched
00719     void* arg;              // 2nd argument passed to finalCheckProc
00720     bool (*finalCheckProc)(MAXWrapper*, void*); // if needed, a secondary callback proc for testing the ReferenceTarget
00721     // needed for things like MAXTVNode, which consist of both a ReferenceTarget and an index
00722 public:
00723     FindMAXWrapperEnum(ReferenceTarget* ref, ValueMetaClass* tag, bool (*finalCheckProc)(MAXWrapper*, void*) = NULL, void* arg = NULL)
00724     {
00725         mytag = tag;
00726         myref = ref;
00727         result = NULL;
00728         this->finalCheckProc = finalCheckProc;
00729         this->arg = arg;
00730     }
00731     int proc(ReferenceMaker* rm)
00732     {
00733         if (rm == myref) 
00734             return DEP_ENUM_CONTINUE;
00735         if (rm->SuperClassID() == MAXSCRIPT_WRAPPER_CLASS_ID && 
00736             ((MAXWrapper*)rm)->tag == mytag &&
00737             rm->NumRefs() && rm->GetReference(0) == myref &&
00738             (finalCheckProc == NULL || (*finalCheckProc)((MAXWrapper*)rm, arg))
00739             ) 
00740         {
00741             result = (MAXWrapper*)rm;
00742             return DEP_ENUM_HALT;
00743         }
00744         return DEP_ENUM_SKIP; // just look at direct dependents
00745     }
00746     Value* result;
00747 };
00748 
00749     
00750 /* ------------------------ MAXNode class  ------------------------ */
00751 
00752 /* this class is the MAXScript wrapper for object hierarchy 
00753  * INodes. */
00754 
00755 // following will invalidate the node's rectangle in either the foreground or background
00756 // plane, depending on whether the node is in the foreground or not. Also sets that redraw 
00757 // is needed. This simply wraps INode::InvalidateRect(TimeValue, bool)
00758 extern ScripterExport void InvalidateNodeRect(INode*node, TimeValue t);
00759 
00760 // return values from GetINodeTabFromValue
00761 enum GetINodeTabResult
00762 {
00763     ResultOk,
00764     ErrSelectionEmpty,
00765     ErrRequireNodes
00766 };
00767 
00768 // Converts the specified value to an INodeTab. The specified value can be '$' (current selection set), a node collection,
00769 // or a single node. If pResult is != NULL and val is '$', then *pResult = NULL to signify the current selection set (some sdk
00770 // methods interpret an INodeTab* of NULL to mean the current selection set). Otherwise the node set is added to nodeTab and 
00771 // if pResult is != NULL, *pResult = &nodeTab.
00772 ScripterExport extern GetINodeTabResult GetINodeTabFromValue(Value* val, INodeTab& nodeTab, INodeTab** pResult);
00773 
00774 
00775 visible_class (MAXNode)
00776 
00777 class MAXNode : public MAXWrapper
00778 {
00779 public:
00780     INode*      node;
00781     
00782     ScripterExport MAXNode(INode* init_node);
00783     static ScripterExport Value* intern(INode* init_node);
00784 
00785     Value*      classOf_vf(Value** arg_list, int count);
00786     Value*      superClassOf_vf(Value** arg_list, int count);
00787     Value*      isKindOf_vf(Value** arg_list, int count);
00788     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXNode)) ? 1 : MAXWrapper::is_kind_of(c); }
00789 #   define is_node(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXNode))
00790     ScripterExport void sprin1(CharStream* s);
00791     MCHAR*      class_name();
00792     ScripterExport ReferenceTarget* get_max_object();
00793     ScripterExport static Value* ConvertTo(INode* node, Class_ID ccid);
00794 
00795 
00796     /* include all the protocol declarations */
00797 
00798 #include "..\macros\define_implementations.h"
00799 #   include "..\protocols\node.inl"
00800 
00801     def_generic( distance,          "distance" );  // shortcut distance fn for nodes
00802     def_generic( eq,                "=");
00803     def_generic( ne,                "!=");
00804     def_generic( coerce,            "coerce");
00805     def_generic (get_interfaces,    "getInterfaces");
00806     def_generic (get_interface,     "getInterface");
00807     
00808     /* declare built-in property accessors */
00809 
00810     def_property    ( dir );
00811     def_property    ( target );
00812     def_property    ( mat );
00813     def_property    ( modifiers );
00814     def_property    ( name );
00815     def_property    ( max );
00816     def_property    ( min );
00817     def_property    ( center );
00818     def_property    ( transform );
00819     def_property    ( parent );
00820     def_property    ( children );
00821     def_property    ( pivot );
00822     def_2_prop_path ( pivot, x );
00823     def_2_prop_path ( pivot, y );
00824     def_2_prop_path ( pivot, z );
00825     def_property    ( objectoffsetpos );
00826     def_property    ( objectoffsetrot );
00827     def_property    ( objectoffsetscale );
00828     def_property    ( objecttransform );
00829 
00830     def_nested_prop ( angle );
00831     def_nested_prop ( axis );
00832 
00833     /* mesh props */
00834 
00835     def_property    ( numverts );
00836     def_property    ( numtverts );
00837     def_property    ( numfaces );
00838     def_property    ( numcpvverts );
00839     def_property    ( mesh );
00840     def_property    ( displacementMapping );
00841     def_property    ( subdivisionDisplacement );
00842     def_property    ( splitMesh );
00843 
00844     /* mesh sub-objects (implemented in MeshSub.cpp) */
00845 
00846     def_property    ( vertices );
00847     def_property    ( selectedVertices );
00848     def_property    ( faces );
00849     def_property    ( selectedFaces );
00850     def_property    ( edges );
00851     def_property    ( selectedEdges );
00852 
00853     /* spline shape props */
00854 
00855     def_property    ( numsplines );
00856 
00857     /* general property & substructure access */
00858     
00859     Value*      get_property(Value** arg_list, int count);
00860     Value*      set_property(Value** arg_list, int count);
00861     Value*      find_modifier(Object* obj, Value* prop);
00862     Value*      get_property_via_metadata(Value* prop);
00863     Control*    get_max_prop_controller(Value* prop, ParamDimension** pdim);
00864     BOOL        set_max_prop_controller(Value* prop, MAXControl* c);
00865 
00866     /* children mappers */
00867     
00868     ScripterExport Value* map(node_map& m);
00869     ScripterExport Value* map_path(PathName* path, node_map& m);
00870     ScripterExport Value* find_first(BOOL (*test_fn)(INode* node, int level, void* arg), void* test_arg);
00871     ScripterExport Value* get_path(PathName* path);
00872 
00873     INode*      to_node() { check_for_deletion(); return node; }
00874     void        to_fpvalue(FPValue& v) { v.n = node; v.type = TYPE_INODE; }
00875 
00876     //  coordsystem mappers
00877     ScripterExport void object_to_current_coordsys(Point3& p, int mode=0);
00878     ScripterExport void object_from_current_coordsys(Point3& p, int mode=0);
00879     ScripterExport void world_to_current_coordsys(Point3& p, int mode=0);
00880     ScripterExport void world_from_current_coordsys(Point3& p, int mode=0);
00881     ScripterExport void world_to_current_coordsys(Quat& q);
00882     ScripterExport void world_from_current_coordsys(Quat& q);
00883     ScripterExport void world_to_current_coordsys(ScaleValue& s);
00884     ScripterExport void world_from_current_coordsys(ScaleValue& s);
00885 
00886     // standard transorm controller access
00887     Control*    get_max_pos_controller(ParamDimension** pdim);
00888     Control*    get_max_scale_controller(ParamDimension** pdim);
00889     Control*    get_max_rotation_controller(ParamDimension** pdim);
00890     Control*    get_max_tm_controller(ParamDimension** pdim);
00891     Control*    get_max_controller(ParamDimension** pdim);
00892     BOOL        set_max_pos_controller(MAXControl* c);
00893     BOOL        set_max_scale_controller(MAXControl* c);
00894     BOOL        set_max_rotation_controller(MAXControl* c);
00895     BOOL        set_max_tm_controller(MAXControl* c);
00896     BOOL        set_max_controller(MAXControl* c);
00897 
00898     void        ctrl_to_current_coordsys(Point3& p, int mode=0);
00899     void        ctrl_from_current_coordsys(Point3& p, int mode=0);
00900     void        ctrl_to_current_coordsys(Quat& q);
00901     void        ctrl_from_current_coordsys(Quat& q);
00902     void        ctrl_to_current_coordsys(ScaleValue& s);
00903     void        ctrl_from_current_coordsys(ScaleValue& s);
00904 
00905     // recursive time functions
00906     #undef def_time_fn
00907     #define def_time_fn(_fn) Value* _fn##_vf(Value** arglist, int arg_count)
00908     #include "..\protocols\timefunctions.inl"
00909 
00910     // mesh access setup
00911     Mesh*       set_up_mesh_access(int access, ReferenceTarget** owner = NULL);
00912     Mesh*       set_up_mesh_face_access(int index, int access, ReferenceTarget** owner = NULL);
00913     Mesh*       set_up_mesh_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00914     MNMesh*     set_up_mnmesh_access(int access, ReferenceTarget** owner = NULL);
00915     MNMesh*     set_up_mnmesh_face_access(int index, int access, ReferenceTarget** owner = NULL);
00916     MNMesh*     set_up_mnmesh_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00917     BitArray    get_vertsel();
00918     BitArray    get_facesel();
00919     BitArray    get_edgesel();
00920     void        set_vertsel(BitArray &sel);
00921     void        set_facesel(BitArray &sel);
00922     void        set_edgesel(BitArray &sel);
00923     GenericNamedSelSetList& get_named_vertsel_set();
00924     GenericNamedSelSetList& get_named_facesel_set();
00925     GenericNamedSelSetList& get_named_edgesel_set();
00926     void        update_sel();
00927     bool        isPolyObject(int access);
00928     IMeshSelectData* set_up_IMeshSelectData_access(int access, ReferenceTarget** owner);
00929     
00930     // Patch Access
00931 #ifndef NO_PATCHES
00932     bool isPatchObject(int access);
00933     PatchObject* set_up_patch_access(int access, ReferenceTarget** owner = NULL);
00934     PatchObject* set_up_patch_face_access(int index, int access, ReferenceTarget** owner = NULL);
00935     PatchObject* set_up_patch_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
00936     IPatchSelectData* set_up_IPatchSelectData_access(int access, ReferenceTarget** owner);
00937 #endif // NO_PATCHES
00938 
00939 };
00940 
00941 #define INODE_CLASS_ID      Class_ID(BASENODE_CLASS_ID, 0)  /* INode class ID for MAXScript metadata table indexing */
00942 #define INODE_SUPERCLASS_ID BASENODE_CLASS_ID
00943 
00944 /* ---------------------- MAXNodeChildrenArray ----------------------- */
00945 
00946 visible_class (MAXNodeChildrenArray)
00947 
00948 class MAXNodeChildrenArray : public Value, public Collection
00949 {
00950 public:
00951     MAXNode*        parent;             /* parent node */
00952 
00953     ENABLE_STACK_ALLOCATE(MAXNodeChildrenArray);
00954     ScripterExport MAXNodeChildrenArray(INode* parent);
00955     ScripterExport MAXNodeChildrenArray(MAXNode* parent);
00956 #   define      is_nodechildrenarray(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXNodeChildrenArray))
00957 
00958                 classof_methods (MAXNodeChildrenArray, Value);
00959     BOOL        _is_collection() { return 1; }
00960     void        collect() { delete this; }
00961     void        gc_trace();
00962     ScripterExport void     sprin1(CharStream* s);
00963 
00964     // operations
00965     ScripterExport Value* map(node_map& m);
00966 
00967 #include "..\macros\define_implementations.h"
00968 #   include "..\protocols\arrays.inl"
00969 
00970     // built-in property accessors
00971     def_property ( count );
00972     def_property ( center );
00973     def_property ( min );
00974     def_property ( max );
00975 
00976 };
00977 
00978 /* ---------------------- MAXObject ----------------------- */
00979 
00980 // generic wrapper for MAX reftarg objects (as opposed to nodes); ie, things inside nodes, mod stacks, etc.
00981 
00982 visible_class (MAXObject)
00983 
00984 class MAXObject : public MAXWrapper
00985 {
00986 public:
00987     Object* obj;                // the MAX-side object
00988 
00989     ScripterExport MAXObject(Object* o);
00990     static ScripterExport Value* intern(Object* o);
00991 #   define      is_maxobject(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXObject))
00992 
00993     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXObject)) ? 1 : MAXWrapper::is_kind_of(c); }
00994 
00995     void        collect() { delete this; }
00996     ScripterExport void sprin1(CharStream* s);
00997     MCHAR*      class_name();
00998 
00999     BOOL CanTransferReference(int i) { UNUSED_PARAM(i); return FALSE; }  // prevent mod applications from making us refer to a derived object
01000     
01001     def_property    ( mesh );
01002 
01003     Value*      get_property(Value** arg_list, int count);
01004     Value*      set_property(Value** arg_list, int count);
01005 
01006     void        to_fpvalue(FPValue& v) { v.obj = obj; v.type = TYPE_OBJECT; }
01007 
01008     def_visible_generic ( updateXRef,   "updateXRef");
01009 };
01010 
01011 /* ---------------------- MAXPB2ArrayParam ----------------------- */
01012 
01013 // a virtual array wrapper for ParamBlock2 Tab<> array parameters
01014 // allows indexed access to Tab<> paramaters held in ParamBlock2's
01015 
01016 visible_class (MAXPB2ArrayParam)
01017 
01018 #pragma warning(push)
01019 #pragma warning(disable:4100)
01020 class MAXPB2ArrayParam : public MAXWrapper, public Collection
01021 {
01022 public:
01023     IParamBlock2*       pblock;             // owning paramblock
01024     ParamDef*           pdef;               // Tab<> parameter def
01025 
01026                 MAXPB2ArrayParam(IParamBlock2* pb, ParamDef* pd);
01027     static ScripterExport Value* intern(IParamBlock2* pb, ParamDef* pd);
01028 
01029                 classof_methods (MAXPB2ArrayParam, MAXWrapper);
01030 #   define      is_tab_param(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXPB2ArrayParam))
01031     void        collect() { delete this; }
01032     ScripterExport void     sprin1(CharStream* s);
01033     MCHAR*      class_name() { return _M("Array Parameter"); }
01034 
01035     // operations
01036     ScripterExport Value* map(node_map& m);
01037 
01038 #include "..\macros\define_implementations.h"
01039 #   include "..\protocols\arrays.inl"
01040 
01041     def_generic( coerce,    "coerce");
01042     ScripterExport Value*       insertItem(Value** arg_list, int count); // called by insertItem_cf
01043 
01044     // built-in property accessors
01045     def_property ( count );
01046 
01047     // nested props on indexed elements (notably <param>[i].controller)
01048     ScripterExport Value*       get_container_property(Value* prop, Value* cur_prop);
01049     ScripterExport Value*       set_container_property(Value* prop, Value* val, Value* cur_prop);
01050 
01051     // NULL get/showprops
01052     Value* show_props_vf(Value** arg_list, int count) { return &false_value; }
01053     Value* get_props_vf(Value** arg_list, int count) { return &undefined; }
01054 };
01055 #pragma warning(pop) // 4100
01056 /* ---------------------- MAXModifier ----------------------- */
01057 
01058 /* generic wrapper for MAX modifiers. */
01059 
01060 visible_class (MAXModifier)
01061 
01062 class MAXModifier : public MAXWrapper
01063 {
01064 public:
01065     Modifier*   mod;            // the MAX-side modifier
01066 
01067     ScripterExport MAXModifier(Modifier* imod);
01068     static ScripterExport Value* intern(Modifier* imod);
01069 
01070 #   define is_modifier(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXModifier))
01071     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXModifier)) ? 1 : MAXWrapper::is_kind_of(c); }
01072     void        collect() { delete this; }
01073     ScripterExport void     sprin1(CharStream* s);
01074     MCHAR*      class_name();
01075 
01076     def_property    ( name );
01077     Value*      get_property(Value** arg_list, int count);
01078     Value*      set_property(Value** arg_list, int count);
01079 
01080     Modifier*   to_modifier() { check_for_deletion(); return mod; }
01081     void        to_fpvalue(FPValue& v) { v.r = mod; v.type = TYPE_REFTARG; }
01082 };
01083 
01084 visible_class (MAXModifierArray)
01085 
01086 class MAXModifierArray : public Value
01087 {
01088 public:
01089     MAXNode*    node;           /* the noed containing the modifiers */
01090 
01091     ENABLE_STACK_ALLOCATE(MAXModifierArray);
01092     ScripterExport  MAXModifierArray(INode* node);
01093     ScripterExport  MAXModifierArray(MAXNode* node);
01094 
01095                 classof_methods (MAXModifierArray, Value);
01096     void        collect() { delete this; }
01097     void        gc_trace();
01098     BOOL        _is_collection() { return 1; }
01099     ScripterExport void     sprin1(CharStream* s);
01100     Modifier*   get_modifier(int index);
01101     Modifier*   find_modifier(MCHAR* name);
01102     MCHAR*      class_name();
01103 
01104     // operations
01105     ScripterExport Value* map(node_map& m);
01106 
01107 #include "..\macros\define_implementations.h"
01108 #   include "..\protocols\arrays.inl"
01109 
01110     // built-in property accessors 
01111     def_property ( count );
01112 
01113 };
01114 
01115 /* ---------------------- MAXControl ----------------------- */
01116 
01117 /* generic wrapper for MAX controls. */
01118 
01121 #define REFMSG_MAXCONTROL_NOT_NEW   REFMSG_USER + 0x4af551aa
01122 
01123 visible_class (MAXControl)
01124 
01125 class MAXControl : public MAXWrapper
01126 {
01127 public:
01128     Control*         controller;            /* the MAX-side controller                  */
01129     ParamDimension*  dim;                   /* dimension from originating animatable    */
01130     short            flags;
01131 
01132     ScripterExport MAXControl(Control* icont, ParamDimension* idim);
01133     ScripterExport MAXControl(Control* icont, int flags = 0);
01134     static ScripterExport Value* intern(Control* icont, ParamDimension* idim);
01135     static ScripterExport Value* intern(Control* icont, int flags = 0);
01136 
01137     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXControl)) ? 1 : MAXWrapper::is_kind_of(c); }
01138     void        collect() { delete this; }
01139     ScripterExport void     sprin1(CharStream* s);
01140     MCHAR*      class_name();
01141 #   define is_controller(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXControl))
01142 
01143     RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message);
01144 
01145 
01146     // the non-recursive controller ops... (recursive's are implemented as MAXWrapper methods)
01147     #include "..\macros\define_implementations.h"
01148     use_generic          ( copy,    "copy");
01149     def_visible_generic  ( supportsTimeOperations,  "supportsTimeOperations");
01150     def_visible_generic  ( getTimeRange,            "getTimeRange");
01151     def_visible_generic  ( deleteKey,               "deleteKey");
01152     def_visible_generic  ( selectKey,               "selectKey");
01153     def_visible_generic  ( deselectKey,             "deselectKey");
01154     def_visible_generic  ( isKeySelected,           "isKeySelected");
01155     def_visible_generic  ( moveKey,                 "moveKey");
01156     def_visible_generic  ( numKeys,                 "numKeys");
01157     def_visible_generic  ( getKey,                  "getKey");
01158     def_visible_generic  ( getKeyTime,              "getKeyTime");
01159     def_visible_generic  ( getKeyIndex,             "getKeyIndex");
01160     def_visible_generic  ( numSelKeys,              "numSelKeys");
01161     def_visible_generic  ( numEaseCurves,           "numEaseCurves");
01162     def_visible_generic  ( applyEaseCurve,          "applyEaseCurve");
01163     def_visible_generic  ( addMultiplierCurve,      "addMultiplierCurve");
01164     def_visible_generic  ( deleteMultiplierCurve,   "deleteMultiplierCurve");
01165     def_visible_generic  ( numMultiplierCurves,     "numMultiplierCurves");
01166     def_visible_generic  ( getMultiplierValue,      "getMultiplierValue");
01167     def_visible_generic  ( getBeforeORT,            "getBeforeORT");
01168     def_visible_generic  ( getAfterORT,             "getAfterORT");
01169 
01170     // built-in property accessors 
01171     def_property ( value );
01172     def_property ( keys );
01173 
01174     Control*    to_controller() { check_for_deletion(); return controller; }
01175     void        to_fpvalue(FPValue& v) { v.ctrl = controller; v.type = TYPE_CONTROL; }
01176 
01177     // trap reduceKeys() here to supply controllers dim
01178     def_visible_generic  ( reduceKeys,              "reduceKeys");
01179 
01180     Value*      get_property(Value** arg_list, int count); // LAM - 11/16/02
01181     Value*      set_property(Value** arg_list, int count);
01182 };
01183 
01184 #define MAX_CTRL_NO_DIM     0x01        // indicates no explicit dimension yet assigned
01185 #define MAX_CTRL_NEW        0x02        // new controller, copy(old) when first assigned
01186 
01187 /* ---------------------- MAXSubAnim ----------------------- */
01188 
01189 /* generic wrapper for MAX subanims. */
01190 
01191 visible_class (MAXSubAnim)
01192 
01193 class MAXSubAnim : public MAXWrapper
01194 {
01195 public:
01196     ReferenceTarget* ref;                   /* parent object */
01197     int              subanim_num;           /* the subanim index */
01198 
01199     ScripterExport MAXSubAnim(ReferenceTarget* ref, int index);
01200     static ScripterExport Value* intern(ReferenceTarget* ref, int index);
01201 
01202                 classof_methods(MAXSubAnim, MAXWrapper);
01203     void        collect() { delete this; }
01204     ScripterExport void     sprin1(CharStream* s);
01205     MCHAR*      class_name() { return _M("SubAnim"); }
01206     ScripterExport ReferenceTarget* get_max_object();
01208     Value* _set_property(Value* prop, Value* val) { UNUSED_PARAM(prop); return val; } 
01209 #   define is_subAnim(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXSubAnim))
01210 
01211     // standard transform controller access
01212     Control*    get_max_pos_controller(ParamDimension** pdim);
01213     Control*    get_max_scale_controller(ParamDimension** pdim);
01214     Control*    get_max_rotation_controller(ParamDimension** pdim);
01215     Control*    get_max_tm_controller(ParamDimension** pdim);
01216     Control*    get_max_controller(ParamDimension** pdim);
01217     BOOL        set_max_pos_controller(MAXControl* c);
01218     BOOL        set_max_scale_controller(MAXControl* c);
01219     BOOL        set_max_rotation_controller(MAXControl* c);
01220     BOOL        set_max_tm_controller(MAXControl* c);
01221     BOOL        set_max_controller(MAXControl* c);
01222 
01223     def_property( controller );
01224     def_property( isAnimated );
01225     def_property( keys );
01226     def_property( value );
01227     def_property( object );
01228     def_property( name );
01229     def_property( parent );
01230     def_property( index );
01231 
01232     // these converters all attempt to bounce off the subanim object
01233     Value*      subanim_obj();
01234 
01235     INode*      to_node()       { return subanim_obj() != this ? subanim_obj()->to_node() : Value::to_node(); }
01236     Mtl*        to_mtl()        { return subanim_obj() != this ? subanim_obj()->to_mtl() : Value::to_mtl(); }
01237     Texmap*     to_texmap()     { return subanim_obj() != this ? subanim_obj()->to_texmap() : Value::to_texmap(); }
01238     Modifier*   to_modifier()   { return subanim_obj() != this ? subanim_obj()->to_modifier() : Value::to_modifier(); }
01239     Control*    to_controller() { return subanim_obj() != this ? subanim_obj()->to_controller() : Value::to_controller() ; }
01240     Atmospheric* to_atmospheric() { return subanim_obj() != this ? subanim_obj()->to_atmospheric() : Value::to_atmospheric(); }
01241     Effect*     to_effect() { return subanim_obj() != this ? subanim_obj()->to_effect() : Value::to_effect(); }
01242     ITrackViewNode* to_trackviewnode() { return subanim_obj() != this ? subanim_obj()->to_trackviewnode() : Value::to_trackviewnode(); }
01243     void        to_fpvalue(FPValue& v);
01244 };
01245 
01246 /* ---------------------- MAXRefTarg ----------------------- */
01247 // generic wrapper for MAX ReferenceTargets.
01248 
01249 visible_class (MAXRefTarg)
01250 
01251 class MAXRefTarg : public MAXWrapper
01252 {
01253 public:
01254     ReferenceTarget* ref;                   /* the object */
01255 
01256     ScripterExport MAXRefTarg(ReferenceTarget* ref);
01257     static ScripterExport Value* intern(ReferenceTarget* ref);
01258 
01259 //              classof_methods(MAXRefTarg, MAXWrapper);
01260     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXRefTarg)) ? 1 : MAXWrapper::is_kind_of(c); }
01261     void        collect() { delete this; }
01262     ScripterExport void     sprin1(CharStream* s);
01263     MCHAR*      class_name() { return _M("MAXRefTarg"); }
01264 
01265 };
01266 
01267 /* ---------------------- MAXTVNode ----------------------- */
01268 
01269 // generic wrapper for MAX TrackView Nodes. 
01270 
01271 visible_class (MAXTVNode)
01272 
01273 class MAXTVNode : public MAXWrapper
01274 {
01275 public:
01276     ITrackViewNode*  parent;        // parent node
01277     int              index;         // the TVNode index
01278     ITrackViewNode*  me;            // LAM - 8/11/02 - defect 507276 - leaf class, not used outside MXS
01279 
01280     ScripterExport MAXTVNode(ITrackViewNode* parent, int index);
01281     static ScripterExport Value* intern(ITrackViewNode* parent, int index);
01282     static ScripterExport Value* intern(ITrackViewNode* itvnode);  // new to max 2010
01283 
01284                 classof_methods (MAXTVNode, MAXWrapper);
01285     void        collect() { delete this; }
01286     ScripterExport void     sprin1(CharStream* s);
01287     MCHAR*      class_name() { return _M("TrackViewNode"); }
01288     ReferenceTarget* get_max_object();
01289     ScripterExport ITrackViewNode* get_tvnode();  // new to max 2010
01290 
01291     Value*      get_property(Value** arg_list, int count);
01292     Value*      set_property(Value** arg_list, int count);
01293 
01294     Control* get_max_prop_controller(Value* prop, ParamDimension** pdim);
01295     BOOL     set_max_prop_controller(Value* prop, MAXControl* c);
01296     Control* get_max_pos_controller(ParamDimension** pdim) { return get_max_prop_controller(n_position, pdim); }
01297     Control* get_max_scale_controller(ParamDimension** pdim) { return get_max_prop_controller(n_scale, pdim); }
01298     Control* get_max_rotation_controller(ParamDimension** pdim) { return get_max_prop_controller(n_rotation, pdim); }
01299 
01300     def_generic  ( get_props,  "getPropNames" );
01301     def_property ( name );
01302 
01303     RefResult   NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID,  RefMessage message);
01304     BOOL        IsRealDependency(ReferenceTarget *rtarg);
01305 
01306     ITrackViewNode* to_trackviewnode() { check_for_deletion(); return (parent == NULL) ? MAXScript_interface->GetTrackViewRootNode() : parent->GetNode(index); }
01307 };
01308 
01309 /* ---------------------- TrackViewPick ----------------------- */
01310 
01311 visible_class (TrackViewPickValue)
01312 
01313 class TrackViewPickValue : public Value
01314 {
01315 public:
01316     TrackViewPick       track;
01317     Value*              client;
01318     Value*              anim;
01319     int                 sub_num;
01320     MSTR                name;
01321     ScripterExport      TrackViewPickValue(TrackViewPick pick);
01322                         classof_methods (TrackViewPickValue, Value);
01323     void                collect() { delete this; }
01324     ScripterExport  void    sprin1(CharStream* s);
01325     void                gc_trace();
01326 #   define              is_trackviewpick(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(TrackViewPickValue))
01327     Value*              get_property(Value** arg_list, int count);
01328     Value*              set_property(Value** arg_list, int count);  
01329 };
01330 
01331 visible_class (MAXTVUtility)
01332 
01333 class MAXTVUtility : public MAXWrapper
01334 {
01335 public:
01336     ITreeView*          tv;         // the trackview the utility was created in
01337     MSTR                name;
01338     TrackViewUtility*   tvUtil;
01339 
01340     ScripterExport          MAXTVUtility(TrackViewUtility* util, ITreeView* tv);
01341     static ScripterExport Value* intern(TrackViewUtility* util, ITreeView* tv);
01342 
01343     BOOL                    is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXTVUtility)) ? 1 : MAXWrapper::is_kind_of(c); }
01344     MCHAR*                  class_name();
01345     void                    collect() { delete this; }
01346     ScripterExport void     sprin1(CharStream* s);
01347     void                    gc_trace();
01348 
01349     Value*                  get_property(Value** arg_list, int count);
01350     Value*                  set_property(Value** arg_list, int count);
01351 
01352     def_generic  ( get_props,  "getPropNames" );
01353     def_property ( name );
01354 };
01355 
01356 
01357 /* ---------------------- MAXMeshClass ----------------------- */
01358 // the sole instance of the MAXMeshClass represents the Nodes made from the core tri-mesh object class TriObject.
01359 // reflecting its special status in MAX, it is defined by a separate class in MAXScript,
01360 // allowing access to all the things you want to get at when procedurally working 
01361 // with meshes.
01362  
01363 visible_class (MAXMeshClass)
01364 
01365 class MAXMeshClass : public Value
01366 {
01367 public:
01368                 MAXMeshClass();
01369 
01370                 classof_methods (MAXMeshClass, Value);
01371     void        collect() { delete this; }
01372     ScripterExport void     sprin1(CharStream* s);
01373     void        export_to_scripter();
01374 
01375     ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL);      // object creation by applying class object
01376     Class_ID    get_max_class_id() { return triObjectClassID; } 
01377 };
01378 
01379 /* ---------------------- MeshValue ----------------------- */
01380 // A wrapper for the MAX SDK Mesh objects, typically used in Object plugins for creating scene
01381 // object meshes
01382 
01383 applyable_class (MeshValue)
01384 
01385 class MeshValue : public MAXWrapper
01386 {
01387 public:
01388     Object*     obj;        // MAX object if indirect ref to mesh (ref 0)
01389     Mesh*       mesh;       // direct mesh ref
01390     BOOL        owned;      // if direct ref owned by this value (& so s/b deleted on collect)
01391 
01392     ScripterExport MeshValue(Mesh* imesh, BOOL owned = FALSE);
01393     ScripterExport MeshValue(Object* obj);
01394     static ScripterExport Value* intern(Object* obj);
01395                ~MeshValue();
01396 
01397                 classof_methods (MeshValue, MAXWrapper);
01398 #   define is_mesh(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MeshValue))
01399     void        collect() { delete this; }
01400     void        sprin1(CharStream* s);
01401     MCHAR*      class_name() { return _M("TriMesh"); }
01402     ReferenceTarget* get_max_object() { return obj; }
01403 protected:
01404     virtual void        SetReference(int i, RefTargetHandle rtarg);
01405 public:
01406     RefResult   NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID,  RefMessage message);
01408     BOOL        CanTransferReference(int i) { UNUSED_PARAM(i); return FALSE; }
01409     BOOL        IsRealDependency(ReferenceTarget* target); 
01410 
01411     void        setup_mesh(int access = MESH_READ_ACCESS);
01412 
01413     // mesh protocol (same as for MAXNode)
01414     def_generic             ( setvert,              "setvert");
01415     def_generic_debug_ok    ( getvert,              "getvert");
01416     def_generic             ( settvert,             "settvert");
01417     def_generic_debug_ok    ( gettvert,             "gettvert");
01418     def_generic             ( setvertcolor,         "setvertcolor");
01419     def_generic_debug_ok    ( getvertcolor,         "getvertcolor");
01420     def_generic             ( setnumverts,          "setnumverts");
01421     def_generic_debug_ok    ( getnumverts,          "getnumverts");
01422     def_generic             ( setnumtverts,         "setnumtverts");
01423     def_generic_debug_ok    ( getnumtverts,         "getnumtverts");
01424     def_generic             ( setnumcpvverts,       "setnumcpvverts");
01425     def_generic_debug_ok    ( getnumcpvverts,       "getnumcpvverts");
01426     def_generic             ( setnumfaces,          "setnumfaces");
01427     def_generic_debug_ok    ( getnumfaces,          "getnumfaces");
01428     def_generic             ( buildtvfaces,         "buildTVFaces");
01429     def_generic             ( buildvcfaces,         "buildVCFaces");
01430     def_generic             ( defaultvcfaces,       "defaultVCFaces");
01431     def_generic_debug_ok    ( getnormal,            "getnormal");
01432     def_generic             ( setnormal,            "setnormal");
01433     def_generic             ( setface,              "setface");
01434     def_generic_debug_ok    ( getface,              "getface");
01435     def_generic             ( settvface,            "setTVFace");
01436     def_generic_debug_ok    ( gettvface,            "getTVFace");
01437     def_generic             ( setvcface,            "setVCFace");
01438     def_generic_debug_ok    ( getvcface,            "getVCFace");
01439     def_generic_debug_ok    ( getfacenormal,        "getfacenormal");
01440     def_generic             ( setfacenormal,        "setfacenormal");
01441     def_generic             ( setfacematid,         "setfaceMatID");
01442     def_generic_debug_ok    ( getfacematid,         "getfaceMatID");
01443     def_generic             ( setfacesmoothgroup,   "setfaceSmoothGroup");
01444     def_generic_debug_ok    ( getfacesmoothgroup,   "getfaceSmoothGroup");
01445     def_generic             ( setedgevis,           "setedgevis");
01446     def_generic_debug_ok    ( getedgevis,           "getedgevis");
01447     def_generic             ( detachVerts,          "detachVerts");
01448     def_generic             ( detachFaces,          "detachFaces");
01449     def_generic             ( extrudeface,          "extrudeface");
01450     def_generic             ( deletevert,           "deletevert");
01451     def_generic             ( deleteface,           "deleteface");
01452     def_generic             ( collapseface,         "collapseface");
01453     def_generic             ( setMesh,              "setMesh");
01454     def_generic             ( update,               "update");
01455     def_generic_debug_ok    ( getVertSelection,     "getVertSelection");
01456     def_generic             ( setVertSelection,     "setVertSelection"); 
01457     def_generic_debug_ok    ( getFaceSelection,     "getFaceSelection");  
01458     def_generic             ( setFaceSelection,     "setFaceSelection");  
01459     def_generic_debug_ok    ( getEdgeSelection,     "getEdgeSelection");  
01460     def_generic             ( setEdgeSelection,     "setEdgeSelection"); 
01461 
01462     def_generic             ( copy,                 "copy");  
01463     def_generic             ( delete,               "delete");  
01464     use_generic             ( plus,                 "+" );      // mesh boolean ops
01465     use_generic             ( minus,                "-" );
01466     use_generic             ( times,                "*" );
01467 
01468     use_generic             ( move,                 "move" );       // transform verts
01469     use_generic             ( rotate,               "rotate" );
01470     use_generic             ( scale,                "scale" );
01471     use_generic             ( transform,            "transform" );
01472 
01473     use_generic             ( free,                 "free");
01474 
01475     def_property( numverts );
01476     def_property( numtverts );
01477     def_property( numfaces );
01478     def_property( numcpvverts );
01479     def_property( mesh );
01480 
01481     def_property( vertices );
01482     def_property( selectedVertices );
01483     def_property( faces );
01484     def_property( selectedFaces );
01485     def_property( edges );
01486     def_property( selectedEdges );
01487 
01488 
01489     Mesh*       to_mesh() { setup_mesh(); return mesh; }
01490     void        to_fpvalue(FPValue& v) { setup_mesh(); v.msh = mesh; v.type = TYPE_MESH; }
01491     
01492     Value*      get_property(Value** arg_list, int count);
01493     Value*      set_property(Value** arg_list, int count);
01494 
01495     BitArray    get_vertsel() { setup_mesh(); return mesh->vertSel; }
01496     BitArray    get_facesel() { setup_mesh(); return mesh->faceSel; }
01497     BitArray    get_edgesel() { setup_mesh(); return mesh->edgeSel; }
01498     void        set_vertsel(BitArray &sel) { setup_mesh(MESH_WRITE_ACCESS); mesh->vertSel = sel; }
01499     void        set_facesel(BitArray &sel) { setup_mesh(MESH_WRITE_ACCESS); mesh->faceSel = sel; }
01500     void        set_edgesel(BitArray &sel) { setup_mesh(MESH_WRITE_ACCESS); mesh->edgeSel = sel; }
01501     Mesh*       set_up_mesh_access(int access, ReferenceTarget** owner = NULL);
01502     Mesh*       set_up_mesh_face_access(int index, int access, ReferenceTarget** owner = NULL);
01503     Mesh*       set_up_mesh_vertex_access(int index, int access, ReferenceTarget** owner = NULL);
01504 };
01505 
01506 /* ---------------------- MAXAtmospheric ----------------------- */
01507 
01508 visible_class (MAXAtmospheric)
01509 
01510 class MAXAtmospheric : public MAXWrapper
01511 {
01512 public:
01513     Atmospheric*    atmos;          // the MAX-side Atmospheric
01514 
01515     ScripterExport MAXAtmospheric(Atmospheric* iatmos);
01516     static ScripterExport Value* intern(Atmospheric* iatmos);
01517 
01518     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXAtmospheric)) ? 1 : MAXWrapper::is_kind_of(c); }
01519     void        collect() { delete this; }
01520     ScripterExport void     sprin1(CharStream* s);
01521     MCHAR*      class_name() { return _M("Atmospheric"); }
01522 
01523 #include "..\macros\define_implementations.h"
01524     #include "..\protocols\atmospherics.inl"
01525 
01526     def_property    ( name );
01527     def_prop_getter ( numGizmos );
01528 
01529     Atmospheric*    to_atmospheric() { check_for_deletion(); return atmos; }
01530 };
01531 
01532 /* ---------------------- MAXEffect ----------------------- */
01533 
01534 visible_class (MAXEffect)
01535 
01536 class MAXEffect : public MAXWrapper
01537 {
01538 public:
01539     Effect* effect;         // the MAX-side Effect
01540 
01541     ScripterExport MAXEffect(Effect* ieffect);
01542     static ScripterExport Value* intern(Effect* ieffect);
01543 
01544     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXEffect)) ? 1 : MAXWrapper::is_kind_of(c); }
01545     void        collect() { delete this; }
01546     ScripterExport void     sprin1(CharStream* s);
01547     MCHAR*      class_name() { return _M("Effect"); }
01548 
01549 #include "..\macros\define_implementations.h"
01550     #include "..\protocols\atmospherics.inl"
01551 
01552     def_property    ( name );
01553     def_prop_getter ( numGizmos );
01554 
01555     Effect* to_effect() { check_for_deletion(); return effect; }
01556 };
01557 
01558 /* ---------------------- MAXMultiPassCameraEffect ----------------------- */
01559 
01560 visible_class (MAXMultiPassCameraEffect)
01561 
01562 class MAXMultiPassCameraEffect : public MAXWrapper
01563 {
01564 public:
01565     IMultiPassCameraEffect* effect;         // the MAX-side Effect
01566 
01567     ScripterExport MAXMultiPassCameraEffect(IMultiPassCameraEffect* ieffect);
01568     static ScripterExport Value* intern(IMultiPassCameraEffect* ieffect);
01569 
01570     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXMultiPassCameraEffect)) ? 1 : MAXWrapper::is_kind_of(c); }
01571     void        collect() { delete this; }
01572     ScripterExport void     sprin1(CharStream* s);
01573     MCHAR*      class_name() { return _M("MultiPassCameraEffect"); }
01574 
01575     def_generic( iscompatible,  "isCompatible");
01576 
01577     IMultiPassCameraEffect* to_mpassCamEffect() { check_for_deletion(); return effect; }
01578 };
01579 
01580 /* ---------------------- MAXShadowType ----------------------- */
01581 
01582 visible_class (MAXShadowType)
01583 
01584 class MAXShadowType : public MAXWrapper
01585 {
01586 public:
01587     ShadowType* shadow;         // the MAX-side Effect
01588 
01589     ScripterExport MAXShadowType(ShadowType* ishadow);
01590     static ScripterExport Value* intern(ShadowType* ishadow);
01591 
01592     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXShadowType)) ? 1 : MAXWrapper::is_kind_of(c); }
01593     void        collect() { delete this; }
01594     ScripterExport void     sprin1(CharStream* s);
01595     MCHAR*      class_name() { return _M("MAXShadowType"); }
01596 
01597     ShadowType* to_shadowtype() { check_for_deletion(); return shadow; }
01598 };
01599 
01600 
01601 /* ---------------------- MAXRenderer ----------------------- */
01602 
01603 visible_class (MAXRenderer)
01604 
01605 class MAXRenderer : public MAXWrapper
01606 {
01607 public:
01608     Renderer*   renderer;           // the MAX-side Renderer
01609 
01610     ScripterExport MAXRenderer(Renderer* irenderer);
01611     static ScripterExport Value* intern(Renderer* irenderer);
01612 
01613     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXRenderer)) ? 1 : MAXWrapper::is_kind_of(c); }
01614     void        collect() { delete this; }
01615     ScripterExport void     sprin1(CharStream* s);
01616     MCHAR*      class_name() { return _M("MAXRenderer"); }
01617 
01618     Value*      get_property(Value** arg_list, int count);
01619     Value*      set_property(Value** arg_list, int count);
01620 
01621     Renderer*   to_renderer() { check_for_deletion(); return renderer; }
01622 };
01623 
01624 /* ---------------------- MAXCustAttrib ----------------------- */
01625 
01626 visible_class (MAXCustAttrib)
01627 
01628 class MAXCustAttrib : public MAXWrapper
01629 {
01630 public:
01631     CustAttrib* custattrib;     
01632 
01633     ScripterExport MAXCustAttrib(CustAttrib* icustattrib);
01634     static ScripterExport Value* intern(CustAttrib* icustattrib);
01635 #   define      is_custattrib(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXCustAttrib))
01636 
01637     BOOL        is_kind_of(ValueMetaClass* c) { return (c == class_tag(MAXCustAttrib)) ? 1 : MAXWrapper::is_kind_of(c); }
01638     void        collect() { delete this; }
01639     ScripterExport void     sprin1(CharStream* s);
01640     MCHAR*      class_name() { return _M("MAXCustAttrib"); }
01641 
01642 //  Value*      get_property(Value** arg_list, int count);
01643 //  Value*      set_property(Value** arg_list, int count);
01644 
01645     def_property   ( name );
01646     CustAttrib* to_custattrib() { check_for_deletion(); return custattrib; }
01647 };
01648 
01649 
01650 visible_class (MAXCustAttribArray)
01651 
01652 class MAXCustAttribArray : public Value
01653 {
01654 public:
01655     MAXWrapper*     ref;            /* the ref containing the CAs */
01656 
01657     ENABLE_STACK_ALLOCATE(MAXCustAttribArray);
01658     ScripterExport  MAXCustAttribArray(MAXWrapper* ref);
01659     ScripterExport  MAXCustAttribArray(ReferenceTarget* ref);
01660     ScripterExport  MAXCustAttribArray(MAXRefTarg* ref);
01661 
01662                 classof_methods (MAXCustAttribArray, Value);
01663     void        collect() { delete this; }
01664     void        gc_trace();
01665     BOOL        _is_collection() { return 1; }
01666     ScripterExport void     sprin1(CharStream* s);
01667     CustAttrib* get_CustAttrib(int index);
01668     CustAttrib* find_CustAttrib(MCHAR* name);
01669 
01670     // operations
01671     ScripterExport Value* map(node_map& m);
01672 
01673 #include "..\macros\define_implementations.h"
01674 #   include "..\protocols\arrays.inl"
01675 
01676     // built-in property accessors 
01677     def_property ( count );
01678 
01679 };
01680 
01681 
01682 /* ---------------------- ChangeHandler ----------------------- */
01683 
01684 /* maintains notification references to a bunch of objects & a scitped function
01685  * to execute if one changes - runtime object for the 'on object changed ....' construct */
01686 class ChangeHandler;
01687 
01688 visible_class (ChangeHandler)
01689 
01690 class CHTimeChangeCallback : public TimeChangeCallback
01691 {
01692 public:
01693     static BOOL registered;                 // if active
01694     static Tab<ChangeHandler*> handlers;    // active handlers
01695     static BOOL notified;                   // set if any delayed-handle events have been notified
01696     public:
01697         void TimeChanged(TimeValue t);
01698 };
01699 
01700 class CHRedrawViewsCallback : public RedrawViewsCallback
01701 {
01702 public:
01703     static BOOL registered;                 // if active
01704     static Tab<ChangeHandler*> handlers;    // active handlers
01705     static BOOL notified;                   // set if any delayed-handle events have been notified
01706     public:
01707         void proc(Interface *ip);
01708 };
01709 
01710 class ChangeHandler : public MAXWrapper
01711 {
01712 public:
01713     Value*      fn;                 // function to run
01714     Value*      attribute;          // controlling change atribute
01715     Value*      id;                 // optional handler ID for group deleting
01716     Value*      handle_at;          // delayed handling event code (#redraw, #timeChange)
01717     short       parameter_count;    // # formal params for fn
01718     short       flags;
01719     Tab<ReferenceTarget*> targets;  // table of targets who've notified delayed-handling handler
01720 
01721     static CHRedrawViewsCallback    chrvcb;     // redrawviews callback
01722     static CHTimeChangeCallback     chtccb;     // timechange callback
01723     static Tab<ChangeHandler*>      handlers;   // immediate-mode active handlers
01724     static BOOL                     delete_flagged; // signals a delayed delete was flagged
01725 
01726                 ChangeHandler(Value* ifn, Value* attrib, Value* id, Value* handle_at);
01727 
01728                 classof_methods (ChangeHandler, Value);
01729     void        collect() { delete this; }
01730     void        gc_trace();
01731     MCHAR*      class_name() { return _M("<ChangeHandler>"); }
01732     void        handle_event(ReferenceTarget* target);
01733     void        call_handler(ReferenceTarget* target);
01734 
01735     RefResult   NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, 
01736                                  PartID& partID,  RefMessage message);  
01737     BOOL        IsRealDependency(ReferenceTarget* target) { UNUSED_PARAM(target); return FALSE; }
01738 };
01739 
01740 #define CH_BROKEN       0x0001      // fn had a runtime error, disabled
01741 #define CH_BUSY         0x0002      // fn is running, ignore recursive events
01742 #define CH_NOTIFIED     0x0004      // change notified, handle at next specied handleAt: event
01743 #define CH_DELETE       0x0008      // attempted delete within the change handler, mark for delayed delete
01744 
01745 /* ------------------------ MAXRootNode class  ------------------------ */
01746 
01747 /* this class is the MAXScript wrapper for root nodes */
01748 
01749 visible_class (MAXRootNode)
01750 
01751 class MAXRootNode : public MAXWrapper
01752 {
01753 public:
01754     INode   *node;
01755     
01756     ScripterExport MAXRootNode(INode* init_node);
01757     static ScripterExport Value* intern(INode* init_node);
01758 
01759     classof_methods (MAXRootNode, MAXWrapper);
01760 #   define is_rootnode(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MAXRootNode))
01761     void        collect() { delete this; }
01762     ScripterExport void sprin1(CharStream* s);
01763     MCHAR*      class_name() { return _M("<root>"); }
01764 
01765     /* include all the protocol declarations */
01766 
01767 #include "..\macros\define_implementations.h"
01768 
01769     def_generic( eq,        "=");
01770     def_generic( ne,        "!=");
01771     
01772     /* declare built-in property accessors */
01773     def_property    ( name );
01774     def_property    ( children );
01775     
01776     INode*      to_rootnode() { check_for_deletion(); return node; }
01777 };
01778 
01779 /* ---------------------- Node mapping stuff  ----------------------- */
01780 
01781 /* node mapping argument structures */
01782 
01783 struct node_map
01784 {
01785     value_vf    vfn_ptr;                            // virtual fn to map
01786     value_cf    cfn_ptr;                            // or, c fn to map (one or the other must be null)
01787     Value**     arg_list;                           // args to pass on...
01788     int         count;
01789     BOOL        (*selector)(INode*, int, void*);    // set selector fn
01790     void*       sel_arg;                            // arg for the selector
01791     int         get_index;                          // index if we are doing an indexed get
01792     int         get_count;                          // local running traverse count during get
01793     Value**     get_result_p;                       // ptr to result holder for indexed get
01794     Array*      collection;                         // append map results here if non-null (used in for ... collect)
01795     short       flags;                              // control flags
01796 };
01797 
01798 #define NM_INVERT   0x0001                          // invert map order, map parents last on the way out of the recursion
01799 #define NM_SELECT   0x0002                          // applying a select, adjust clear flag 
01800 #define NM_GET      0x0004                          // doing a get, return get_index'th item 
01801 #define NM_MXS_FN   0x0008                          // cfn_ptr is actually a MAXScriptFunction*, apply directly 
01802 
01803 struct node_find
01804 {
01805     BOOL        (*tester)(INode*, int, void*);      // node test fn
01806     void*       test_arg;                           // tester arg
01807     BOOL        (*selector)(INode*, int, void*);    // set selector fn
01808     void*       sel_arg;                            // arg for the selector
01809 };
01810 
01811 struct node_get
01812 {
01813     PathName*   path;                               // path to the node
01814     BOOL        (*selector)(INode*, int, void*);    // set selector fn
01815     void*       sel_arg;                            // arg for the selector
01816 };
01817 
01818 class ConvertToRestore : public RestoreObj 
01819 {
01820     BOOL onlyForRedo;
01821 public:        
01822     ConvertToRestore(BOOL onlyForRedo = FALSE) { this->onlyForRedo = onlyForRedo; }         
01823     void Restore(int isUndo);
01824     void Redo();
01825     MSTR Description() {return MSTR(_M("convertTo()"));}
01826 };
01827 
01828 // G-bufer channel names & IDs
01829 struct gbuff_chan_code
01830 {
01831     MCHAR* name; 
01832     int code;
01833 };
01834 
01835 extern gbuff_chan_code gbuff_chan_codes[];
01836 
01837 // various externs
01838 extern bool for_all_nodes(INode* root, node_map* m);
01839 extern Value* find_first_node(INode* root, node_find* f);
01840 extern Value* get_node(INode* root, node_get* g);
01841 extern bool for_all_path_nodes(INode* root, PathName* path, node_map* m);
01842 extern BOOL all_objects_selector(INode* node, int level, void* selector_arg);
01843 extern int max_name_compare(const MCHAR* max_name, const MCHAR* other);
01844 extern Value* get_subanim_property(Animatable* anim, Value* prop);
01845 extern Value* get_subanim_property(Animatable* anim, int i);
01846 extern Value* set_subanim_property(Animatable* anim, Value* prop, Value* val);
01847 extern Value* set_subanim_property(Animatable* anim, int i, Value* val);
01848 extern BOOL set_subanim_controller(Animatable* anim, Value* prop, Control* newc, MAXControl* newcv);
01849 extern Control* find_subanim_controller(Animatable* anim, Value* prop, ParamDimension** dim);
01850 extern void deselect_if_motion_panel_open();
01851 
01852 // class for suspending/resuming motion panel around controller assignment.
01853 // example usage:
01854 //  if (theHold.Holding())
01855 //      theHold.Put(new AssignContRestore2(0));
01856 //  BOOL result = tmc->SetPositionController(c);
01857 //  if (theHold.Holding())
01858 //      theHold.Put(new AssignContRestore2(1));
01859 
01860 class AssignControllerRestore : public RestoreObj {
01861     BOOL parity;
01862     public: 
01863         ScripterExport AssignControllerRestore(BOOL p); 
01864         void Restore(int isUndo);
01865         void Redo();
01866         MSTR Description();
01867     };
01868 
01869 class NodeTab : public INodeTab
01870 {
01871 public:
01872     INodeTab* AsINodeTabPtr()
01873     {
01874         return reinterpret_cast<INodeTab*>(this);
01875     }
01876     INodeTab& AsINodeTabRef()
01877     { 
01878         return reinterpret_cast<INodeTab&>(*this);
01879     }
01880 };
01881 
01882 // node tab collector for collection node mapping
01883 // arg0 is node candidate, arg1 is NodeTab*
01884 extern ScripterExport Value* collect_nodes(Value** arg_list, int count);
01885 
01886 visible_class (MAXSceneXRef)
01887 class MAXSceneXRef : public MAXWrapper
01888 {
01889 public:
01890     int             index;
01891     MSTR            name;
01892     MSTR            full_name;
01893     INode           *root;
01894     ULONG           nodeHandle;
01895 
01896     ScripterExport  MAXSceneXRef (INode* root, int i);
01897     static ScripterExport Value* intern(INode* root, int i);
01898     MCHAR*          class_name() { return _M("XRefScene"); }
01899     classof_methods (MAXSceneXRef, MAXWrapper);
01900     void            collect() { delete this; }
01901     ScripterExport  void sprin1(CharStream* s);
01902     void            check_for_xref_deletion();
01903     /* operations */    
01904 #include "..\macros\define_implementations.h"   
01905 #   include "..\protocols\xrefs.inl"
01906 
01907     /* built-in property accessors */
01908     def_property( tree );
01909     def_property( parent );
01910     def_property( fileName );
01911 
01912     def_property( autoUpdate );
01913     def_property( boxDisp );
01914     def_property( hidden );
01915     def_property( disabled );
01916     def_property( ignoreLights );
01917     def_property( ignoreCameras );
01918     def_property( ignoreShapes );
01919     def_property( ignoreHelpers );
01920     def_property( ignoreAnimation );
01921 
01922     Value*      get_property(Value** arg_list, int count);
01923     Value*      set_property(Value** arg_list, int count);
01924 };
01925 
01926 
01927 /* ------------------------ MAXRootScene class  ------------------------ */
01928 
01929 /* this class is the MAXScript wrapper for scene root object */
01930 
01931 visible_class (MAXRootScene)
01932 
01933 class MAXRootScene : public MAXRefTarg
01934 {
01935 public:
01936     ScripterExport MAXRootScene(ReferenceTarget* ref);
01937     static ScripterExport Value* intern(ReferenceTarget* ref);
01938     ScripterExport void     sprin1(CharStream* s);
01939     MCHAR*      class_name() { return _M("<rootScene>");    }
01940 };