mxsPlugin.h

Go to the documentation of this file.
00001 /*  
00002  *      MSPlugin.h - MAXScript scriptable plugins for MAX
00003  *
00004  *   A typical scripted plugin is defined by 3 MAXScript classes:
00005  *
00006  *      MSPlugin            base mixin for all scripted MAX plug-in classes
00007  *                          this class inherits from Value so it can live
00008  *                          in the MAXScript garbage-collected heap.
00009  * 
00010  *      MSPluginGeomObject  scripted GeomObjects
00011  *      MSPluginModifier    scripted Modifiers
00012  *      MSPluginControl     scripted Controls
00013  *      MSPluginLight       scripted Lights
00014  *      MSPluginMtl         scripted Materials, etc...
00015  *
00016  *      MSGeomObjectXtnd
00017  *      MSModifierXtnd
00018  *      MSControlXtnd       ... These are subclasses of the above MSPlugin classes that
00019  *                          extend an existing class (specified in the extends: param).  
00020  *                          Instances contain a delegate, a ref to an owned instance of 
00021  *                          the class under extension and
00022  *                          bounce all calls to it (delegation) then specialize UI calls 
00023  *                          to allow UI replacement or extra rollouts for the delegate.  
00024  *
00025  *      MSPluginClass       MAXClass specialization whose instances represent scripted
00026  *                          plugin classes, contains all the definition-level stuff
00027  *                          and a pointer to the MSPluginDesc for the class.
00028  *                          It is applyable for scripted instance creation.  It is also 
00029  *                          kept in a special 
00030  *                          hashtable to enable repeated re-definition in the scripter,
00031  *                          the same value is updated on each re-definition.
00032  *                          This class inherits also from MAXClass and so lives in
00033  *                          the MAXScript heap. 
00034  *
00035  *      MSPluginDesc        ClassDesc2 specialization for MSPlugin classes.
00036  *                          Unlike most ClassDescs, many instances of this are
00037  *                          created, one per scripted plugin.
00038  *                          Instances contain a pointer to the corresponding
00039  *                          MSPluginClass instance from which info for the implementing
00040  *                          the standard ClassDesc2 interface is derived.
00041  *
00042  *          Copyright (c) Autodesk, Inc, 1998.  John Wainwright.
00043  *
00044  */
00045 
00046 #pragma once
00047 
00048 #include "..\kernel\value.h"
00049 #include "..\maxwrapper\mxsobjects.h"
00050 #include "..\..\ref.h"
00051 #include "..\..\iparamm2.h"
00052 #include "..\..\iparamb2.h"
00053 #include "..\..\iparamb2Typedefs.h"
00054 #include "..\..\IMtlRender_Compatibility.h"
00055 #include "..\..\genlight.h"
00056 #include "..\..\gencam.h"
00057 #include "..\..\simpobj.h"
00058 #include "..\..\manipulator.h"
00059 #include "..\..\simpmod.h"
00060 #include "..\..\tvutil.h"
00061 
00062 class MSPlugin;
00063 class MSPluginDesc;
00064 class MSPluginClass;
00065 class MSAutoMParamDlg;
00066 class MSAutoEParamDlg;
00067 class Point3Value;
00068 class MouseTool;
00069 
00070 // plugin context predefined local indexes - MUST match order in Parser::plugin_def() and Parser::attributes_body()
00071 enum { 
00072     pl_this, pl_version, pl_loading, pl_delegate            // common
00073 };
00074 
00075 enum { 
00076     pl_extent = pl_delegate + 1, pl_min, pl_max, pl_center   // for SimpleMods
00077 };
00078 
00079 enum { 
00080     pl_mesh = pl_delegate + 1                               // for SimpleObjects 
00081 };
00082 
00083 enum { 
00084     pl_target = pl_delegate + 1, pl_node,                   // for SimpleManipulators 
00085     pl_gizmoDontDisplay, pl_gizmoDontHitTest, pl_gizmoScaleToViewport,
00086     pl_gizmoUseScreenSpace, pl_gizmoActiveViewportOnly, pl_gizmoUseRelativeScreenSpace,
00087 };
00088 
00089 typedef RefTargetHandle (*creator_fn)(MSPluginClass* pic, BOOL loading);
00090 //extern void show_source_pos();
00091 
00092 // parameter reference (used by subtex and submtl mechanism in scripted texmaps & mtls)
00093 class ParamRef
00094 {
00095 public:
00096     BlockID block_id;
00097     ParamID param_id;
00098     int     tabIndex;
00099     ParamRef(BlockID bid, ParamID pid, int index) { block_id = bid; param_id = pid; tabIndex = index; }
00100 };
00101 
00102 // ----------------------- MSPluginClass -----------------------
00103 //  MAXClass specialization for scripted plug-in classes
00104 
00105 visible_class (MSPluginClass)
00106 
00107 class MSPluginClass : public MAXClass
00108 {
00109 protected:
00110                     MSPluginClass() { }
00111 public:
00112     Value*          class_name;     // UI-visible class name
00113     HINSTANCE       hInstance;      // owning module
00114     ClassDesc*      extend_cd;      // if extending, ClassDesc of class to extend
00115     creator_fn      obj_creator;    // obj maker for the appropriate MSPlugin subclass  
00116     HashTable*      local_scope;    // local name space 
00117     Value**         local_inits;    // local var init vals  
00118     int             local_count;    //   "    "  count  
00119     HashTable*      handlers;       // handler tables   
00120     Array*          rollouts;       // UI rollouts
00121     MouseTool*      create_tool;    // scripted creation tool if non-NULL
00122     Array*          pblock_defs;    // parameter block definition data from compiler (used to build the PB2 descs)
00123     Array*          remap_param_names;  // defines the mapping of old param names to new param names
00124     Array*          loading_pblock_defs; // parameter block definition data for currently loading scene file (to permit old version schema migration)
00125     Tab<ParamBlockDesc2*> pbds;     // parameter block descriptors
00126     ReferenceTarget* alternate;     // any alternate UI object system-style during create mode
00127     Tab<ParamRef>   sub_texmaps;    // param references to any texmaps in pblocks in instances of this class in subobjno order
00128     Tab<ParamRef>   sub_mtls;       // param references to any mtls in pblocks in instances of this class in subobjno order
00129     int             version;        // plugin version (from version: param on def header)
00130     DWORD           mpc_flags;      // flags    
00131     DWORD           rollup_state;   // initial rollup state
00132 
00133     static HashTable* msp_classes;  // table of existing scripted plugin classes to enable redefinition
00134     static MSPlugin* creating;      // object currently being created if non-NULL
00135     static bool      loading;       // currently loading defs from a scene file, delay TV & other updates
00136 
00137                     MSPluginClass(Value* name, MAXSuperClass* supcls, creator_fn cfn);
00138                    ~MSPluginClass();
00139 
00140     // definition and redefinition
00141     static MSPluginClass* intern(Value* name, MAXSuperClass* supcls, creator_fn cfn);
00142     void            init(int local_count, Value** inits, HashTable* local_scope, HashTable* handlers, Array* pblock_defs, Array* iremap_param_names, Array* rollouts, MouseTool* create_tool);
00143 
00144     // MAXScript required
00145 //  BOOL            is_kind_of(ValueMetaClass* c) { return (c == class_tag(MSPluginClass)) ? 1 : Value::is_kind_of(c); } // LAM: 2/23/01
00146     BOOL            is_kind_of(ValueMetaClass* c) { return (c == class_tag(MSPluginClass)) ? 1 : MAXClass::is_kind_of(c); }
00147 #   define          is_msplugin_class(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(MSPluginClass))
00148     void            gc_trace();
00149     void            collect() { delete this; }
00150 
00151     // from Value 
00152     Value*          apply(Value** arglist, int count, CallContext* cc=NULL);        // object creation by applying class object
00153 
00154     // local
00155     void            SetClassID(Value* cidv);
00156     void            SetExtension(Value* cls);
00157     void            SetVersion(Value* ver) { version = ver->to_int(); }
00158     void            StopEditing(int stop_flags = 0);
00159     void            RestartEditing();
00160     static int          lookup_assetType(Value* name);
00161     static ParamType2   lookup_type(Value* name);
00162     void            call_handler(Value* handler, Value** arg_list, int count, TimeValue t, BOOL disable_on_error=FALSE);
00163     // low level handler call, returns result from handler, but needs init_thread_locals() & push/pop_alloc_frame around it
00164     Value*          _call_handler(Value* handler, Value** arg_list, int count, TimeValue t, BOOL disable_on_error=FALSE);
00165 
00166     virtual bool    is_custAttribDef() { return false; }
00167 
00168     // alternate UI
00169     void            install_alternate(ReferenceTarget* ref);
00170     // schema migration
00171     void            build_paramblk_descs();
00172     void            redefine(MSPlugin* val, HashTable* old_locals, Array* old_pblock_defs);
00173     Array*          find_pblock_def(Value* name, Array* pblock_defs);
00174     // scene I/O
00175     static void     save_class_defs(ISave* isave);
00176     static IOResult load_class_def(ILoad* iload);
00177     static void     post_load(ILoad *iload, int which);
00178 
00179     // ClassDesc delegates
00180     virtual RefTargetHandle Create(BOOL loading);
00181     const MCHAR*    ClassName() { return class_name->to_string(); }
00182     SClass_ID       SuperClassID() { return sclass_id; }
00183     Class_ID        ClassID() { return class_id; }
00184     const MCHAR*    Category() { return category ? category->to_string() : _M(""); }
00185     const MCHAR*    InternalName() { return name->to_string(); }
00186     HINSTANCE       HInstance() { return hInstance; }
00187     BOOL            IsManipulator();
00188     BOOL            CanManipulate(ReferenceTarget* hTarget);
00189     BOOL            CanManipulateNode(INode* pNode);
00190     Manipulator*    CreateManipulator(ReferenceTarget* hTarget, INode* pNode);
00191     Manipulator*    CreateManipulator(INode* pNode);
00192 
00193 #include "..\macros\define_implementations.h"
00194     // props
00195     def_prop_getter(name);
00196 };
00197 
00198 #ifdef _DEBUG
00199 void PrintMSPluginClassMetrics();
00200 //#define DEBUG_PARAMDEF_SIZES
00201 #ifdef DEBUG_PARAMDEF_SIZES
00202 void PrintMSPluginClassPDBParamMetrics(ParamBlockDesc2* pdb);
00203 #endif // DEBUG_PARAMDEF_SIZES
00204 #endif // _DEBUG
00205 
00206 // plugin class flags  //AF (4/24/01) redefined these flags because there were conflicts when bit-fiddling with them...
00207 #define MPC_TEMPORARY           (1<<0) //0x0001 // no classID: temporary, cannot be saved in a scene file, shouldn't be wired in to the scene anywhere
00208 #define MPC_REDEFINITION        (1<<1) //0x0002 // class redefinition under way
00209 #define MPC_MS_CREATING         (1<<2) //0x0004 // currently creating new object
00210 #define MPC_MS_WAS_CREATING     (1<<3) //0x0008 // MAXScript was creating during a redefinition
00211 #define MPC_EDITING_IN_CP       (1<<4) //0x0010 // currently editing obj in command panel
00212 #define MPC_EDITING_IN_MTLEDT   (1<<5) //0x0020 // currently editing obj in material editor
00213 #define MPC_EDITING_IN_EFX      (1<<6) //0x0040 // currently editing obj in render effects/environment editor
00214 #define MPC_REPLACE_UI          (1<<7) //0x0080 // for extending classes, scripted UI completely replaces delegates UI
00215 #define MPC_INVISIBLE           (1<<8) //0x0100 // doesn't show up in create panel buttons, useful for controlling dummies, etc.
00216 #define MPC_SILENTERRORS        (1<<9) //0x0200  // don't report errors
00217 #define MPC_MAX_CREATING        (1<<10) //0x0400  // in default MAX creation mode
00218 #define MPC_ABORT_CREATE        (1<<11) //0x0800  // plugin should abort MAX create mode on next GetMouseCreateCallback
00219 #define MPC_LEVEL_6             (1<<12) //0x1000  // level 6 plugin; supports full, stand-alone creatability
00220 #define MPC_IS_MANIP            (1<<13) //0x2000  // is a manipulator plugin
00221 #define MPC_ALTERNATE           (1<<14) //0x4000  // is currently an alternate
00222 // LAM - 1/24/02 - defect 299822 - added following
00223 #define MPC_CAD_FILESAVE        (1<<15) //0x8000  // custom attribute def used by saved instance of scripted plugin
00224 #define MPC_PROMOTE_DEL_PROPS   (1<<16) //0x00010000  // If set, automatically search delegate props on prop miss in scripted plugin
00225 #define MPC_USE_PB_VALIDITY     (1<<17) //0x00020000  // If set, AND delegate's validity interval with param blocks' validity interval
00226 
00227 // for accessing keyword params in pblock_defs
00228 #define key_parm(_key)  _get_key_param(keys, n_##_key)
00229 extern Value* _get_key_param(Array* keys, Value* key_name);
00230 
00231 // ----------------------- MSPluginDesc -----------------------
00232 //  ClassDescs for scripted classes, created dynamically for each scripted class
00233 
00234 class MSPluginDesc : public ClassDesc2, public IMtlRender_Compatibility_MtlBase
00235 {
00236 public:
00237     MSPluginClass*  pc;         // my MAXScript-side plugin class
00238     MSPlugin*       plugin;     // object under creation, MSPlugin interface
00239     RefTargetHandle base_obj;   //   "      "       "     base object interface
00240 
00241                     MSPluginDesc(MSPluginClass* ipc) { pc = ipc; Init(*this); }
00242 
00243     // from ClassDesc
00244     int             IsPublic();
00245     void*           Create(BOOL loading = FALSE) { return pc->Create(loading); }
00246     const MCHAR*    ClassName() { return pc->ClassName(); }
00247     SClass_ID       SuperClassID() { return pc->SuperClassID(); }
00248     Class_ID        ClassID() { return pc->ClassID(); }
00249     const MCHAR*    Category() { return pc->Category(); }
00250     int             BeginCreate(Interface *i);
00251     int             EndCreate(Interface *i);
00252     void            ResetClassParams(BOOL fileReset);
00253     DWORD           InitialRollupPageState();
00254     // manipulator methods
00255     BOOL            IsManipulator() { return pc->IsManipulator(); }
00256     BOOL            CanManipulate(ReferenceTarget* hTarget) { return pc->CanManipulate(hTarget); }
00257     BOOL            CanManipulateNode(INode* pNode) { return pc->CanManipulateNode(pNode); }
00258     Manipulator*    CreateManipulator(ReferenceTarget* hTarget, INode* pNode) { return pc->CreateManipulator(hTarget, pNode); }
00259     Manipulator*    CreateManipulator(INode* pNode) { return pc->CreateManipulator(pNode); }
00260 
00261     // from ClassDesc2
00262     const MCHAR*    InternalName() { return pc->InternalName(); }
00263     HINSTANCE       HInstance() { return pc->HInstance(); }
00264     MCHAR*          GetString(INT_PTR id) { return id != 0 ? (MCHAR*)id : NULL; } // resIDs are actual string ptrs in msplugins...
00265     MCHAR*          GetRsrcString(INT_PTR id) { return id != 0 ? (MCHAR*)id : NULL; }
00266 
00267     // local 
00268     void            StartTool(IObjCreate *iob);   // start up scripted create tool
00269     void            StopTool(IObjCreate *iob);   // stop scripted create tool
00270 
00271     Class_ID        SubClassID()
00272     {
00273         if (pc->extend_cd != NULL) 
00274             return pc->extend_cd->SubClassID();
00275         return Class_ID(0,0); 
00276     }
00277 
00278     bool IsCompatibleWithRenderer(ClassDesc& rendererClassDesc)     // Class descriptor of a Renderer plugin
00279     {
00280         ClassDesc * cd = pc->extend_cd;
00281         if(cd == NULL)
00282         {
00283             return true;
00284         }
00285         IMtlRender_Compatibility_MtlBase* rendererCompatibility = Get_IMtlRender_Compability_MtlBase(*cd);
00286         if(rendererCompatibility)
00287             return rendererCompatibility->IsCompatibleWithRenderer(rendererClassDesc);
00288         else
00289             return true;
00290     }
00291     bool GetCustomMtlBrowserIcon(HIMAGELIST& hImageList, int& inactiveIndex, int& activeIndex, int& disabledIndex) 
00292     {
00293         ClassDesc * cd = pc->extend_cd;
00294         if(cd == NULL)
00295         {
00296             return false;
00297         }
00298 
00299         IMtlRender_Compatibility_MtlBase* rendererCompatibility = Get_IMtlRender_Compability_MtlBase(*cd);
00300         if(rendererCompatibility)
00301             return rendererCompatibility->GetCustomMtlBrowserIcon(hImageList, inactiveIndex,  activeIndex,  disabledIndex);
00302         else
00303             return false;
00304     }
00305 
00306 };
00307 
00308 // ----------------------- MSPluginPBAccessor -----------------------
00309 //  paramblock accessor topass gets & sets to scripted handlers
00310 
00311 class MSPluginPBAccessor : public PBAccessor
00312 {
00313     BlockID         bid;
00314     MSPluginClass*  pc;
00315 public:
00316     MSPluginPBAccessor(MSPluginClass* ipc, BlockID id);
00317     void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t); // set from v
00318     void Get(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t, Interval& valid); // set from v
00319     BOOL KeyFrameAtTime(ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t);
00320     void TabChanged(tab_changes changeCode, Tab<PB2Value>* tab, ReferenceMaker* owner, ParamID id, int tabIndex, int count);
00321     Value* to_value(PB2Value& v, const ParamDef& pd);
00322     void from_value(PB2Value& v, const ParamDef& pd, Value* val);
00323     void DeleteThis();
00324 };
00325 
00326 // ----------------------- MSPlugin -----------------------
00327 //  base mixin class for MAX-side scripted classes
00328 
00329 #define MSP_LOADING     0x0001          // instance is currently being loaded from a scene
00330 #define MSP_DISABLED    0x0002          // general disablement flag, used to diable plugin in case of handler errors, reset by redefinition
00331 #define MSP_DELETED     0x0004          // I'm deleted in the MAX world
00332 
00333 class MSPlugin : public Value
00334 {
00335 public:
00336     MSPluginClass*  pc;             // my class
00337     Value**         locals;         // local var array  
00338     short           flags;          // plugin flags 
00339     int             version;        // plugin version
00340     ReferenceTarget* ref;           // ReferenceTarget interface to me
00341     Tab<IParamBlock2*> pblocks;     // parameter blocks
00342     ILoad*          iload;          // ILoad that the plugin instance was created from
00343     
00344                     MSPlugin() { flags = 0; }
00345     virtual        ~MSPlugin();
00346     void            init(MSPluginClass* pc);
00347 
00348     ScripterExport  void            gc_trace();
00349     ScripterExport  void            collect();
00350 
00351     void            DeleteThis();   // drops all references to/from me
00352     ScripterExport  void            RefDeleted();
00353 
00354     // code management
00355     void            init_locals();
00356     void            call_handler(Value* handler, Value** arg_list, int count, TimeValue t, BOOL disable_on_error=FALSE);
00357     // low level handler call, returns result from handler, but needs init_thread_locals() & push/pop_alloc_frame around it
00358     Value*          _call_handler(Value* handler, Value** arg_list, int count, TimeValue t, BOOL disable_on_error=FALSE);
00359     FPStatus        call_handler(MCHAR* handler_name, FPParams* params, FPValue& result, TimeValue t, BOOL disable_on_error=FALSE);
00360     FPStatus        call_handler(Value* handler, FPParams* params, FPValue& result, TimeValue t, BOOL disable_on_error=FALSE);
00361     void            post_create(ReferenceTarget* me, BOOL loading);
00362     void            call_all_set_handlers();
00363     void            disable() { flags |= MSP_DISABLED; }
00364     void            enable() { flags &= ~MSP_DISABLED; }
00365     BOOL            enabled() { return !(flags & MSP_DISABLED); }
00366 
00367     // locals
00368     int             get_local_index(Value* prop);
00369     Value*          get_local(int index) { return locals[index]; }
00370     void            set_local(int index, Value* val) { locals[index] = heap_ptr(val); }
00371 
00372     // block management
00373     ScripterExport  IParamBlock2*   GetParamBlockByID(BlockID id);
00374 
00375     // UI 
00376     virtual HWND    AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD)=0;
00377     virtual void    DeleteRollupPage(HWND hRollup)=0;
00378     virtual IRollupWindow* GetRollupWindow()=0;
00379 
00380     // factored ReferenceTarget stuff
00381     ScripterExport  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message);
00382     ScripterExport  RefTargetHandle clone_from(MSPlugin* obj, ReferenceTarget* obj_as_ref, RemapDir& remap);
00383     void            RefAdded(RefMakerHandle rm);
00384     void            NotifyTarget(int msg, RefMakerHandle rm);
00385 
00386     // delegate access 
00387     virtual ReferenceTarget* get_delegate()=0;
00388 
00389     // I/O
00390     IOResult        Save(ISave *isave);
00391     IOResult        Load(ILoad *iload);
00392     void            post_load(ILoad *iload, int which);
00393 
00394     // added 3/21/05. Used by debugger to dump locals and externals to standard out
00395     void            dump_local_vars_and_externals(int indentLevel);
00396 };
00397 
00398 // used for in-memory instance migration when a scripted plugin class is redefined
00399 class MSPluginValueMigrator : public ValueMapper
00400 {
00401     MSPluginClass*  pc;
00402     HashTable*      old_locals;
00403     Array*          old_pblock_defs;
00404 public:
00405 
00406     MSPluginValueMigrator(MSPluginClass* pc, HashTable* old_locals, Array* old_pblock_defs)
00407     {
00408         this->pc = pc;
00409         this->old_locals = old_locals;
00410         this->old_pblock_defs = old_pblock_defs;
00411     }
00412 
00413     void map(Value* val) 
00414     { 
00415         if (((MSPlugin*)val)->pc == pc) 
00416             pc->redefine((MSPlugin*)val, old_locals, old_pblock_defs); 
00417     }
00418 };
00419 
00420 #define MSPLUGIN_CHUNK  0x0010
00421 #pragma warning(push)
00422 #pragma warning(disable: 4239  4100)
00423 // ----------------------- MSPluginObject ----------------------
00424 
00425 //  template for MSPlugin classes derived from Object
00426 template <class TYPE> class MSPluginObject : public MSPlugin, public TYPE
00427 {
00428 public:
00429     IObjParam*      ip;                 // ip for any currently open command panel dialogs
00430 
00431     void            DeleteThis();
00432 
00433     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
00434     using Collectable::operator new;
00435     using Collectable::operator delete;
00436 
00437     MSPluginObject() : TYPE(){}
00438     // From MSPlugin
00439     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
00440     void            DeleteRollupPage(HWND hRollup);
00441     IRollupWindow* GetRollupWindow();
00442     ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
00443 
00444     // From Animatable
00445     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
00446     Class_ID        ClassID() { return pc->class_id; }
00447     void            FreeCaches() { }        
00448     int             NumSubs() { return pblocks.Count(); }  
00449     Animatable*     SubAnim(int i) { return pblocks[i]; }
00450     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
00451     int             NumParamBlocks() { return pblocks.Count(); }
00452     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
00453     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
00454     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return TYPE::GetInterface(id); }
00455     
00456     
00457     virtual BaseInterface*GetInterface(Interface_ID id) { 
00459         // GetInterface(Interface_ID) was added after the MAX 4
00460         // SDK shipped. This did not break the SDK because
00461         // it only calls the base class implementation. If you add
00462         // any other code here, plugins compiled with the MAX 4 SDK
00463         // that derive from MSPluginObject and call Base class
00464         // implementations of GetInterface(Interface_ID), will not call
00465         // that code in this routine. This means that the interface
00466         // you are adding will not be exposed for these objects,
00467         // and could have unexpected results.
00468         return TYPE::GetInterface(id);  
00470     }
00471    
00472 
00473     // From ReferenceMaker
00474     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
00475                     { 
00476                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
00477                     }
00478 
00479     // From ReferenceTarget
00480     int             NumRefs();
00481     RefTargetHandle GetReference(int i);
00482     void            SetReference(int i, RefTargetHandle rtarg);
00483     void            RefDeleted() { MSPlugin::RefDeleted(); }
00484     IOResult        Save(ISave *isave) { return MSPlugin::Save(isave); }
00485     IOResult        Load(ILoad *iload) { return MSPlugin::Load(iload); }
00486     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded(rm); }
00487     void            NotifyTarget(int msg, RefMakerHandle rm) { MSPlugin::NotifyTarget(msg, rm); }
00488 
00489     // From BaseObject
00490     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
00491     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
00492     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00493     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) { return 0; }
00494     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { return 0; }       
00495     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { }
00496     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { }
00497     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { }
00498     CreateMouseCallBack* GetCreateMouseCallBack() { return NULL; }  
00499     BOOL            HasUVW() { return 1; }
00500     void            SetGenUVW(BOOL sw) { }
00501     
00502     // From Object
00503     ObjectState     Eval(TimeValue time) { return ObjectState(this); }
00504     void            InitNodeName(MSTR& s) {s = GetObjectName();}
00505     Interval        ObjectValidity(TimeValue t) { return FOREVER; }
00506     int             CanConvertToType(Class_ID obtype) { return 0; }
00507     Object*         ConvertToType(TimeValue t, Class_ID obtype) { return NULL; }
00508     void            GetCollapseTypes(Tab<Class_ID> &clist, Tab<MSTR*> &nlist) { }
00509     void            GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel) { Object::GetDeformBBox(t, box, tm, useSel); }
00510     int             IntersectRay(TimeValue t, Ray& r, float& at, Point3& norm) { return 0; }
00511 
00512 };
00513 
00514 //  template for MSPlugin Xtnd classes derived from Object
00515 template <class TYPE, class MS_SUPER> class MSObjectXtnd : public MS_SUPER
00516 {
00517 public:
00518     TYPE*           delegate;       // my delegate
00519 
00520     void            DeleteThis();
00521 
00522     MSObjectXtnd() : MS_SUPER() {}
00523 
00524     // From MSPlugin
00525     ReferenceTarget* get_delegate() { return delegate; } 
00526 
00527     // From Animatable
00528     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
00529     Class_ID        ClassID() { return pc->class_id; }
00530     void            FreeCaches() { }; // { delegate->FreeCaches(); }        
00531     int             NumSubs() { return pblocks.Count() + 1; }  
00532     Animatable*     SubAnim(int i) { if (i == 0) return delegate; else return pblocks[i-1]; }
00533     MSTR            SubAnimName(int i) { if (i == 0) return delegate->GetObjectName(); else return pblocks[i-1]->GetLocalName(); }
00534     int             NumParamBlocks() { return pblocks.Count(); }
00535     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
00536     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
00537     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MS_SUPER::GetInterface(id); }
00538     
00539     
00540     virtual BaseInterface* GetInterface(Interface_ID id){
00542         // GetInterface(Interface_ID) was added after the MAX 4
00543         // SDK shipped. This did not break the SDK because
00544         // it only calls the base class implementation. If you add
00545         // any other code here, plugins compiled with the MAX 4 SDK
00546         // that derive from MSObjectXtnd and call Base class
00547         // implementations of GetInterface(Interface_ID), will not call
00548         // that code in this routine. This means that the interface
00549         // you are adding will not be exposed for these objects,
00550         // and could have unexpected results.
00551         return MS_SUPER::GetInterface(id); 
00553     }
00554 
00555     // From ReferenceMaker
00556 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
00557 
00558     // From ReferenceTarget
00559     int             NumRefs();
00560     RefTargetHandle GetReference(int i);
00561     void            SetReference(int i, RefTargetHandle rtarg); 
00562 
00563     // From BaseObject
00564     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
00565     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
00566     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00567     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
00568                         { return delegate->HitTest(t, inode, type, crossing, flags, p, vpt); }
00569     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
00570                         { return delegate->Display(t, inode, vpt, flags); }     
00571     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { delegate->GetWorldBoundBox(t, inode, vpt, box); }
00572     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { delegate->GetLocalBoundBox(t, inode, vpt,  box ); }
00573     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { delegate->Snap(t, inode, snap, p, vpt); }
00574     CreateMouseCallBack* GetCreateMouseCallBack();
00575     BOOL            HasUVW() { return delegate->HasUVW(); }
00576     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW(sw); }
00577     void            SetExtendedDisplay(int flags) { delegate->SetExtendedDisplay( flags); }      // for setting mode-dependent display attributes
00578 
00579     // From Object
00580     ObjectState     Eval(TimeValue time);
00581     void            InitNodeName(MSTR& s) {s = GetObjectName();}
00582     Interval        ObjectValidity(TimeValue t);
00583     int             CanConvertToType(Class_ID obtype) { return delegate->CanConvertToType(obtype); }
00584     Object*         ConvertToType(TimeValue t, Class_ID obtype) {
00585                         // CAL-10/1/2002: Don't return the delegate, because it might be deleted.
00586                         //      Return a copy of the delegate instead. (422964)
00587                         Object* obj = delegate->ConvertToType(t, obtype);
00588                         if (obj == delegate) obj = delegate->MakeShallowCopy(OBJ_CHANNELS);
00589                         return obj;
00590                     }
00591     void            GetCollapseTypes(Tab<Class_ID> &clist, Tab<MSTR*> &nlist) { delegate->GetCollapseTypes(clist, nlist); }
00592     void            GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel) { delegate->GetDeformBBox(t, box, tm, useSel); }
00593     int             IntersectRay(TimeValue t, Ray& r, float& at, Point3& norm) { return delegate->IntersectRay(t, r, at, norm); }
00594 
00595 };
00596 
00597 // ----------------------- MSPluginGeomObject ----------------------
00598 //  scripted GeomObject 
00599 
00600 class MSPluginGeomObject : public MSPluginObject<GeomObject>
00601 {
00602 public:
00603                     MSPluginGeomObject() { }
00604                     MSPluginGeomObject(MSPluginClass* pc, BOOL loading);
00605                    ~MSPluginGeomObject() { DeleteAllRefsFromMe(); }
00606 
00607     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
00608     RefTargetHandle Clone(RemapDir& remap);
00609 
00610     // From GeomObject
00611     int             IsRenderable() { return 0; }        
00612     Mesh*           GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete) { return GeomObject::GetRenderMesh(t, inode, view, needDelete); }
00613 };
00614 
00615 class MSGeomObjectXtnd : public MSObjectXtnd<GeomObject, MSPluginGeomObject>
00616 {
00617 public:
00618                     MSGeomObjectXtnd(MSPluginClass* pc, BOOL loading);
00619                    ~MSGeomObjectXtnd() { DeleteAllRefsFromMe(); }
00620 
00621     RefTargetHandle Clone(RemapDir& remap);
00622     // From GeomObject
00623     int             IsRenderable() { return delegate->IsRenderable(); }     
00624     Mesh*           GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete) { return delegate->GetRenderMesh(t, inode, view, needDelete); }
00625 };
00626 
00627 // ----------------------- MSPluginHelper ----------------------
00628 // scripted HelperObject
00629 
00630 class MSPluginHelper : public MSPluginObject<HelperObject>
00631 {
00632 public:
00633                     MSPluginHelper() { }
00634                     MSPluginHelper(MSPluginClass* pc, BOOL loading);
00635                    ~MSPluginHelper() { DeleteAllRefsFromMe(); }
00636 
00637     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
00638     RefTargetHandle Clone(RemapDir& remap);
00639 
00640     // From HelperObject
00641     int             UsesWireColor() { return HelperObject::UsesWireColor(); }   // TRUE if the object color is used for display
00642     BOOL            NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) { return HelperObject::NormalAlignVector(t, pt, norm); }
00643 };
00644 
00645 class MSHelperXtnd : public MSObjectXtnd<HelperObject, MSPluginHelper>
00646 {
00647 public:
00648                     MSHelperXtnd(MSPluginClass* pc, BOOL loading);
00649                    ~MSHelperXtnd() { DeleteAllRefsFromMe(); }
00650 
00651     RefTargetHandle Clone(RemapDir& remap);
00652 
00653     // From BaseObject
00654     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00655 
00656     void            GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& abox );
00657     void            GetLocalBoundBox(TimeValue t, INode *inode, ViewExp *vpt, Box3& abox );
00658     void            GetDeformBBox(TimeValue t, Box3& abox, Matrix3 *tm, BOOL useSel );
00659     int             HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00660     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
00661 
00662     // From Object
00663     ObjectState     Eval(TimeValue time);
00664     Interval        ObjectValidity(TimeValue t);
00665 
00666     // From HelperObject
00667     int             UsesWireColor();
00668     BOOL            NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm);
00669 };
00670 
00671 // ----------------------- MSPluginLight ----------------------
00672 // scripted GenLight
00673 
00674 class MSPluginLight : public MSPluginObject<GenLight>
00675 {
00676 public:
00677     ExclList            exclusionList;
00678 
00679                     MSPluginLight() { }
00680                     MSPluginLight(MSPluginClass* pc, BOOL loading);
00681                    ~MSPluginLight() { DeleteAllRefsFromMe(); }
00682 
00683     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
00684     RefTargetHandle Clone(RemapDir& remap);
00685 
00686     // From LightObject
00687     RefResult       EvalLightState(TimeValue time, Interval& valid, LightState *ls) { return REF_SUCCEED; }
00688     ObjLightDesc *  CreateLightDesc(INode *n, BOOL forceShadowBuf) { return LightObject::CreateLightDesc(n, forceShadowBuf); }
00689     void            SetUseLight(int onOff) { }
00690     BOOL            GetUseLight(void) { return FALSE; }
00691     void            SetHotspot(TimeValue time, float f) { } 
00692     float           GetHotspot(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00693     void            SetFallsize(TimeValue time, float f) { }
00694     float           GetFallsize(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00695     void            SetAtten(TimeValue time, int which, float f) { }
00696     float           GetAtten(TimeValue t, int which, Interval& valid = Interval(0,0)) { return 0.0f; }
00697     void            SetTDist(TimeValue time, float f) { }
00698     float           GetTDist(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00699     void            SetConeDisplay(int s, int notify=TRUE) { }
00700     BOOL            GetConeDisplay(void) { return FALSE; }
00701     int             GetShadowMethod() {return LIGHTSHADOW_NONE;}
00702     void            SetRGBColor(TimeValue t, Point3& rgb) { }
00703     Point3          GetRGBColor(TimeValue t, Interval &valid = Interval(0,0)) {return Point3(0,0,0);}        
00704     void            SetIntensity(TimeValue time, float f) { }
00705     float           GetIntensity(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
00706     void            SetAspect(TimeValue t, float f) { }
00707     float           GetAspect(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}    
00708     void            SetUseAtten(int s) { }
00709     BOOL            GetUseAtten(void) {return FALSE;}
00710     void            SetAttenDisplay(int s) { }
00711     BOOL            GetAttenDisplay(void) {return FALSE;}      
00712     void            Enable(int enab) { }
00713     void            SetMapBias(TimeValue t, float f) { }
00714     float           GetMapBias(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
00715     void            SetMapRange(TimeValue t, float f) { }
00716     float           GetMapRange(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
00717     void            SetMapSize(TimeValue t, int f) { }
00718     int             GetMapSize(TimeValue t, Interval& valid = Interval(0,0)) {return 0;}
00719     void            SetRayBias(TimeValue t, float f) { }
00720     float           GetRayBias(TimeValue t, Interval& valid = Interval(0,0)) {return 0.0f;}
00721     int             GetUseGlobal() {return 0;}
00722     void            SetUseGlobal(int a) { }
00723     int             GetShadow() {return 0;}
00724     void            SetShadow(int a) { }
00725     int             GetShadowType() {return 0;}
00726     void            SetShadowType(int a) { }
00727     int             GetAbsMapBias() {return 0;}
00728     void            SetAbsMapBias(int a) { }
00729     int             GetOvershoot() {return 0;}
00730     void            SetOvershoot(int a) { }
00731     int             GetProjector() {return 0;}
00732     void            SetProjector(int a) { }
00733     ExclList*       GetExclList() { return &exclusionList; }
00734     BOOL            Include() {return FALSE;}
00735     Texmap*         GetProjMap() {return NULL;}
00736     void            SetProjMap(Texmap* pmap) { }
00737     void            UpdateTargDistance(TimeValue t, INode* inode) { }
00738     int             UsesWireColor() { return LightObject::UsesWireColor(); }   // TRUE if the object color is used for display
00739 
00740     // From GenLight
00741 
00742     GenLight *      NewLight(int type) { return NULL; }
00743     int             Type() { return 0; }  // OMNI_LIGHT, TSPOT_LIGHT, DIR_LIGHT, FSPOT_LIGHT, TDIR_LIGHT
00744     void            SetType(int tp) { } // OMNI_LIGHT, TSPOT_LIGHT, DIR_LIGHT, FSPOT_LIGHT, TDIR_LIGHT      
00745     BOOL            IsSpot() { return FALSE; }
00746     BOOL            IsDir() { return FALSE; }
00747     void            SetSpotShape(int s) { }
00748     int             GetSpotShape(void) { return 0; }
00749     void            SetHSVColor(TimeValue t, Point3& hsv) { }
00750     Point3          GetHSVColor(TimeValue t, Interval &valid = Interval(0,0)) { return Point3(0.0f, 0.0f, 0.0f); }
00751     void            SetContrast(TimeValue time, float f) { }
00752     float           GetContrast(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00753     void            SetUseAttenNear(int s) { }
00754     BOOL            GetUseAttenNear(void) { return FALSE; }
00755     void            SetAttenNearDisplay(int s) { }
00756     BOOL            GetAttenNearDisplay(void) { return FALSE; }
00757 
00758     ExclList&       GetExclusionList() { return exclusionList; }
00759     void            SetExclusionList(ExclList &list) { }
00760 
00761     BOOL            SetHotSpotControl(Control *c) { return FALSE; }
00762     BOOL            SetFalloffControl(Control *c) { return FALSE; }
00763     BOOL            SetColorControl(Control *c) { return FALSE; }
00764     Control*        GetHotSpotControl() { return NULL; }
00765     Control*        GetFalloffControl() { return NULL; }
00766     Control*        GetColorControl() { return NULL; }
00767     
00768     void            SetAffectDiffuse(BOOL onOff) { }
00769     BOOL            GetAffectDiffuse() { return FALSE; }
00770     void            SetAffectSpecular(BOOL onOff) { }
00771     BOOL            GetAffectSpecular() { return FALSE; }
00772 
00773     void            SetDecayType(BOOL onOff) { }
00774     BOOL            GetDecayType() { return FALSE; }
00775     void            SetDecayRadius(TimeValue time, float f) {}
00776     float           GetDecayRadius(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f;}
00777     void            SetDiffuseSoft(TimeValue time, float f) {}
00778     float           GetDiffuseSoft(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00779 
00780     void            SetShadColor(TimeValue t, Point3& rgb) {}
00781     Point3          GetShadColor(TimeValue t, Interval &valid = Interval(0,0)) { return Point3(0,0,0); }
00782     BOOL            GetLightAffectsShadow() { return FALSE; }
00783     void            SetLightAffectsShadow(BOOL b) {  }
00784     void            SetShadMult(TimeValue t, float m) {  }
00785     float           GetShadMult(TimeValue t, Interval &valid = Interval(0,0)) { return 1.0f; }
00786 
00787     Texmap*         GetShadowProjMap() { return NULL;  }
00788     void            SetShadowProjMap(Texmap* pmap) {}
00789 
00790     void            SetAmbientOnly(BOOL onOff) {  }
00791     BOOL            GetAmbientOnly() { return FALSE; }
00792 
00793     void            SetAtmosShadows(TimeValue t, int onOff) { }
00794     int             GetAtmosShadows(TimeValue t) { return 0; }
00795     void            SetAtmosOpacity(TimeValue t, float f) { }
00796     float           GetAtmosOpacity(TimeValue t, Interval& valid=FOREVER) { return 0.0f; }
00797     void            SetAtmosColAmt(TimeValue t, float f) { }
00798     float           GetAtmosColAmt(TimeValue t, Interval& valid=FOREVER) { return 0.0f; }
00799 
00800     void            SetUseShadowColorMap(TimeValue t, int onOff) { GenLight::SetUseShadowColorMap(t, onOff); }
00801     int             GetUseShadowColorMap(TimeValue t) { return GenLight::GetUseShadowColorMap(t); }
00802 
00803     void            SetShadowGenerator(ShadowType *s) { GenLight::SetShadowGenerator(s); };
00804     ShadowType*     GetShadowGenerator() { return GenLight::GetShadowGenerator(); } 
00805 };
00806 
00807 class MSLightXtnd : public MSObjectXtnd<GenLight, MSPluginLight>
00808 {
00809 public:
00810                     MSLightXtnd(MSPluginClass* pc, BOOL loading);
00811                    ~MSLightXtnd() { DeleteAllRefsFromMe(); }
00812     RefTargetHandle Clone(RemapDir& remap);
00813 
00814     // From BaseObject
00815     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00816 
00817     void            GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& abox );
00818     void            GetLocalBoundBox(TimeValue t, INode *inode, ViewExp *vpt, Box3& abox );
00819     void            GetDeformBBox(TimeValue t, Box3& abox, Matrix3 *tm, BOOL useSel );
00820     int             HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00821     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
00822 
00823     // From LightObject
00824 
00825     RefResult       EvalLightState(TimeValue time, Interval& valid, LightState *ls);
00826     ObjLightDesc *  CreateLightDesc(INode *n, BOOL forceShadowBuf) { return delegate->CreateLightDesc(n, forceShadowBuf); }
00827     void            SetUseLight(int onOff) { delegate->SetUseLight(onOff); }
00828     BOOL            GetUseLight(void) { return delegate->GetUseLight(); }
00829     void            SetHotspot(TimeValue time, float f) { delegate->SetHotspot(time, f); } 
00830     float           GetHotspot(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetHotspot(t, valid); }
00831     void            SetFallsize(TimeValue time, float f) { delegate->SetFallsize(time, f); }
00832     float           GetFallsize(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetFallsize(t, valid); }
00833     void            SetAtten(TimeValue time, int which, float f) { delegate->SetAtten(time, which, f); }
00834     float           GetAtten(TimeValue t, int which, Interval& valid = Interval(0,0)) { return delegate->GetAtten(t, which, valid); }
00835     void            SetTDist(TimeValue time, float f) { delegate->SetTDist(time, f); }
00836     float           GetTDist(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetTDist(t, valid); }
00837     void            SetConeDisplay(int s, int notify=TRUE) { delegate->SetConeDisplay(s, notify); }
00838     BOOL            GetConeDisplay(void) { return delegate->GetConeDisplay(); }
00839     int             GetShadowMethod() {return delegate->GetShadowMethod();}
00840     void            SetRGBColor(TimeValue t, Point3& rgb) { delegate->SetRGBColor(t, rgb); }
00841     Point3          GetRGBColor(TimeValue t, Interval &valid = Interval(0,0)) {return delegate->GetRGBColor(t, valid);}        
00842     void            SetIntensity(TimeValue time, float f) { delegate->SetIntensity(time, f); }
00843     float           GetIntensity(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetIntensity(t, valid); }
00844     void            SetAspect(TimeValue t, float f) { delegate->SetAspect(t, f); }
00845     float           GetAspect(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetAspect(t, valid); }    
00846     void            SetUseAtten(int s) { delegate->SetUseAtten(s); }
00847     BOOL            GetUseAtten(void) { return delegate->GetUseAtten(); }
00848     void            SetAttenDisplay(int s) { delegate->SetAttenDisplay(s); }
00849     BOOL            GetAttenDisplay(void) { return delegate->GetAttenDisplay(); }      
00850     void            Enable(int enab) { delegate->Enable(enab); }
00851     void            SetMapBias(TimeValue t, float f) { delegate->SetMapBias(t, f); }
00852     float           GetMapBias(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetMapBias(t, valid); }
00853     void            SetMapRange(TimeValue t, float f) { delegate->SetMapRange(t, f); }
00854     float           GetMapRange(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetMapRange(t, valid); }
00855     void            SetMapSize(TimeValue t, int f) { delegate->SetMapSize(t, f); }
00856     int             GetMapSize(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetMapSize(t, valid); }
00857     void            SetRayBias(TimeValue t, float f) { delegate->SetRayBias(t, f); }
00858     float           GetRayBias(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetRayBias(t, valid); }
00859     int             GetAbsMapBias() { return delegate->GetAbsMapBias(); }
00860     void            SetAbsMapBias(int a) { delegate->SetAbsMapBias(a); }
00861     int             GetOvershoot() { return delegate->GetOvershoot(); }
00862     void            SetOvershoot(int a) { delegate->SetOvershoot(a); }
00863     int             GetProjector() { return delegate->GetProjector(); }
00864     void            SetProjector(int a) { delegate->SetProjector(a); }
00865     ExclList*       GetExclList() { return delegate->GetExclList(); }
00866     BOOL            Include() { return delegate->Include(); }
00867     Texmap*         GetProjMap() { return delegate->GetProjMap(); }
00868     void            SetProjMap(Texmap* pmap) { delegate->SetProjMap(pmap); }
00869     void            UpdateTargDistance(TimeValue t, INode* inode) { delegate->UpdateTargDistance(t, inode); }
00870     int             UsesWireColor();
00871 
00872     // From GenLight
00873 
00874     GenLight *      NewLight(int type) { return delegate->NewLight(type); }
00875     int             Type() { return delegate->Type(); }  // OMNI_LIGHT, TSPOT_LIGHT, DIR_LIGHT, FSPOT_LIGHT, TDIR_LIGHT
00876     void            SetType(int tp) { delegate->SetType(tp); } // OMNI_LIGHT, TSPOT_LIGHT, DIR_LIGHT, FSPOT_LIGHT, TDIR_LIGHT      
00877     BOOL            IsSpot() { return delegate->IsSpot(); }
00878     BOOL            IsDir() { return delegate->IsDir(); }
00879     void            SetSpotShape(int s) { delegate->SetSpotShape(s); }
00880     int             GetSpotShape(void) { return delegate->GetSpotShape(); }
00881     void            SetHSVColor(TimeValue t, Point3& hsv) { delegate->SetHSVColor(t, hsv); }
00882     Point3          GetHSVColor(TimeValue t, Interval &valid = Interval(0,0)) { return delegate->GetHSVColor(t, valid); }
00883     void            SetContrast(TimeValue time, float f) { delegate->SetContrast(time, f); }
00884     float           GetContrast(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetContrast(t, valid); }
00885     void            SetUseAttenNear(int s) { delegate->SetUseAttenNear(s); }
00886     BOOL            GetUseAttenNear(void) { return delegate->GetUseAttenNear(); }
00887     void            SetAttenNearDisplay(int s) { delegate->SetAttenNearDisplay(s); }
00888     BOOL            GetAttenNearDisplay(void) { return delegate->GetAttenNearDisplay(); }
00889 
00890     ExclList&       GetExclusionList() { return delegate->GetExclusionList(); }
00891     void            SetExclusionList(ExclList &list) { delegate->SetExclusionList(list); }
00892 
00893     BOOL            SetHotSpotControl(Control *c) { return delegate->SetHotSpotControl(c); }
00894     BOOL            SetFalloffControl(Control *c) { return delegate->SetFalloffControl(c); }
00895     BOOL            SetColorControl(Control *c) { return delegate->SetColorControl(c); }
00896     Control*        GetHotSpotControl() { return delegate->GetHotSpotControl(); }
00897     Control*        GetFalloffControl() { return delegate->GetFalloffControl(); }
00898     Control*        GetColorControl() { return delegate->GetColorControl(); }
00899     
00900     void            SetAffectDiffuse(BOOL onOff) { delegate->SetAffectDiffuse(onOff); }
00901     BOOL            GetAffectDiffuse() { return delegate->GetAffectDiffuse(); }
00902     void            SetAffectSpecular(BOOL onOff) { delegate->SetAffectSpecular(onOff); }
00903     BOOL            GetAffectSpecular() { return delegate->GetAffectSpecular(); }
00904 
00905     void            SetDecayType(BOOL onOff) { delegate->SetDecayType(onOff); }
00906     BOOL            GetDecayType() { return delegate->GetDecayType(); }
00907     void            SetDecayRadius(TimeValue time, float f) { delegate->SetDecayRadius(time, f); }
00908     float           GetDecayRadius(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetDecayRadius(t, valid);}
00909     void            SetDiffuseSoft(TimeValue time, float f) { delegate->SetDiffuseSoft(time, f); }
00910     float           GetDiffuseSoft(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetDiffuseSoft(t, valid); }
00911 
00912     int             GetUseGlobal() { return delegate->GetUseGlobal(); }
00913     void            SetUseGlobal(int a) { delegate->SetUseGlobal(a); }
00914     int             GetShadow() { return delegate->GetShadow(); }
00915     void            SetShadow(int a) { delegate->SetShadow(a); }
00916     int             GetShadowType() { return delegate->GetShadowType(); }
00917     void            SetShadowType(int a) { delegate->SetShadowType(a); }
00918 
00919     void            SetShadColor(TimeValue t, Point3& rgb) { delegate->SetShadColor(t, rgb); }
00920     Point3          GetShadColor(TimeValue t, Interval &valid = Interval(0,0)) { return delegate->GetShadColor(t, valid); }
00921     BOOL            GetLightAffectsShadow() { return delegate->GetLightAffectsShadow(); }
00922     void            SetLightAffectsShadow(BOOL b) { delegate->SetLightAffectsShadow(b); }
00923     void            SetShadMult(TimeValue t, float m) { delegate->SetShadMult(t, m); }
00924     float           GetShadMult(TimeValue t, Interval &valid = Interval(0,0)) { return delegate->GetShadMult(t, valid); }
00925 
00926     Texmap*         GetShadowProjMap() { return delegate->GetShadowProjMap();  }
00927     void            SetShadowProjMap(Texmap* pmap) { delegate->SetShadowProjMap(pmap); }
00928 
00929     void            SetAmbientOnly(BOOL onOff) { delegate->SetAmbientOnly(onOff); }
00930     BOOL            GetAmbientOnly() { return delegate->GetAmbientOnly(); }
00931 
00932     void            SetAtmosShadows(TimeValue t, int onOff) { delegate->SetAtmosShadows(t, onOff);}
00933     int             GetAtmosShadows(TimeValue t) { return delegate->GetAtmosShadows(t); }
00934     void            SetAtmosOpacity(TimeValue t, float f) { delegate->SetAtmosOpacity(t, f);}
00935     float           GetAtmosOpacity(TimeValue t, Interval& valid=FOREVER) { return delegate->GetAtmosOpacity(t); }
00936     void            SetAtmosColAmt(TimeValue t, float f) { delegate->SetAtmosColAmt(t, f);}
00937     float           GetAtmosColAmt(TimeValue t, Interval& valid=FOREVER) { return delegate->GetAtmosColAmt(t); }
00938     
00939     void            SetUseShadowColorMap(TimeValue t, int onOff) { delegate->SetUseShadowColorMap(t, onOff); }
00940     int             GetUseShadowColorMap(TimeValue t) { return delegate->GetUseShadowColorMap(t); }
00941 
00942     void            SetShadowGenerator(ShadowType *s) { delegate->SetShadowGenerator(s); }
00943     ShadowType*     GetShadowGenerator() { return delegate->GetShadowGenerator(); } 
00944 };
00945 
00946 // ----------------------- MSPluginCamera ----------------------
00947 // scripted GenCamera
00948 
00949 class MSPluginCamera : public MSPluginObject<GenCamera>
00950 {
00951 public:
00952                     MSPluginCamera() { }
00953                     MSPluginCamera(MSPluginClass* pc, BOOL loading);
00954                    ~MSPluginCamera() { DeleteAllRefsFromMe(); }
00955 
00956     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
00957     RefTargetHandle Clone(RemapDir& remap);
00958 
00959     // From CameraObject
00960 
00961     RefResult       EvalCameraState(TimeValue time, Interval& valid, CameraState* cs) { return REF_SUCCEED; }
00962     void            SetOrtho(BOOL b) { }
00963     BOOL            IsOrtho() { return FALSE; }
00964     void            SetFOV(TimeValue time, float f) { } 
00965     float           GetFOV(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00966     void            SetTDist(TimeValue time, float f) { } 
00967     float           GetTDist(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00968     int             GetManualClip() {return 0;}
00969     void            SetManualClip(int onOff) { }
00970     float           GetClipDist(TimeValue t, int which, Interval &valid=Interval(0,0)) { return 0.0f; }
00971     void            SetClipDist(TimeValue t, int which, float val) { }
00972     void            SetEnvRange(TimeValue time, int which, float f) { } 
00973     float           GetEnvRange(TimeValue t, int which, Interval& valid = Interval(0,0)) { return 0.0f; }
00974     void            SetEnvDisplay(BOOL b, int notify=TRUE) { }
00975     BOOL            GetEnvDisplay(void) { return FALSE; }
00976     void            RenderApertureChanged(TimeValue t) { }
00977     void            UpdateTargDistance(TimeValue t, INode* inode) { }
00978     int             UsesWireColor() { return CameraObject::UsesWireColor(); }   // TRUE if the object color is used for display
00979 
00980     // From GenCamera
00981 
00982     GenCamera *     NewCamera(int type) { return NULL; }
00983     void            SetConeState(int s) { }
00984     int             GetConeState() { return 0; }
00985     void            SetHorzLineState(int s) { }
00986     int             GetHorzLineState() { return 0; }
00987     void            Enable(int enab) { }
00988     BOOL            SetFOVControl(Control *c) { return FALSE; }
00989     void            SetFOVType(int ft) { }
00990     int             GetFOVType() { return 0; }
00991     Control *       GetFOVControl() { return NULL; }
00992     int             Type() { return 0; }
00993     void            SetType(int tp) { }
00994 
00995     void            SetDOFEnable(TimeValue t, BOOL onOff) {}
00996     BOOL            GetDOFEnable(TimeValue t, Interval& valid = Interval(0,0)) { return 0; }
00997     void            SetDOFFStop(TimeValue t, float fs) {}
00998     float           GetDOFFStop(TimeValue t, Interval& valid = Interval(0,0)) { return 1.0f; }
00999 
01000 };
01001 
01002 class MSCameraXtnd : public MSObjectXtnd<GenCamera, MSPluginCamera>
01003 {
01004 public:
01005                     MSCameraXtnd(MSPluginClass* pc, BOOL loading);
01006                    ~MSCameraXtnd() { DeleteAllRefsFromMe(); }
01007     RefTargetHandle Clone(RemapDir& remap);
01008 
01009     // From BaseObject
01010     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
01011 
01012     void            GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& abox );
01013     void            GetLocalBoundBox(TimeValue t, INode *inode, ViewExp *vpt, Box3& abox );
01014     void            GetDeformBBox(TimeValue t, Box3& abox, Matrix3 *tm, BOOL useSel );
01015     int             HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
01016     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
01017 
01018 
01019     // From CameraObject
01020 
01021     RefResult       EvalCameraState(TimeValue time, Interval& valid, CameraState* cs);
01022     void            SetOrtho(BOOL b) { delegate->SetOrtho(b); }
01023     BOOL            IsOrtho() { return delegate->IsOrtho(); }
01024     void            SetFOV(TimeValue time, float f) { delegate->SetFOV(time, f); } 
01025     float           GetFOV(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetFOV(t, valid); }
01026     void            SetTDist(TimeValue time, float f) { delegate->SetTDist(time, f); } 
01027     float           GetTDist(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetTDist(t, valid); }
01028     int             GetManualClip() { return delegate->GetManualClip(); }
01029     void            SetManualClip(int onOff) { delegate->SetManualClip(onOff); }
01030     float           GetClipDist(TimeValue t, int which, Interval &valid=Interval(0,0)) { return delegate->GetClipDist(t, which, valid); }
01031     void            SetClipDist(TimeValue t, int which, float val) { delegate->SetClipDist(t, which, val); }
01032     void            SetEnvRange(TimeValue time, int which, float f) { delegate->SetEnvRange(time, which, f); } 
01033     float           GetEnvRange(TimeValue t, int which, Interval& valid = Interval(0,0)) { return delegate->GetEnvRange(t, which, valid); }
01034     void            SetEnvDisplay(BOOL b, int notify=TRUE) { delegate->SetEnvDisplay(b, notify); }
01035     BOOL            GetEnvDisplay(void) { return delegate->GetEnvDisplay(); }
01036     void            RenderApertureChanged(TimeValue t);
01037     void            UpdateTargDistance(TimeValue t, INode* inode) { delegate->UpdateTargDistance(t, inode); }
01038     int             UsesWireColor();
01039 
01040     void            SetMultiPassEffectEnabled(TimeValue t, BOOL enabled) { delegate->SetMultiPassEffectEnabled(t, enabled); }
01041     BOOL            GetMultiPassEffectEnabled(TimeValue t, Interval& valid) { return delegate->GetMultiPassEffectEnabled(t, valid); }
01042     void            SetMPEffect_REffectPerPass(BOOL enabled) { delegate->SetMPEffect_REffectPerPass(enabled); }
01043     BOOL            GetMPEffect_REffectPerPass() { return delegate->GetMPEffect_REffectPerPass(); }
01044     void            SetIMultiPassCameraEffect(IMultiPassCameraEffect *pIMultiPassCameraEffect) { delegate->SetIMultiPassCameraEffect(pIMultiPassCameraEffect); }
01045     IMultiPassCameraEffect *GetIMultiPassCameraEffect() { return delegate->GetIMultiPassCameraEffect(); }
01046 
01047     // From GenCamera
01048 
01049     GenCamera *     NewCamera(int type) { return delegate->NewCamera(type); }
01050     void            SetConeState(int s) { delegate->SetConeState(s); }
01051     int             GetConeState() { return delegate->GetConeState(); }
01052     void            SetHorzLineState(int s) { delegate->SetHorzLineState(s); }
01053     int             GetHorzLineState() { return delegate->GetHorzLineState(); }
01054     void            Enable(int enab) { delegate->Enable(enab); }
01055     BOOL            SetFOVControl(Control *c) { return delegate->SetFOVControl(c); }
01056     void            SetFOVType(int ft) { delegate->SetFOVType(ft); }
01057     int             GetFOVType() { return delegate->GetFOVType(); }
01058     Control *       GetFOVControl() { return delegate->GetFOVControl(); }
01059     int             Type() { return delegate->Type(); }
01060     void            SetType(int tp) { delegate->SetType(tp); }
01061 
01062     void            SetDOFEnable(TimeValue t, BOOL onOff) { delegate->SetDOFEnable(t, onOff); }
01063     BOOL            GetDOFEnable(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetDOFEnable(t, valid); }
01064     void            SetDOFFStop(TimeValue t, float fs) { delegate->SetDOFFStop(t, fs); }
01065     float           GetDOFFStop(TimeValue t, Interval& valid = Interval(0,0)) { return delegate->GetDOFFStop(t, valid); }
01066 };
01067 
01068 // ----------------------- MSPluginShape ----------------------
01069 // scripted Shape
01070 
01071 class MSPluginShape : public MSPluginObject<ShapeObject>
01072 {
01073     ShapeHierarchy  sh;
01074 public:
01075     MSPluginShape() : MSPluginObject<ShapeObject>() { sh.New(); }
01076                     MSPluginShape(MSPluginClass* pc, BOOL loading);
01077                    ~MSPluginShape() { DeleteAllRefsFromMe(); }
01078 
01079     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01080     RefTargetHandle Clone(RemapDir& remap);
01081 
01082     // From GeomObject
01083     int             IsRenderable() { return ShapeObject::IsRenderable(); }      
01084     Mesh*           GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete) { return ShapeObject::GetRenderMesh(t, inode, view, needDelete); }
01085 
01086     // from ShapeObject
01087     void            InitNodeName(MSTR& s) { ShapeObject::InitNodeName(s); }
01088     SClass_ID       SuperClassID() { return ShapeObject::SuperClassID(); }
01089 
01090     int             IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm) { return ShapeObject::IntersectRay(t, ray, at, norm); }
01091     int             NumberOfVertices(TimeValue t, int curve = -1) { return ShapeObject::NumberOfVertices(t, curve); }   // Informational only, curve = -1: total in all curves
01092     int             NumberOfCurves() { return 0; }                 // Number of curve polygons in the shape
01093     BOOL            CurveClosed(TimeValue t, int curve) { return FALSE; }     // Returns TRUE if the curve is closed
01094     Point3          InterpCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) { return Point3 (0,0,0); }    // Interpolate from 0-1 on a curve
01095     Point3          TangentCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) { return Point3 (0,0,0); }    // Get tangent at point on a curve
01096     float           LengthOfCurve(TimeValue t, int curve) { return 0.0f; }  // Get the length of a curve
01097     int             NumberOfPieces(TimeValue t, int curve) { return 0; }   // Number of sub-curves in a curve
01098     Point3          InterpPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return Point3 (0,0,0); }  // Interpolate from 0-1 on a sub-curve
01099     Point3          TangentPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return Point3 (0,0,0); }         // Get tangent on a sub-curve
01100     BOOL            CanMakeBezier() { return ShapeObject::CanMakeBezier(); }                  // Return TRUE if can turn into a bezier representation
01101     void            MakeBezier(TimeValue t, BezierShape &shape) { ShapeObject::MakeBezier(t, shape); }     // Create the bezier representation
01102     ShapeHierarchy& OrganizeCurves(TimeValue t, ShapeHierarchy *hier=NULL) { return sh; }       // Ready for lofting, extrusion, etc.
01103     void            MakePolyShape(TimeValue t, PolyShape &shape, int steps = PSHAPE_BUILTIN_STEPS, BOOL optimize = FALSE) { } // Create a PolyShape representation with optional fixed steps & optimization
01104     int             MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType) { return 0; }  // Generate mesh capping info for the shape
01105     int             MakeCap(TimeValue t, PatchCapInfo &capInfo) { return ShapeObject::MakeCap(t, capInfo); }    // Only implement if CanMakeBezier=TRUE -- Gen patch cap info
01106 
01107     
01108     MtlID           GetMatID(TimeValue t, int curve, int piece) { return ShapeObject::GetMatID(t, curve, piece); }
01109     BOOL            AttachShape(TimeValue t, INode *thisNode, INode *attachNode) { return ShapeObject::AttachShape(t, thisNode, attachNode); }  // Return TRUE if attached
01110     // UVW Mapping switch access
01111     BOOL            HasUVW() { return ShapeObject::HasUVW(); }
01112     void            SetGenUVW(BOOL sw) { ShapeObject::SetGenUVW(sw); }
01113 
01114     // These handle loading and saving the data in this class. Should be called
01115     // by derived class BEFORE it loads or saves any chunks
01116     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return ShapeObject::Save(isave); }
01117     IOResult        Load(ILoad *iload) {  MSPlugin::Load(iload); return ShapeObject::Load(iload); }
01118 
01119     Class_ID        PreferredCollapseType() { return ShapeObject::PreferredCollapseType(); }
01120     BOOL            GetExtendedProperties(TimeValue t, MSTR &prop1Label, MSTR &prop1Data, MSTR &prop2Label, MSTR &prop2Data)
01121                         { return ShapeObject::GetExtendedProperties(t, prop1Label, prop1Data, prop2Label, prop2Data); }
01122     void            RescaleWorldUnits(float f) { ShapeObject::RescaleWorldUnits(f); }
01123 };
01124 
01125 class MSShapeXtnd : public MSObjectXtnd<ShapeObject, MSPluginShape>
01126 {
01127 public:
01128                     MSShapeXtnd(MSPluginClass* pc, BOOL loading);
01129                    ~MSShapeXtnd() { DeleteAllRefsFromMe(); }
01130     RefTargetHandle Clone(RemapDir& remap);
01131 
01132     // From GeomObject
01133     int             IsRenderable() { return delegate->IsRenderable(); }     
01134     Mesh*           GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete) { return delegate->GetRenderMesh(t, inode, view, needDelete); }
01135 
01136     // from ShapeObject
01137     void            InitNodeName(MSTR& s) { delegate->InitNodeName(s); }
01138                     // CAL-10/1/2002: delegate could be NULL while doing DeleteReference(0) (412668)
01139     SClass_ID       SuperClassID() { return delegate ? delegate->SuperClassID() : MSPluginShape::SuperClassID(); }
01140 
01141     int             IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm) { return delegate->IntersectRay(t, ray, at, norm); }
01142     int             NumberOfVertices(TimeValue t, int curve = -1) { return delegate->NumberOfVertices(t, curve); }  
01143     int             NumberOfCurves() { return delegate->NumberOfCurves(); }                 
01144     BOOL            CurveClosed(TimeValue t, int curve) { return delegate->CurveClosed(t, curve); }     
01145     Point3          InterpCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) { return delegate->InterpCurve3D(t, curve, param, ptype); }    
01146     Point3          TangentCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) { return delegate->TangentCurve3D(t, curve, param, ptype); }    
01147     float           LengthOfCurve(TimeValue t, int curve) { return delegate->LengthOfCurve(t, curve); }  
01148     int             NumberOfPieces(TimeValue t, int curve) { return delegate->NumberOfPieces(t, curve); }   
01149     Point3          InterpPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return delegate->InterpPiece3D(t, curve, piece, param, ptype); }  
01150     Point3          TangentPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return delegate->TangentPiece3D(t, curve, piece, param, ptype); }         
01151     BOOL            CanMakeBezier() { return delegate->CanMakeBezier(); }                  
01152     void            MakeBezier(TimeValue t, BezierShape &shape) { delegate->MakeBezier(t, shape); }     
01153     ShapeHierarchy& OrganizeCurves(TimeValue t, ShapeHierarchy *hier=NULL) { return delegate->OrganizeCurves(t, hier); }       
01154     void            MakePolyShape(TimeValue t, PolyShape &shape, int steps = PSHAPE_BUILTIN_STEPS, BOOL optimize = FALSE) { delegate->MakePolyShape(t, shape, steps, optimize); } 
01155     int             MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType) { return delegate->MakeCap(t, capInfo, capType); }  
01156     int             MakeCap(TimeValue t, PatchCapInfo &capInfo) { return delegate->MakeCap(t, capInfo); }   
01157 
01158     
01159     MtlID           GetMatID(TimeValue t, int curve, int piece) { return delegate->GetMatID(t, curve, piece); }
01160     BOOL            AttachShape(TimeValue t, INode *thisNode, INode *attachNode) { return delegate->AttachShape(t, thisNode, attachNode); } // Return TRUE if attached
01161     // UVW Mapping switch access
01162     BOOL            HasUVW() { return delegate->HasUVW(); }
01163     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW(sw); }
01164 
01165     // These handle loading and saving the data in this class. Should be called
01166     // by derived class BEFORE it loads or saves any chunks
01167     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return ShapeObject::Save(isave); }
01168     IOResult        Load(ILoad *iload) {  MSPlugin::Load(iload); return ShapeObject::Load(iload); }
01169 
01170     Class_ID        PreferredCollapseType() { return delegate->PreferredCollapseType(); }
01171     BOOL            GetExtendedProperties(TimeValue t, MSTR &prop1Label, MSTR &prop1Data, MSTR &prop2Label, MSTR &prop2Data)
01172                         { return delegate->GetExtendedProperties(t, prop1Label, prop1Data, prop2Label, prop2Data); }
01173     void            RescaleWorldUnits(float f) { delegate->RescaleWorldUnits(f); }
01174 
01175     Object*         MakeShallowCopy(ChannelMask channels) { return delegate->MakeShallowCopy(channels); }
01176     void            ShallowCopy(Object* fromOb, ChannelMask channels) { delegate->ShallowCopy(fromOb, channels); }
01177     ObjectState     Eval(TimeValue time) { delegate->Eval(time); return ObjectState(this); }
01178 
01179 };
01180 
01181 // ----------------------- MSPluginSimpleObject ----------------------
01182 //  scriptable SimpleObject, mesh building and all
01183 
01184 class MSPluginSimpleObject : public MSPlugin, public SimpleObject
01185 {
01186 public:
01187     IObjParam*      ip;         // ip for any currently open command panel dialogs
01188 
01189                     MSPluginSimpleObject() { }
01190                     MSPluginSimpleObject(MSPluginClass* pc, BOOL loading);
01191                    ~MSPluginSimpleObject() { DeleteAllRefsFromMe(); }
01192 
01193     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01194 
01195     void            DeleteThis();
01196 
01197     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
01198     using Collectable::operator new;
01199     using Collectable::operator delete;
01200 
01201     // From MSPlugin
01202     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
01203     void            DeleteRollupPage(HWND hRollup);
01204     IRollupWindow* GetRollupWindow();
01205     ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
01206 
01207     // From Animatable
01208     using SimpleObject::GetInterface;
01209 
01210     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01211     Class_ID        ClassID() { return pc->class_id; }
01212     int             NumSubs() { return pblocks.Count(); }  
01213     Animatable*     SubAnim(int i) { return pblocks[i]; }
01214     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
01215     int             NumParamBlocks() { return pblocks.Count(); }
01216     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01217     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01218     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return SimpleObject::GetInterface(id); }
01219 
01220     // From ReferenceMaker
01221     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
01222                     { 
01223                         SimpleObject::NotifyRefChanged(changeInt, hTarget, partID, message); 
01224                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
01225                     }
01226 
01227     // From ReferenceTarget
01228     int             NumRefs();
01229     RefTargetHandle GetReference(int i);
01230 protected:
01231     virtual void            SetReference(int i, RefTargetHandle rtarg);
01232 public:
01233     void            RefDeleted() { MSPlugin::RefDeleted(); }
01234     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded( rm); }
01235     RefTargetHandle Clone(RemapDir& remap);
01236     IOResult        Save(ISave *isave) { return MSPlugin::Save(isave); }
01237     IOResult        Load(ILoad *iload) { return MSPlugin::Load(iload); }
01238     void            NotifyTarget(int msg, RefMakerHandle rm) { MSPlugin::NotifyTarget(msg, rm); }
01239 
01240     // From BaseObject
01241     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01242     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01243     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01244 
01245     // From SimpleObject
01246     void            BuildMesh(TimeValue t);
01247     BOOL            OKtoDisplay(TimeValue t);
01248     void            InvalidateUI();
01249     CreateMouseCallBack* GetCreateMouseCallBack();
01250     BOOL            HasUVW();
01251     void            SetGenUVW(BOOL sw);
01252 };
01253 
01254 //  MSSimpleObjectXtnd
01255 class MSSimpleObjectXtnd : public MSPluginSimpleObject
01256 {
01257 public:
01258     SimpleObject*   delegate;       // my delegate
01259 
01260                     MSSimpleObjectXtnd(MSPluginClass* pc, BOOL loading);
01261                    ~MSSimpleObjectXtnd() { DeleteAllRefsFromMe(); }
01262 
01263     void            DeleteThis();
01264 
01265     // From MSPlugin
01266     ReferenceTarget* get_delegate() { return delegate; } 
01267 
01268     // From Animatable
01269     using MSPluginSimpleObject::GetInterface;
01270 
01271     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01272     Class_ID        ClassID() { return pc->class_id; }
01273     void            FreeCaches() { delegate->FreeCaches(); }        
01274     int             NumSubs() { return pblocks.Count() + 1; }  
01275     Animatable*     SubAnim(int i) { if (i == 0) return delegate; else return pblocks[i-1]; }
01276     MSTR            SubAnimName(int i) { if (i == 0) return delegate->GetObjectName(); else return pblocks[i-1]->GetLocalName(); }
01277     int             NumParamBlocks() { return pblocks.Count(); }
01278     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01279     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01280     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginSimpleObject::GetInterface(id); }
01281     
01282     // From ReferenceMaker
01283 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
01284 
01285     // From ReferenceTarget
01286     int             NumRefs();
01287     RefTargetHandle GetReference(int i);
01288 protected:
01289     virtual void            SetReference(int i, RefTargetHandle rtarg); 
01290 public:
01291     RefTargetHandle Clone(RemapDir& remap);
01292 
01293     // From BaseObject
01294     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01295     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01296     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01297     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
01298                         { return delegate->HitTest(t, inode, type, crossing, flags, p, vpt); }
01299     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
01300                         { return delegate->Display(t, inode, vpt, flags); }     
01301     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { delegate->GetWorldBoundBox(t, inode, vpt, box); }
01302     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { delegate->GetLocalBoundBox(t, inode, vpt,  box ); }
01303     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { delegate->Snap(t, inode, snap, p, vpt); }
01304     CreateMouseCallBack* GetCreateMouseCallBack() { return delegate->GetCreateMouseCallBack(); } 
01305     BOOL            HasUVW() { return delegate->HasUVW(); }
01306     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW(sw); }
01307     
01308     // From Object
01309     ObjectState     Eval(TimeValue time);
01310     void            InitNodeName(MSTR& s) {s = GetObjectName();}
01311     Interval        ObjectValidity(TimeValue t);
01312     int             CanConvertToType(Class_ID obtype) { return delegate->CanConvertToType(obtype); }
01313     Object*         ConvertToType(TimeValue t, Class_ID obtype) {
01314                         // CAL-10/1/2002: Don't return the delegate, because it might be deleted.
01315                         //      Return a copy of the delegate instead. (422964)
01316                         Object* obj = delegate->ConvertToType(t, obtype);
01317                         if (obj == delegate) obj = delegate->MakeShallowCopy(OBJ_CHANNELS);
01318                         return obj;
01319                     }
01320     void            GetCollapseTypes(Tab<Class_ID> &clist, Tab<MSTR*> &nlist) { delegate->GetCollapseTypes(clist, nlist); }
01321     void            GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel) { delegate->GetDeformBBox(t, box, tm, useSel); }
01322     int             IntersectRay(TimeValue t, Ray& r, float& at, Point3& norm) { return delegate->IntersectRay(t, r, at, norm); }
01323 
01324     void            BuildMesh(TimeValue t) { delegate->BuildMesh(t); }
01325     BOOL            OKtoDisplay(TimeValue t) { return delegate->OKtoDisplay(t); }
01326     void            InvalidateUI() { delegate->InvalidateUI(); }
01327     ParamDimension* GetParameterDim(int pbIndex) { return delegate->GetParameterDim(pbIndex); }
01328     MSTR            GetParameterName(int pbIndex) { return delegate->GetParameterName(pbIndex); }
01329 
01330 };
01331 
01332 // ----------------------- MSPluginSimpleManipulator ----------------------
01333 //  scriptable SimpleManipulator
01334 
01335 class MSPluginSimpleManipulator : public MSPlugin, public SimpleManipulator
01336 {
01337 public:
01338     IObjParam*      ip;         // ip for any currently open command panel dialogs
01339 
01340                     MSPluginSimpleManipulator() { }
01341                     MSPluginSimpleManipulator(MSPluginClass* pc, BOOL loading, RefTargetHandle hTarget=NULL, INode* pNode=NULL);
01342                    ~MSPluginSimpleManipulator() { DeleteAllRefsFromMe(); }
01343 
01344     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01345     static MSPluginSimpleManipulator* create(MSPluginClass* pc, RefTargetHandle hTarget, INode* pNode);
01346 
01347     void            DeleteThis();
01348 
01349     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
01350     using Collectable::operator new;
01351     using Collectable::operator delete;
01352  
01353     // From MSPlugin
01354     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
01355     void            DeleteRollupPage(HWND hRollup);
01356     IRollupWindow* GetRollupWindow();
01357     ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
01358 
01359     // From Animatable
01360     using SimpleManipulator::GetInterface;
01361 
01362     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01363     Class_ID        ClassID() { return pc->class_id; }
01364     int             NumSubs() { return pblocks.Count() + SimpleManipulator::NumSubs(); }  
01365     Animatable*     SubAnim(int i);
01366     MSTR            SubAnimName(int i);
01367     int             NumParamBlocks() { return pblocks.Count(); }
01368     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01369     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01370     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return Manipulator::GetInterface(id); }
01371 
01372     // From ReferenceMaker
01373     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
01374                     { 
01375                         SimpleManipulator::NotifyRefChanged(changeInt, hTarget, partID, message); 
01376                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
01377                     }
01378 
01379     // From ReferenceTarget
01380     int             NumRefs();
01381     RefTargetHandle GetReference(int i);
01382 protected:
01383     virtual void            SetReference(int i, RefTargetHandle rtarg);
01384 public:
01385     void            RefDeleted() { MSPlugin::RefDeleted(); }
01386     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded( rm); }
01387     RefTargetHandle Clone(RemapDir& remap);
01388     IOResult        Save(ISave *isave) { return MSPlugin::Save(isave); }
01389     IOResult        Load(ILoad *iload) { return MSPlugin::Load(iload); }
01390     void            NotifyTarget(int msg, RefMakerHandle rm) { MSPlugin::NotifyTarget(msg, rm); }
01391 
01392     // From BaseObject
01393     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01394     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01395     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01396     CreateMouseCallBack* GetCreateMouseCallBack();
01397 
01398     // From HelperObject
01399     int             UsesWireColor() { return HelperObject::UsesWireColor(); }   // TRUE if the object color is used for display
01400     BOOL            NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) { return HelperObject::NormalAlignVector(t, pt, norm); }
01401 
01402     // From SimpleManipulator
01403     void            UpdateShapes(TimeValue t, MSTR& toolTip);
01404     void            OnButtonDown(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01405     void            OnMouseMove(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01406     void            OnButtonUp(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01407 };
01408 
01409 //  MSSimpleManipulatorXtnd
01410 class MSSimpleManipulatorXtnd : public MSPluginSimpleManipulator
01411 {
01412 public:
01413     SimpleManipulator*  delegate;       // my delegate
01414 
01415                     MSSimpleManipulatorXtnd() { }
01416                     MSSimpleManipulatorXtnd(MSPluginClass* pc, BOOL loading, RefTargetHandle hTarget=NULL, INode* pNode=NULL);
01417                    ~MSSimpleManipulatorXtnd() { DeleteAllRefsFromMe(); }
01418 
01419     static MSSimpleManipulatorXtnd* create(MSPluginClass* pc, RefTargetHandle hTarget);
01420 
01421     // From MSPlugin
01422     ReferenceTarget* get_delegate() { return delegate; } 
01423 
01424     // From Animatable
01425     using MSPluginSimpleManipulator::GetInterface;
01426 
01427     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01428     Class_ID        ClassID() { return pc->class_id; }
01429     void            FreeCaches() { delegate->FreeCaches(); }        
01430     int             NumSubs() { return pblocks.Count() + SimpleManipulator::NumSubs() + 1; }  
01431     Animatable*     SubAnim(int i);
01432     MSTR            SubAnimName(int i);
01433     int             NumParamBlocks() { return pblocks.Count(); }
01434     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01435     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01436     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginSimpleManipulator::GetInterface(id); }
01437     
01438     // From ReferenceMaker
01439 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
01440 
01441     // From ReferenceTarget
01442     int             NumRefs();
01443     RefTargetHandle GetReference(int i);
01444 protected:
01445     virtual void            SetReference(int i, RefTargetHandle rtarg);
01446 public:
01447     RefTargetHandle Clone(RemapDir& remap);
01448 
01449     // From BaseObject
01450     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01451     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01452     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01453     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
01454                         { return delegate->HitTest(t, inode, type, crossing, flags, p, vpt); }
01455     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
01456                         { return delegate->Display(t, inode, vpt, flags); }     
01457     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { delegate->GetWorldBoundBox(t, inode, vpt, box); }
01458     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { delegate->GetLocalBoundBox(t, inode, vpt,  box ); }
01459     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { delegate->Snap(t, inode, snap, p, vpt); }
01460     CreateMouseCallBack* GetCreateMouseCallBack() { return delegate->GetCreateMouseCallBack(); } 
01461     BOOL            HasUVW() { return delegate->HasUVW(); }
01462     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW(sw); }
01463     
01464     // From HelperObject
01465     int             UsesWireColor() { return delegate->UsesWireColor(); }   // TRUE if the object color is used for display
01466     BOOL            NormalAlignVector(TimeValue t,Point3 &pt, Point3 &norm) { return delegate->NormalAlignVector(t, pt, norm); }
01467 
01468     // From SimpleManipulator
01469     void            UpdateShapes(TimeValue t, MSTR& toolTip);
01470     void            OnButtonDown(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01471     void            OnMouseMove(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01472     void            OnButtonUp(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01473 };
01474 
01475 // ----------------------- MSPluginModifier ----------------------
01476 // scripted Modifier
01477 
01478 class MSPluginModifier : public MSPlugin, public Modifier
01479 {
01480 public:
01481     IObjParam*      ip;                 // ip for any currently open command panel dialogs
01482 
01483                     MSPluginModifier() { }
01484                     MSPluginModifier(MSPluginClass* pc, BOOL loading);
01485                    ~MSPluginModifier() { DeleteAllRefsFromMe(); }
01486 
01487     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01488 
01489     void            DeleteThis() {  MSPlugin::DeleteThis(); }
01490 
01491     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
01492     using Collectable::operator new;
01493     using Collectable::operator delete;
01494 
01495     // From MSPlugin
01496     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
01497     void            DeleteRollupPage(HWND hRollup);
01498     IRollupWindow* GetRollupWindow();
01499     ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
01500 
01501     // From Animatable
01502     using Modifier::GetInterface;
01503 
01504     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01505     Class_ID        ClassID() { return pc->class_id; }
01506     SClass_ID       SuperClassID() { return pc->sclass_id; }
01507     void            FreeCaches() { }        
01508     int             NumSubs() { return pblocks.Count(); }  
01509     Animatable*     SubAnim(int i) { return pblocks[i]; }
01510     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
01511     int             NumParamBlocks() { return pblocks.Count(); }
01512     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01513     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01514     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return Modifier::GetInterface(id); }
01515 
01516     // From ReferenceMaker
01517     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
01518                     { 
01519                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
01520                     }
01521 
01522     // From ReferenceTarget
01523     int             NumRefs();
01524     RefTargetHandle GetReference(int i);
01525 protected:
01526     virtual void            SetReference(int i, RefTargetHandle rtarg);
01527 public:
01528     void            RefDeleted() { MSPlugin::RefDeleted(); }
01529     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded( rm); }
01530     RefTargetHandle Clone(RemapDir& remap);
01531     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return Modifier::Save(isave); }
01532     IOResult        Load(ILoad *iload) { MSPlugin::Load(iload); return Modifier::Load(iload); }
01533     void            NotifyTarget(int msg, RefMakerHandle rm) { MSPlugin::NotifyTarget(msg, rm); }  // LAM - 9/7/01 - ECO 624
01534 
01535     // From BaseObject
01536     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01537     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01538     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01539     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) { return 0; }
01540     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { return 0; }       
01541     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { }
01542     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { }
01543     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { }
01544     CreateMouseCallBack* GetCreateMouseCallBack() { return NULL; }  
01545     BOOL            HasUVW() { return 1; }
01546     void            SetGenUVW(BOOL sw) { }
01547 
01548     // from Modifier
01549     Interval        LocalValidity(TimeValue t);
01550     ChannelMask     ChannelsUsed() { return GEOM_CHANNEL; }   // pretend this thing mods geometry in order to get parameters eval'd 
01551     ChannelMask     ChannelsChanged() { return GEOM_CHANNEL; } 
01552     // this is used to invalidate cache's in Edit Modifiers:
01553     void            NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) { Modifier::NotifyInputChanged(changeInt, partID, message, mc); }
01554 
01555     // This is the method that is called when the modifier is needed to 
01556     // apply its effect to the object. Note that the INode* is always NULL
01557     // for object space modifiers.
01558     void            ModifyObject(TimeValue t, ModContext &mc, ObjectState* os, INode *node) { os->obj->UpdateValidity(GEOM_CHAN_NUM, LocalValidity(t)); }
01559 
01560     // Modifiers that place a dependency on topology should return TRUE
01561     // for this method. An example would be a modifier that stores a selection
01562     // set base on vertex indices.
01563     BOOL            DependOnTopology(ModContext &mc) { return Modifier::DependOnTopology(mc); }
01564 
01565     // this can return:
01566     //   DEFORM_OBJ_CLASS_ID -- not really a class, but so what
01567     //   MAPPABLE_OBJ_CLASS_ID -- ditto
01568     //   TRIOBJ_CLASS_ID
01569     //   BEZIER_PATCH_OBJ_CLASS_ID
01570     Class_ID        InputType() { return Class_ID(DEFORM_OBJ_CLASS_ID,0); }
01571 
01572     IOResult        SaveLocalData(ISave *isave, LocalModData *ld) { return Modifier::SaveLocalData(isave, ld); }  
01573     IOResult        LoadLocalData(ILoad *iload, LocalModData **pld) { return Modifier::LoadLocalData(iload, pld); }  
01574 
01575 };
01576 
01577 class MSModifierXtnd : public MSPluginModifier
01578 {
01579 public:
01580     Modifier*       delegate;       // my delegate
01581 
01582                     MSModifierXtnd(MSPluginClass* pc, BOOL loading);
01583                    ~MSModifierXtnd() { DeleteAllRefsFromMe(); }
01584 
01585                     void DeleteThis() { MSPlugin::DeleteThis(); }
01586 
01587     // From MSPlugin
01588     ReferenceTarget* get_delegate() { return delegate; } 
01589 
01590     // From Animatable
01591     using MSPluginModifier::GetInterface;
01592 
01593     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01594     Class_ID        ClassID() { return pc->class_id; }
01595     SClass_ID       SuperClassID() { return pc->sclass_id; }
01596     void            FreeCaches() { delegate->FreeCaches(); }        
01597     int             NumSubs() { return pblocks.Count() + 1; }  
01598     Animatable*     SubAnim(int i) { if (i == 0) return delegate; else return pblocks[i-1]; }
01599     MSTR            SubAnimName(int i) { if (i == 0) return delegate->GetObjectName(); else return pblocks[i-1]->GetLocalName(); }
01600     int             NumParamBlocks() { return pblocks.Count(); }
01601     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01602     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01603     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginModifier::GetInterface(id); }
01604     
01605     // From ReferenceMaker
01606 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
01607 
01608     // From ReferenceTarget
01609     int             NumRefs();
01610     RefTargetHandle GetReference(int i);
01611 protected:
01612     virtual void            SetReference(int i, RefTargetHandle rtarg);
01613 public:
01614     RefTargetHandle Clone(RemapDir& remap);
01615 
01616     // From BaseObject
01617     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01618     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01619     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01620     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt)
01621                         { return delegate->HitTest(t, inode, type, crossing, flags, p, vpt); }
01622     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
01623                         { return delegate->Display(t, inode, vpt, flags); }     
01624     void            SetExtendedDisplay(int flags) { delegate->SetExtendedDisplay( flags); }      // for setting mode-dependent display attributes
01625     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box) { delegate->GetWorldBoundBox(t, inode, vpt, box); }
01626     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { delegate->GetLocalBoundBox(t, inode, vpt,  box ); }
01627     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { delegate->Snap(t, inode, snap, p, vpt); }
01628     CreateMouseCallBack* GetCreateMouseCallBack() { return delegate->GetCreateMouseCallBack(); } 
01629     BOOL            ChangeTopology() {return delegate->ChangeTopology();}
01630 
01631     void            Move( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE ){ delegate->Move( t, partm, tmAxis, val, localOrigin ); }
01632     void            Rotate( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Quat& val, BOOL localOrigin=FALSE ){ delegate->Rotate( t, partm, tmAxis, val, localOrigin ); }
01633     void            Scale( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE ){ delegate->Scale( t, partm, tmAxis, val, localOrigin ); }
01634     void            TransformStart(TimeValue t) { delegate->TransformStart( t); }
01635     void            TransformHoldingStart(TimeValue t) { delegate->TransformHoldingStart( t); }
01636     void            TransformHoldingFinish(TimeValue t) { delegate->TransformHoldingFinish( t); }             
01637     void            TransformFinish(TimeValue t) { delegate->TransformFinish( t); }            
01638     void            TransformCancel(TimeValue t) { delegate->TransformCancel( t); }            
01639     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc) { return delegate->HitTest( t, inode, type, crossing, flags, p, vpt, mc); }
01640     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, ModContext* mc) { return delegate->Display( t, inode, vpt, flags, mc); };   // quick render in viewport, using current TM.         
01641     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc) { delegate->GetWorldBoundBox( t, inode, vpt, box, mc); }
01642 
01643     void            CloneSelSubComponents(TimeValue t) { delegate->CloneSelSubComponents( t); }
01644     void            AcceptCloneSelSubComponents(TimeValue t) { delegate->AcceptCloneSelSubComponents( t); }
01645     void             SelectSubComponent(
01646                     HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE) { delegate->SelectSubComponent(hitRec, selected, all, invert); }
01647     void            ClearSelection(int selLevel) { delegate->ClearSelection( selLevel); }
01648     void            SelectAll(int selLevel) { delegate->SelectAll( selLevel); }
01649     void            InvertSelection(int selLevel) { delegate->InvertSelection( selLevel); }
01650     int             SubObjectIndex(HitRecord *hitRec) {return  delegate->SubObjectIndex(hitRec);}               
01651     void            ActivateSubobjSel(int level, XFormModes& modes ) { delegate->ActivateSubobjSel( level, modes ); }
01652     BOOL            SupportsNamedSubSels() {return  delegate->SupportsNamedSubSels();}
01653     void            ActivateSubSelSet(MSTR &setName) { delegate->ActivateSubSelSet(setName); }
01654     void            NewSetFromCurSel(MSTR &setName) { delegate->NewSetFromCurSel(setName); }
01655     void            RemoveSubSelSet(MSTR &setName) { delegate->RemoveSubSelSet(setName); }
01656     void            SetupNamedSelDropDown() { delegate->SetupNamedSelDropDown(); }
01657     int             NumNamedSelSets() {return  delegate->NumNamedSelSets();}
01658     MSTR            GetNamedSelSetName(int i) {return  delegate->GetNamedSelSetName( i);}
01659     void            SetNamedSelSetName(int i,MSTR &newName) { delegate->SetNamedSelSetName( i, newName); }
01660     void            NewSetByOperator(MSTR &newName,Tab<int> &sets,int op) { delegate->NewSetByOperator(newName, sets, op); }
01661     void            GetSubObjectCenters(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) { delegate->GetSubObjectCenters(cb, t, node, mc); }
01662     void            GetSubObjectTMs(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) { delegate->GetSubObjectTMs( cb, t, node, mc); }                          
01663     BOOL            HasUVW () { return delegate->HasUVW(); }
01664     BOOL            HasUVW (int mapChannel) { return delegate->HasUVW (mapChannel); }
01665     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW( sw);   }  // applies to mapChannel 1
01666     void            SetGenUVW (int mapChannel, BOOL sw) { delegate->SetGenUVW ( mapChannel, sw); }
01667     void            ShowEndResultChanged (BOOL showEndResult) { delegate->ShowEndResultChanged ( showEndResult);  }
01668     
01669     // from Modifier
01670     Interval        LocalValidity(TimeValue t);
01671     ChannelMask     ChannelsUsed() { return delegate->ChannelsUsed(); }
01672     ChannelMask     ChannelsChanged() { return delegate->ChannelsChanged(); }
01673     // this is used to invalidate cache's in Edit Modifiers:
01674     void            NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) { delegate->NotifyInputChanged(changeInt, partID, message, mc); }
01675 
01676     // This is the method that is called when the modifier is needed to 
01677     // apply its effect to the object. Note that the INode* is always NULL
01678     // for object space modifiers.
01679     // LAM - 8/27/03 - 517135
01680     // removing the call to os->obj->UpdateValidity. This was added by me in G038_MINTONL_Aug-5-2003_08h45m41s.txt as part of:
01681     // Added keyword argument to scripted plugin definitions: [usePBValidity:t/f]
01682     // If the delegate's UI is up LocalValidity(t) always returns NEVER, and the extension channel is invalidated. This cause ModifyObject to be called again, and we
01683     // end up in a nice tight loop. 
01684 //  void            ModifyObject(TimeValue t, ModContext &mc, ObjectState* os, INode *node) { delegate->ModifyObject(t, mc, os, node); os->obj->UpdateValidity(EXTENSION_CHAN_NUM,LocalValidity(t));}
01685     void            ModifyObject(TimeValue t, ModContext &mc, ObjectState* os, INode *node); 
01686 
01687     // Modifiers that place a dependency on topology should return TRUE
01688     // for this method. An example would be a modifier that stores a selection
01689     // set base on vertex indices.
01690     BOOL            DependOnTopology(ModContext &mc) { return delegate->DependOnTopology(mc); }
01691 
01692     // this can return:
01693     //   DEFORM_OBJ_CLASS_ID -- not really a class, but so what
01694     //   MAPPABLE_OBJ_CLASS_ID -- ditto
01695     //   TRIOBJ_CLASS_ID
01696     //   BEZIER_PATCH_OBJ_CLASS_ID
01697     Class_ID        InputType() { return delegate->InputType(); }
01698 
01699     IOResult        SaveLocalData(ISave *isave, LocalModData *ld) { return delegate->SaveLocalData(isave, ld); }  
01700     IOResult        LoadLocalData(ILoad *iload, LocalModData **pld) { return delegate->LoadLocalData(iload, pld); }  
01701 };
01702 
01703 // ----------------------- MSPluginSimpleMod ----------------------
01704 // scripted SimpleMod  (this one has full-implementation handler calls)
01705 
01706 class MSPluginSimpleMod : public MSPlugin, public SimpleMod
01707 {
01708 public:
01709     IObjParam*      ip;                 // ip for any currently open command panel dialogs
01710     Point3Value*    vec;                // cache for the Map parameter & local values
01711     Point3Value*    extent;
01712     Point3Value*    min;
01713     Point3Value*    max;
01714     Point3Value*    center;
01715     BOOL            busy;
01716     TimeValue       last_time;
01717     Point3          last_in, last_out;
01718 
01719     static CRITICAL_SECTION def_sync;   // thread synch for Map parameter cache
01720     static BOOL     setup_sync;
01721     
01722                     MSPluginSimpleMod() { vec = extent = min = max = center = NULL; busy = FALSE; last_time = TIME_NegInfinity; }
01723                     MSPluginSimpleMod(MSPluginClass* pc, BOOL loading);
01724                    ~MSPluginSimpleMod();
01725 
01726     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01727 
01728     void            DeleteThis() {  MSPlugin::DeleteThis(); }
01729 
01730     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
01731     using Collectable::operator new;
01732     using Collectable::operator delete;
01733 
01734     // From MSPlugin
01735     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
01736     void            DeleteRollupPage(HWND hRollup);
01737     IRollupWindow* GetRollupWindow();
01738     ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
01739 
01740     // From Animatable
01741     using SimpleMod::GetInterface;
01742     
01743     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01744     Class_ID        ClassID() { return pc->class_id; }
01745     SClass_ID       SuperClassID() { return pc->sclass_id; }
01746     void            FreeCaches() { }        
01747     int             NumSubs() { return pblocks.Count() + 2; }  
01748     Animatable*     SubAnim(int i);
01749     MSTR            SubAnimName(int i);
01750     int             NumParamBlocks() { return pblocks.Count(); }
01751     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01752     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01753     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return SimpleMod::GetInterface(id); }
01754 
01755     // From ReferenceMaker
01756     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
01757                     { 
01758                         if (message == REFMSG_CHANGE) 
01759                             last_time = TIME_NegInfinity;
01760                         SimpleMod::NotifyRefChanged(changeInt, hTarget, partID, message);
01761                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
01762                     }
01763 
01764     // From ReferenceTarget
01765     int             NumRefs();
01766     RefTargetHandle GetReference(int i);
01767 protected:
01768     virtual void            SetReference(int i, RefTargetHandle rtarg);
01769 public:
01770     void            RefDeleted() { MSPlugin::RefDeleted(); }
01771     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded( rm); }
01772     RefTargetHandle Clone(RemapDir& remap);
01773     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return SimpleMod::Save(isave); }
01774     IOResult        Load(ILoad *iload) { MSPlugin::Load(iload); return SimpleMod::Load(iload); }
01775     void            NotifyTarget(int msg, RefMakerHandle rm) { MSPlugin::NotifyTarget(msg, rm); }  // LAM - 9/7/01 - ECO 624
01776 
01777     // From BaseObject
01778     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01779     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01780     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01781 
01782     // Clients of SimpleMod need to implement this method
01783     Deformer&       GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat);
01784     void            InvalidateUI();
01785     Interval        GetValidity(TimeValue t);
01786     BOOL            GetModLimits(TimeValue t,float &zmin, float &zmax, int &axis);
01787 };
01788 
01789 class MSSimpleModXtnd : public MSPluginSimpleMod
01790 {
01791 public:
01792     SimpleMod*      delegate;       // my delegate
01793 
01794                     MSSimpleModXtnd(MSPluginClass* pc, BOOL loading);
01795                    ~MSSimpleModXtnd() { DeleteAllRefsFromMe(); }
01796 
01797                     void DeleteThis() {  MSPlugin::DeleteThis(); }
01798 
01799     // From MSPlugin
01800     ReferenceTarget* get_delegate() { return delegate; } 
01801 
01802     // From Animatable
01803     using MSPluginSimpleMod::GetInterface;
01804 
01805     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01806     Class_ID        ClassID() { return pc->class_id; }
01807     SClass_ID       SuperClassID() { return pc->sclass_id; }
01808     void            FreeCaches() { delegate->FreeCaches(); }        
01809     int             NumSubs() { return pblocks.Count() + 1; }  
01810     Animatable*     SubAnim(int i) { if (i == 0) return delegate; else return pblocks[i-1]; }
01811     MSTR            SubAnimName(int i) { if (i == 0) return delegate->GetObjectName(); else return pblocks[i-1]->GetLocalName(); }
01812     int             NumParamBlocks() { return pblocks.Count(); }
01813     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01814     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01815     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginSimpleMod::GetInterface(id); }
01816     
01817     // From ReferenceMaker
01818 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
01819 
01820     // From ReferenceTarget
01821     int             NumRefs();
01822     RefTargetHandle GetReference(int i);
01823 protected:
01824     virtual void            SetReference(int i, RefTargetHandle rtarg);
01825 public:
01826     RefTargetHandle Clone(RemapDir& remap);
01827 
01828     // From BaseObject
01829     MCHAR *         GetObjectName() { return pc->class_name->to_string(); }
01830     void            BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01831     void            EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01832     int             HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc)
01833                         { return delegate->HitTest(t, inode, type, crossing, flags, p, vpt, mc); }
01834     int             Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, ModContext *mc) 
01835                         { return delegate->Display(t, inode, vpt, flags, mc); }     
01836     void            GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc) { delegate->GetWorldBoundBox(t, inode, vpt, box, mc); }
01837     void            GetLocalBoundBox(TimeValue t, INode *inode,ViewExp* vpt,  Box3& box ) { delegate->GetLocalBoundBox(t, inode, vpt,  box ); }
01838     void            Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { delegate->Snap(t, inode, snap, p, vpt); }
01839     CreateMouseCallBack* GetCreateMouseCallBack() { return delegate->GetCreateMouseCallBack(); } 
01840     BOOL            HasUVW() { return delegate->HasUVW(); }
01841     void            SetGenUVW(BOOL sw) { delegate->SetGenUVW(sw); }
01842         
01843     void            GetSubObjectCenters(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) { delegate->GetSubObjectCenters(cb, t, node, mc); }
01844     void            GetSubObjectTMs(SubObjAxisCallback *cb,TimeValue t,INode *node,ModContext *mc) { delegate->GetSubObjectTMs(cb, t, node, mc); }
01845     BOOL            ChangeTopology() { return delegate->ChangeTopology(); }
01846     
01847     // from Modifier
01848     ChannelMask     ChannelsUsed() { return delegate->ChannelsUsed(); }
01849     ChannelMask     ChannelsChanged() { return delegate->ChannelsChanged(); }
01850     // this is used to invalidate cache's in Edit Modifiers:
01851     void            NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc) { delegate->NotifyInputChanged(changeInt, partID, message, mc); }
01852 
01853     // This is the method that is called when the modifier is needed to 
01854     // apply its effect to the object. Note that the INode* is always NULL
01855     // for object space modifiers.
01856     void            ModifyObject(TimeValue t, ModContext &mc, ObjectState* os, INode *node) { delegate->ModifyObject(t, mc, os, node); }
01857 
01858     // Modifiers that place a dependency on topology should return TRUE
01859     // for this method. An example would be a modifier that stores a selection
01860     // set base on vertex indices.
01861     BOOL            DependOnTopology(ModContext &mc) { return delegate->DependOnTopology(mc); }
01862 
01863     // this can return:
01864     //   DEFORM_OBJ_CLASS_ID -- not really a class, but so what
01865     //   MAPPABLE_OBJ_CLASS_ID -- ditto
01866     //   TRIOBJ_CLASS_ID
01867     //   BEZIER_PATCH_OBJ_CLASS_ID
01868     Class_ID        InputType() { return delegate->InputType(); }
01869 
01870     IOResult        SaveLocalData(ISave *isave, LocalModData *ld) { return delegate->SaveLocalData(isave, ld); }  
01871     IOResult        LoadLocalData(ILoad *iload, LocalModData **pld) { return delegate->LoadLocalData(iload, pld); } 
01872 
01873     // Clients of SimpleMod need to implement this method
01874     Deformer&       GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat) { return delegate->GetDeformer(t, mc, mat, invmat); }
01875     void            InvalidateUI() { delegate->InvalidateUI(); }
01876     Interval        GetValidity(TimeValue t);
01877     BOOL            GetModLimits(TimeValue t,float &zmin, float &zmax, int &axis) { return delegate->GetModLimits(t, zmin,  zmax,  axis); }
01878 
01879 };
01880 
01881 // ----------------------- MSPluginTexmap ----------------------
01882 // scripted Texmap
01883 
01884 class MSPluginTexmap : public MSPlugin, public Texmap
01885 {
01886 public:
01887     static MSAutoMParamDlg* masterMDlg;                     // master dialog containing all scripted rollout
01888     static IMtlParams*      ip;
01889 
01890                     MSPluginTexmap() { }
01891                     MSPluginTexmap(MSPluginClass* pc, BOOL loading);
01892                    ~MSPluginTexmap() { DeleteAllRefsFromMe(); }
01893 
01894     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
01895 
01896     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
01897     using Collectable::operator new;
01898     using Collectable::operator delete;
01899 
01900     // From MSPlugin
01901     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
01902     void            DeleteRollupPage(HWND hRollup);
01903     IRollupWindow*  GetRollupWindow();
01904     ReferenceTarget* get_delegate() { return NULL; } 
01905 
01906 
01907     // From Animatable
01908     using Texmap::GetInterface;
01909 
01910     void            DeleteThis();
01911     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
01912     Class_ID        ClassID() { return pc->class_id; }
01913     void            FreeCaches() { }        
01914     int             NumSubs() { return pblocks.Count(); }  
01915     Animatable*     SubAnim(int i) { return pblocks[i]; }
01916     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
01917     int             NumParamBlocks() { return pblocks.Count(); }
01918     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
01919     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
01920     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return Texmap::GetInterface(id); }
01921 
01922     // From ReferenceMaker
01923     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
01924                     { 
01925                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
01926                     }
01927 
01928     // From ReferenceTarget
01929     int             NumRefs();
01930     RefTargetHandle GetReference(int i);
01931 protected:
01932     virtual void            SetReference(int i, RefTargetHandle rtarg);
01933 public:
01934     void            RefDeleted() { MSPlugin::RefDeleted(); }
01935     RefTargetHandle Clone(RemapDir& remap);
01936 
01937     // From MtlBase
01938 
01939     MSTR            GetFullName() { return MtlBase::GetFullName(); }
01940     int             BuildMaps(TimeValue t, RenderMapsContext &rmc) { return MtlBase::BuildMaps(t, rmc); }
01941     ULONG           Requirements(int subMtlNum) { return MtlBase::Requirements(subMtlNum); }
01942     ULONG           LocalRequirements(int subMtlNum) { return MtlBase::LocalRequirements(subMtlNum); }
01943     void            MappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { MtlBase::MappingsRequired(subMtlNum, mapreq, bumpreq); } 
01944     void            LocalMappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { MtlBase::LocalMappingsRequired(subMtlNum, mapreq, bumpreq); }
01945     BOOL            IsMultiMtl() { return MtlBase::IsMultiMtl(); }
01946     int             NumSubTexmaps();
01947     Texmap*         GetSubTexmap(int i);
01948 //  int             MapSlotType(int i) { return MtlBase::MapSlotType(i); }
01949     void            SetSubTexmap(int i, Texmap *m);
01950 //  int             SubTexmapOn(int i) { return MtlBase::SubTexmapOn(i); }
01951 //  void            DeactivateMapsInTree() { MtlBase::DeactivateMapsInTree(); }     
01952     MSTR            GetSubTexmapSlotName(int i);
01953     MSTR            GetSubTexmapTVName(int i) { return GetSubTexmapSlotName(i); }
01954 //  void            CopySubTexmap(HWND hwnd, int ifrom, int ito) { MtlBase::CopySubTexmap(hwnd, ifrom, ito); }     
01955     void            Update(TimeValue t, Interval& valid) { }
01956     void            Reset() { pc->cd2->Reset(this, TRUE); }
01957     Interval        Validity(TimeValue t);
01958     ParamDlg*       CreateParamDlg(HWND hwMtlEdit, IMtlParams* imp);
01959     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return MtlBase::Save(isave); }
01960     IOResult        Load(ILoad *iload) { MSPlugin::Load(iload); return MtlBase::Load(iload); }
01961 
01962 #ifndef NO_MTLEDITOR_EFFECTSCHANNELS // orb 01-08-2002
01963     ULONG           GetGBufID() { return MtlBase::GetGBufID(); }
01964     void            SetGBufID(ULONG id) { MtlBase::SetGBufID(id); }
01965 #else
01966     ULONG           GetGBufID() { return 0; }
01967     void            SetGBufID(ULONG id) {  }
01968 #endif // NO_MTLEDITOR_EFFECTSCHANNELS
01969 
01970     void            EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags) 
01971     {
01972         if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/21/03
01973         ReferenceTarget::EnumAuxFiles(assetEnum, flags);
01974     }
01975     PStamp*         GetPStamp(int sz) { return MtlBase::GetPStamp(sz); }
01976     PStamp*         CreatePStamp(int sz) { return MtlBase::CreatePStamp(sz); }          
01977     void            DiscardPStamp(int sz) { MtlBase::DiscardPStamp(sz); }           
01978     BOOL            SupportTexDisplay() { return MtlBase::SupportTexDisplay(); }
01979     DWORD_PTR       GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) { return MtlBase::GetActiveTexHandle(t, thmaker); }
01980     void            ActivateTexDisplay(BOOL onoff) { MtlBase::ActivateTexDisplay(onoff); }
01981     BOOL            SupportsMultiMapsInViewport() { return MtlBase::SupportsMultiMapsInViewport(); }
01982     void            SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb) { MtlBase::SetupGfxMultiMaps(t, mtl, cb); }
01983     ReferenceTarget *GetRefTarget() { return MtlBase::GetRefTarget(); }
01984 
01985     // From Texmap
01986 
01987     // Evaluate the color of map for the context.
01988     AColor          EvalColor(ShadeContext& sc)  { return AColor (0,0,0); }
01989 
01990     // Evaluate the map for a "mono" channel.
01991     // this just permits a bit of optimization 
01992     float           EvalMono(ShadeContext& sc) { return Texmap::EvalMono(sc); }
01993     
01994     // For Bump mapping, need a perturbation to apply to a normal.
01995     // Leave it up to the Texmap to determine how to do this.
01996     Point3          EvalNormalPerturb(ShadeContext& sc) { return Point3(0,0,0); }
01997 
01998     // This query is made of maps plugged into the Reflection or 
01999     // Refraction slots:  Normally the view vector is replaced with
02000     // a reflected or refracted one before calling the map: if the 
02001     // plugged in map doesn't need this , it should return TRUE.
02002     BOOL            HandleOwnViewPerturb() { return Texmap::HandleOwnViewPerturb(); }
02003 
02004     void            GetUVTransform(Matrix3 &uvtrans) {Texmap::GetUVTransform(uvtrans); }
02005     int             GetTextureTiling() { return Texmap::GetTextureTiling(); }
02006     void            InitSlotType(int sType) { Texmap::InitSlotType(sType); }               
02007     int             GetUVWSource() { return Texmap::GetUVWSource(); }
02008     int             GetMapChannel () { return Texmap::GetMapChannel (); }   // only relevant if above returns UVWSRC_EXPLICIT
02009 
02010     UVGen *         GetTheUVGen() { return Texmap::GetTheUVGen(); }  // maps with a UVGen should implement this
02011     XYZGen *        GetTheXYZGen() { return Texmap::GetTheXYZGen(); } // maps with a XYZGen should implement this
02012 
02013     // System function to set slot type for all subtexmaps in a tree.
02014     void            SetOutputLevel(TimeValue t, float v) { Texmap::SetOutputLevel(t, v); }
02015 
02016     // called prior to render: missing map names should be added to NameAccum.
02017     // return 1: success,   0:failure. 
02018     int             LoadMapFiles(TimeValue t) { return Texmap::LoadMapFiles(t); } 
02019 
02020     // render a 2-d bitmap version of map.
02021     void            RenderBitmap(TimeValue t, Bitmap *bm, float scale3D=1.0f, BOOL filter = FALSE) { Texmap::RenderBitmap(t, bm, scale3D, filter); }
02022 
02023     void            RefAdded(RefMakerHandle rm){ Texmap::RefAdded(rm); MSPlugin::RefAdded(rm); }
02024 
02025     // --- Texmap evaluation ---
02026     // The output of a texmap is meaningful in a given ShadeContext 
02027     // if it is the same as when the scene is rendered.         
02028     bool            IsLocalOutputMeaningful( ShadeContext& sc ) { return Texmap::IsLocalOutputMeaningful( sc ); }
02029     bool            IsOutputMeaningful( ShadeContext& sc ) { return Texmap::IsOutputMeaningful( sc ); }
02030 
02031 };
02032 
02033 
02034 class MSTexmapXtnd : public MSPluginTexmap
02035 {
02036 public:
02037     Texmap*         delegate;       // my delegate
02038 
02039                     MSTexmapXtnd(MSPluginClass* pc, BOOL loading);
02040                    ~MSTexmapXtnd() { DeleteAllRefsFromMe(); }
02041 
02042     void            DeleteThis();
02043 
02044     // From MSPlugin
02045     ReferenceTarget* get_delegate() { return delegate; } 
02046 
02047     // From Animatable
02048     using MSPluginTexmap::GetInterface;
02049 
02050     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02051     Class_ID        ClassID() { return pc->class_id; }
02052     void            FreeCaches() { delegate->FreeCaches(); }    
02053     // LAM - 2/1/02 commenting inline implementations out
02054     int             NumSubs(); // { return pblocks.Count() + 1; }  
02055     Animatable*     SubAnim(int i); // { if (i == 0) return delegate; else return pblocks[i-1]; }
02056     MSTR            SubAnimName(int i); // { if (i == 0) return pc->extend_cd->ClassName(); else return pblocks[i-1]->GetLocalName(); }
02057     int             NumParamBlocks() { return pblocks.Count(); }
02058     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02059     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02060     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MSPluginTexmap::GetInterface(id); }
02061     
02062     // From ReferenceTarget
02063     int             NumRefs();
02064     RefTargetHandle GetReference(int i);
02065 protected:
02066     virtual void            SetReference(int i, RefTargetHandle rtarg);
02067 public:
02068     RefTargetHandle Clone(RemapDir& remap);
02069 
02070     // From MtlBase
02071 
02072     int             BuildMaps(TimeValue t, RenderMapsContext &rmc) { return delegate->BuildMaps(t, rmc); }
02073     ULONG           Requirements(int subMtlNum) { return delegate->Requirements(subMtlNum); }
02074     ULONG           LocalRequirements(int subMtlNum) { return delegate->LocalRequirements(subMtlNum); }
02075     void            MappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { delegate->MappingsRequired(subMtlNum, mapreq, bumpreq); } 
02076     void            LocalMappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { delegate->LocalMappingsRequired(subMtlNum, mapreq, bumpreq); }
02077     BOOL            IsMultiMtl() { return delegate->IsMultiMtl(); }
02078     void            Update(TimeValue t, Interval& valid);
02079     void            Reset() { delegate->Reset(); pc->cd2->Reset(this, TRUE); }
02080     Interval        Validity(TimeValue t);
02081     ParamDlg*       CreateParamDlg(HWND hwMtlEdit, IMtlParams* imp);
02082     IOResult        Save(ISave *isave) { return MSPluginTexmap::Save(isave); } // return delegate->Save(isave); }
02083     IOResult        Load(ILoad *iload) { return MSPluginTexmap::Load(iload); } // return delegate->Load(iload); }
02084 
02085 #ifndef NO_MTLEDITOR_EFFECTSCHANNELS // orb 01-08-2002
02086     ULONG           GetGBufID() { return delegate->GetGBufID(); }
02087     void            SetGBufID(ULONG id) { delegate->SetGBufID(id); }
02088 #endif // NO_MTLEDITOR_EFFECTSCHANNELS 
02089     
02090     void            EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags) 
02091     {
02092         if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/21/03
02093         ReferenceTarget::EnumAuxFiles(assetEnum, flags);
02094     }
02095     PStamp*         GetPStamp(int sz) { return delegate->GetPStamp(sz); }
02096     PStamp*         CreatePStamp(int sz) { return delegate->CreatePStamp(sz); }         
02097     void            DiscardPStamp(int sz) { delegate->DiscardPStamp(sz); }              
02098 
02099     int             NumSubTexmaps();
02100     Texmap*         GetSubTexmap(int i);
02101 //  int             MapSlotType(int i) { return MtlBase::MapSlotType(i); }
02102     void            SetSubTexmap(int i, Texmap *m);
02103 //  int             SubTexmapOn(int i) { return MtlBase::SubTexmapOn(i); }
02104 //  void            DeactivateMapsInTree() { MtlBase::DeactivateMapsInTree(); }     
02105     MSTR            GetSubTexmapSlotName(int i);
02106     BOOL            SupportTexDisplay() { return delegate->SupportTexDisplay(); }
02107     DWORD_PTR       GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) { return delegate->GetActiveTexHandle(t, thmaker); }
02108     void            ActivateTexDisplay(BOOL onoff) { delegate->ActivateTexDisplay(onoff); }
02109     BOOL            SupportsMultiMapsInViewport() { return delegate->SupportsMultiMapsInViewport(); }
02110     void            SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb) { delegate->SetupGfxMultiMaps(t, mtl, cb); }
02111     ReferenceTarget *GetRefTarget() { return delegate->GetRefTarget(); }
02112 
02113     // From Texmap
02114 
02115     // Evaluate the color of map for the context.
02116     AColor          EvalColor(ShadeContext& sc)  { return delegate->EvalColor(sc); }
02117     
02118     // Evaluate the map for a "mono" channel.
02119     // this just permits a bit of optimization 
02120     float           EvalMono(ShadeContext& sc) { return delegate->EvalMono(sc); }
02121     
02122     // For Bump mapping, need a perturbation to apply to a normal.
02123     // Leave it up to the Texmap to determine how to do this.
02124     Point3          EvalNormalPerturb(ShadeContext& sc) { return delegate->EvalNormalPerturb(sc); }
02125 
02126     // This query is made of maps plugged into the Reflection or 
02127     // Refraction slots:  Normally the view vector is replaced with
02128     // a reflected or refracted one before calling the map: if the 
02129     // plugged in map doesn't need this , it should return TRUE.
02130     BOOL            HandleOwnViewPerturb() { return delegate->HandleOwnViewPerturb(); }
02131 
02132     BITMAPINFO*     GetVPDisplayDIB(TimeValue t, TexHandleMaker& thmaker, Interval &valid, BOOL mono=FALSE, int forceW=0, int forceH=0)
02133                     { return delegate->GetVPDisplayDIB(t, thmaker, valid, mono, forceW, forceH);  }
02134 
02135     void            GetUVTransform(Matrix3 &uvtrans) {delegate->GetUVTransform(uvtrans); }
02136     int             GetTextureTiling() { return delegate->GetTextureTiling(); }
02137     void            InitSlotType(int sType) { delegate->InitSlotType(sType); }             
02138     int             GetUVWSource() { return delegate->GetUVWSource(); }
02139     int             GetMapChannel () { return delegate->GetMapChannel (); } // only relevant if above returns UVWSRC_EXPLICIT
02140 
02141     UVGen *         GetTheUVGen() { return delegate->GetTheUVGen(); }  // maps with a UVGen should implement this
02142     XYZGen *        GetTheXYZGen() { return delegate->GetTheXYZGen(); } // maps with a XYZGen should implement this
02143 
02144     void            SetOutputLevel(TimeValue t, float v) { delegate->SetOutputLevel(t, v); }
02145 
02146     // called prior to render: missing map names should be added to NameAccum.
02147     // return 1: success,   0:failure. 
02148     int             LoadMapFiles(TimeValue t) { return delegate->LoadMapFiles(t); } 
02149 
02150     // render a 2-d bitmap version of map.
02151     void            RenderBitmap(TimeValue t, Bitmap *bm, float scale3D=1.0f, BOOL filter = FALSE) { delegate->RenderBitmap(t, bm, scale3D, filter); }
02152 
02153 //  void            RefAdded(RefMakerHandle rm){ delegate->RefAdded(rm); }
02154 
02155     // --- Texmap evaluation ---
02156     // The output of a texmap is meaningful in a given ShadeContext 
02157     // if it is the same as when the scene is rendered.         
02158     bool            IsLocalOutputMeaningful( ShadeContext& sc ) { return delegate->IsLocalOutputMeaningful( sc ); }
02159     bool            IsOutputMeaningful( ShadeContext& sc ) { return delegate->IsOutputMeaningful( sc ); }
02160 
02161     int             IsHighDynamicRange( ) { return delegate->IsHighDynamicRange( ); }
02162 };
02163 
02164 // ----------------------- MSPluginMtl ----------------------
02165 // scripted Mtl
02166 
02167 class MSPluginMtl : public MSPlugin, public Mtl
02168 {
02169 public:
02170     static MSAutoMParamDlg* masterMDlg; // master dialog containing all scripted rollout
02171     static IMtlParams*      ip;
02172 
02173                     MSPluginMtl() { }
02174                     MSPluginMtl(MSPluginClass* pc, BOOL loading);
02175                    ~MSPluginMtl() { DeleteAllRefsFromMe(); }
02176 
02177     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
02178 
02179     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
02180     using Collectable::operator new;
02181     using Collectable::operator delete;
02182 
02183     // From MSPlugin
02184     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
02185     void            DeleteRollupPage(HWND hRollup);
02186     IRollupWindow*  GetRollupWindow();
02187     ReferenceTarget* get_delegate() { return NULL; } 
02188 
02189 
02190     // From Animatable
02191     using Mtl::GetInterface;
02192 
02193     void            DeleteThis();
02194     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02195     Class_ID        ClassID() { return pc->class_id; }
02196     void            FreeCaches() { }        
02197     int             NumSubs() { return pblocks.Count(); }  
02198     Animatable*     SubAnim(int i) { return pblocks[i]; }
02199     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
02200     int             NumParamBlocks() { return pblocks.Count(); }
02201     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02202     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02203     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return Mtl::GetInterface(id); }
02204 
02205     // From ReferenceMaker
02206     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
02207                     { 
02208                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
02209                     }
02210 
02211     // From ReferenceTarget
02212     int             NumRefs();
02213     RefTargetHandle GetReference(int i);
02214 protected:
02215     virtual void            SetReference(int i, RefTargetHandle rtarg);
02216 public:
02217     RefTargetHandle Clone(RemapDir& remap);
02218 
02219     // From MtlBase
02220 
02221     MSTR            GetFullName() { return MtlBase::GetFullName(); }
02222     int             BuildMaps(TimeValue t, RenderMapsContext &rmc) { return MtlBase::BuildMaps(t, rmc); }
02223     ULONG           Requirements(int subMtlNum) { return MtlBase::Requirements(subMtlNum); }
02224     ULONG           LocalRequirements(int subMtlNum) { return MtlBase::LocalRequirements(subMtlNum); }
02225     void            MappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { MtlBase::MappingsRequired(subMtlNum, mapreq, bumpreq); } 
02226     void            LocalMappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { MtlBase::LocalMappingsRequired(subMtlNum, mapreq, bumpreq); }
02227     BOOL            IsMultiMtl() { return MtlBase::IsMultiMtl(); }
02228     int             NumSubTexmaps();
02229     Texmap*         GetSubTexmap(int i);
02230 //  int             MapSlotType(int i) { return MtlBase::MapSlotType(i); }
02231     void            SetSubTexmap(int i, Texmap *m);
02232 //  int             SubTexmapOn(int i) { return MtlBase::SubTexmapOn(i); }
02233 //  void            DeactivateMapsInTree() { MtlBase::DeactivateMapsInTree(); }     
02234     MSTR            GetSubTexmapSlotName(int i);
02235     MSTR            GetSubTexmapTVName(int i) { return GetSubTexmapSlotName(i); }
02236 //  void            CopySubTexmap(HWND hwnd, int ifrom, int ito) { MtlBase::CopySubTexmap(hwnd, ifrom, ito); }     
02237     void            Update(TimeValue t, Interval& valid) { }
02238     void            Reset() { pc->cd2->Reset(this, TRUE); }
02239     Interval        Validity(TimeValue t);
02240     ParamDlg*       CreateParamDlg(HWND hwMtlEdit, IMtlParams* imp);
02241     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return MtlBase::Save(isave); }
02242     IOResult        Load(ILoad *iload) { MSPlugin::Load(iload); return MtlBase::Load(iload); }
02243 
02244 #ifndef NO_MTLEDITOR_EFFECTSCHANNELS // orb 01-08-2002
02245     ULONG           GetGBufID() { return MtlBase::GetGBufID(); }
02246     void            SetGBufID(ULONG id) { MtlBase::SetGBufID(id); }
02247 #endif // NO_MTLEDITOR_EFFECTSCHANNELS
02248 
02249     void            EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags) 
02250     {   
02251         if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/21/03
02252         ReferenceTarget::EnumAuxFiles(assetEnum, flags);
02253     }
02254     PStamp*         GetPStamp(int sz) { return MtlBase::GetPStamp(sz); }
02255     PStamp*         CreatePStamp(int sz) { return MtlBase::CreatePStamp(sz); }          
02256     void            DiscardPStamp(int sz) { MtlBase::DiscardPStamp(sz); }           
02257     BOOL            SupportTexDisplay() { return MtlBase::SupportTexDisplay(); }
02258     DWORD_PTR       GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) { return MtlBase::GetActiveTexHandle(t, thmaker); }
02259     void            ActivateTexDisplay(BOOL onoff) { MtlBase::ActivateTexDisplay(onoff); }
02260     BOOL            SupportsMultiMapsInViewport() { return MtlBase::SupportsMultiMapsInViewport(); }
02261     void            SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb) { MtlBase::SetupGfxMultiMaps(t, mtl, cb); }
02262     ReferenceTarget *GetRefTarget() { return MtlBase::GetRefTarget(); }
02263 
02264     // From Mtl
02265 
02266     MtlBase*        GetActiveTexmap() { return Mtl::GetActiveTexmap(); } 
02267     void            SetActiveTexmap( MtlBase *txm) { Mtl::SetActiveTexmap(txm); } 
02268     void            RefDeleted() { Mtl::RefDeleted(); MSPlugin::RefDeleted(); } 
02269     void            RefAdded(RefMakerHandle rm);
02270     Color           GetAmbient(int mtlNum=0, BOOL backFace=FALSE) { return Color(0,0,0); }
02271     Color           GetDiffuse(int mtlNum=0, BOOL backFace=FALSE) { return Color(0,0,0); }      
02272     Color           GetSpecular(int mtlNum=0, BOOL backFace=FALSE) { return Color(0,0,0); }
02273     float           GetShininess(int mtlNum=0, BOOL backFace=FALSE) { return 0.0f; }
02274     float           GetShinStr(int mtlNum=0, BOOL backFace=FALSE) { return 0.0f; }      
02275     float           GetXParency(int mtlNum=0, BOOL backFace=FALSE) { return 0.0f; }
02276     BOOL            GetSelfIllumColorOn(int mtlNum=0, BOOL backFace=FALSE) { return Mtl::GetSelfIllumColorOn(mtlNum, backFace); } 
02277     float           GetSelfIllum(int mtlNum=0, BOOL backFace=FALSE) { return Mtl::GetSelfIllum(mtlNum, backFace); } 
02278     Color           GetSelfIllumColor(int mtlNum=0, BOOL backFace=FALSE) { return Mtl::GetSelfIllumColor(mtlNum, backFace); } 
02279     float           WireSize(int mtlNum=0, BOOL backFace=FALSE) { return Mtl::WireSize(mtlNum, backFace); } 
02280     void            SetAmbient(Color c, TimeValue t) { }        
02281     void            SetDiffuse(Color c, TimeValue t) { }        
02282     void            SetSpecular(Color c, TimeValue t) { }
02283     void            SetShininess(float v, TimeValue t) { }  
02284     void            Shade(ShadeContext& sc) { }
02285     int             NumSubMtls();
02286     Mtl*            GetSubMtl(int i);
02287     void            SetSubMtl(int i, Mtl *m);
02288     MSTR            GetSubMtlSlotName(int i);
02289     MSTR            GetSubMtlTVName(int i) { return GetSubMtlSlotName(i); }                       
02290 //  void            CopySubMtl(HWND hwnd, int ifrom, int ito) { Mtl::CopySubMtl(hwnd, ifrom, ito); }  
02291     float           GetDynamicsProperty(TimeValue t, int mtlNum, int propID) { return Mtl::GetDynamicsProperty(t, mtlNum, propID); } 
02292     void            SetDynamicsProperty(TimeValue t, int mtlNum, int propID, float value) { Mtl::SetDynamicsProperty(t, mtlNum, propID, value); } 
02293     float           EvalDisplacement(ShadeContext& sc) { return Mtl::EvalDisplacement(sc); } 
02294     Interval        DisplacementValidity(TimeValue t) { return Mtl::DisplacementValidity(t); } 
02295 
02296     // --- Material evaluation
02297     // Returns true if the evaluated color\value (output) is constant 
02298     // over all possible inputs. 
02299     bool            IsOutputConst( ShadeContext& sc, int stdID ) { return Mtl::IsOutputConst( sc, stdID ); }
02300     // Evaluates the material on a single standard texmap channel (ID_AM, etc) 
02301     // at a UVW cordinated and over an area described in the ShadingContext
02302     bool            EvalColorStdChannel( ShadeContext& sc, int stdID, Color& outClr) { return Mtl::EvalColorStdChannel( sc, stdID, outClr ); }
02303     bool            EvalMonoStdChannel( ShadeContext& sc, int stdID, float& outVal) { return Mtl::EvalMonoStdChannel( sc, stdID, outVal ); }
02304 };
02305 
02306 
02307 class MSMtlXtnd : public MSPluginMtl
02308 {
02309 public:
02310     Mtl*            delegate;       // my delegate
02311 
02312                     MSMtlXtnd(MSPluginClass* pc, BOOL loading);
02313                    ~MSMtlXtnd() { DeleteAllRefsFromMe(); }
02314 
02315     void            DeleteThis();
02316 
02317     // From MSPlugin
02318     ReferenceTarget* get_delegate() { return delegate; } 
02319 
02320     // From Animatable
02321     using MSPluginMtl::GetInterface;
02322 
02323     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02324     Class_ID        ClassID() { return pc->class_id; }
02325     void            FreeCaches() { if (delegate) delegate->FreeCaches(); }      
02326     int             NumSubs(); // { return pblocks.Count() + 1; }  
02327     Animatable*     SubAnim(int i); // { if (i == 0) return delegate; else return pblocks[i-1]; }
02328     MSTR            SubAnimName(int i); // { if (i == 0) return pc->extend_cd->ClassName(); else return pblocks[i-1]->GetLocalName(); }
02329     int             NumParamBlocks() { return pblocks.Count(); }
02330     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02331     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02332     void*           GetInterface(ULONG id) 
02333                     { 
02334                         if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; 
02335                         else if (id == IID_IReshading) return delegate->GetInterface(id); 
02336                         else return MSPluginMtl::GetInterface(id); 
02337                     }
02338 
02339     BaseInterface* GetInterface(Interface_ID id)
02340     {
02341         return delegate ? delegate->GetInterface(id) : NULL;
02342     }
02343     
02344     // From ReferenceMaker
02345 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
02346 
02347     // From ReferenceTarget
02348     int             NumRefs();
02349     RefTargetHandle GetReference(int i);
02350 protected:
02351     virtual void            SetReference(int i, RefTargetHandle rtarg);
02352 public:
02353     RefTargetHandle Clone(RemapDir& remap);
02354 
02355     // From MtlBase
02356 
02357     int             BuildMaps(TimeValue t, RenderMapsContext &rmc) { return delegate->BuildMaps(t, rmc); }
02358     ULONG           Requirements(int subMtlNum) { return delegate->Requirements(subMtlNum); }
02359     ULONG           LocalRequirements(int subMtlNum) { return delegate->LocalRequirements(subMtlNum); }
02360     void            MappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { delegate->MappingsRequired(subMtlNum, mapreq, bumpreq); } 
02361     void            LocalMappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { delegate->LocalMappingsRequired(subMtlNum, mapreq, bumpreq); }
02362     BOOL            IsMultiMtl() { return delegate->IsMultiMtl(); }
02363     int             NumSubTexmaps();
02364     Texmap*         GetSubTexmap(int i);
02365 //  int             MapSlotType(int i) { return delegate->MapSlotType(i); }
02366     void            SetSubTexmap(int i, Texmap *m);
02367 //  int             SubTexmapOn(int i) { return delegate->SubTexmapOn(i); }
02368 //  void            DeactivateMapsInTree() { delegate->DeactivateMapsInTree(); }     
02369     MSTR            GetSubTexmapSlotName(int i);
02370 //  MSTR            GetSubTexmapTVName(int i) { return delegate->GetSubTexmapTVName(i); }
02371 //  void            CopySubTexmap(HWND hwnd, int ifrom, int ito) { delegate->CopySubTexmap(hwnd, ifrom, ito); }         
02372     
02373     void            Update(TimeValue t, Interval& valid);
02374     void            Reset() { delegate->Reset(); pc->cd2->Reset(this, TRUE); }
02375     Interval        Validity(TimeValue t);
02376     ParamDlg*       CreateParamDlg(HWND hwMtlEdit, IMtlParams* imp);
02377     IOResult        Save(ISave *isave) { return MSPluginMtl::Save(isave); } // return delegate->Save(isave); }
02378     IOResult        Load(ILoad *iload) { return MSPluginMtl::Load(iload); } // return delegate->Load(iload); }
02379 
02380 #ifndef NO_MTLEDITOR_EFFECTSCHANNELS // orb 01-08-2002
02381     ULONG           GetGBufID() { return delegate->GetGBufID(); }
02382     void            SetGBufID(ULONG id) { delegate->SetGBufID(id); }
02383 #endif // NO_MTLEDITOR_EFFECTSCHANNELS
02384     
02385     void            EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags) 
02386     {
02387         if ((flags&FILE_ENUM_CHECK_AWORK1)&&TestAFlag(A_WORK1)) return; // LAM - 4/21/03
02388         ReferenceTarget::EnumAuxFiles(assetEnum, flags);
02389     }
02390     PStamp*         GetPStamp(int sz) { return delegate->GetPStamp(sz); }
02391     PStamp*         CreatePStamp(int sz) { return delegate->CreatePStamp(sz); }         
02392     void            DiscardPStamp(int sz) { delegate->DiscardPStamp(sz); }              
02393     BOOL            SupportTexDisplay() { return delegate->SupportTexDisplay(); }
02394     DWORD_PTR       GetActiveTexHandle(TimeValue t, TexHandleMaker& thmaker) { return delegate->GetActiveTexHandle(t, thmaker); }
02395     void            ActivateTexDisplay(BOOL onoff) { delegate->ActivateTexDisplay(onoff); }
02396     BOOL            SupportsMultiMapsInViewport() { return delegate->SupportsMultiMapsInViewport(); }
02397     void            SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb) { delegate->SetupGfxMultiMaps(t, mtl, cb); }
02398     ReferenceTarget *GetRefTarget() { return delegate->GetRefTarget(); }
02399 
02400     // From Mtl
02401 
02402     BOOL            DontKeepOldMtl() { return TRUE; }
02403     MtlBase*        GetActiveTexmap() { return delegate->GetActiveTexmap(); } 
02404     void            SetActiveTexmap( MtlBase *txm) { delegate->SetActiveTexmap(txm); } 
02405 //  void            RefDeleted() { delegate->RefDeleted(); } 
02406 //  void            RefAdded(RefMakerHandle rm) { delegate->RefAdded(rm); }  
02407     Color           GetAmbient(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetAmbient(mtlNum, backFace); }
02408     Color           GetDiffuse(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetDiffuse(mtlNum, backFace); }        
02409     Color           GetSpecular(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetSpecular(mtlNum, backFace); }
02410     float           GetShininess(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetShininess(mtlNum=0, backFace); }
02411     float           GetShinStr(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetShinStr(mtlNum=0, backFace); }      
02412     float           GetXParency(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetXParency(mtlNum=0, backFace); }
02413     BOOL            GetSelfIllumColorOn(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetSelfIllumColorOn(mtlNum, backFace); } 
02414     float           GetSelfIllum(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetSelfIllum(mtlNum, backFace); } 
02415     Color           GetSelfIllumColor(int mtlNum=0, BOOL backFace=FALSE) { return delegate->GetSelfIllumColor(mtlNum, backFace); } 
02416 
02417     Sampler*        GetPixelSampler(int mtlNum=0, BOOL backFace=FALSE){ return delegate->GetPixelSampler(mtlNum, backFace); } 
02418 
02419     float           WireSize(int mtlNum=0, BOOL backFace=FALSE) { return delegate->WireSize(mtlNum, backFace); } 
02420     void            SetAmbient(Color c, TimeValue t) { delegate->SetAmbient(c, t); }        
02421     void            SetDiffuse(Color c, TimeValue t) { delegate->SetDiffuse(c, t); }        
02422     void            SetSpecular(Color c, TimeValue t) { delegate->SetSpecular(c, t); }
02423     void            SetShininess(float v, TimeValue t) { delegate->SetShininess(v, t); }
02424 
02425     BOOL            SupportsShaders() { return delegate->SupportsShaders(); }
02426     BOOL            SupportsRenderElements() { return delegate->SupportsRenderElements(); }
02427 
02428     void            Shade(ShadeContext& sc) { delegate->Shade(sc); }
02429     int             NumSubMtls();
02430     Mtl*            GetSubMtl(int i);
02431     void            SetSubMtl(int i, Mtl *m);
02432     MSTR            GetSubMtlSlotName(int i);
02433     MSTR            GetSubMtlTVName(int i) { return GetSubMtlSlotName(i); }                       
02434 //  void            CopySubMtl(HWND hwnd, int ifrom, int ito) { delegate->CopySubMtl(hwnd, ifrom, ito); }  
02435     float           GetDynamicsProperty(TimeValue t, int mtlNum, int propID) { return delegate->GetDynamicsProperty(t, mtlNum, propID); } 
02436     void            SetDynamicsProperty(TimeValue t, int mtlNum, int propID, float value) { delegate->SetDynamicsProperty(t, mtlNum, propID, value); } 
02437     float           EvalDisplacement(ShadeContext& sc) { return delegate->EvalDisplacement(sc); } 
02438     Interval        DisplacementValidity(TimeValue t) { return delegate->DisplacementValidity(t); } 
02439 
02440     // --- Material evaluation
02441     // Returns true if the evaluated color\value (output) is constant over all possible inputs. 
02442     bool            IsOutputConst( ShadeContext& sc, int stdID ) { return delegate->IsOutputConst( sc, stdID ); }
02443     // Evaluates the material on a single standard texmap channel (ID_AM, etc) 
02444     // at a UVW cordinated and over an area described in the ShadingContext
02445     bool            EvalColorStdChannel( ShadeContext& sc, int stdID, Color& outClr) { return delegate->EvalColorStdChannel( sc, stdID, outClr ); }
02446     bool            EvalMonoStdChannel( ShadeContext& sc, int stdID, float& outVal) { return delegate->EvalMonoStdChannel( sc, stdID, outVal ); }
02447 
02448     // Need to get/set properties for the delegate
02449     int         SetProperty(ULONG id, void *data) { return delegate->SetProperty( id, data ); }
02450     void*           GetProperty(ULONG id) { return delegate->GetProperty( id ); }
02451 
02452 };
02453 
02454 /* ------------- ParamDlg class for scripter material/texmap plug-ins --------------- */
02455 
02456 class MSAutoMParamDlg : public IAutoMParamDlg 
02457 {
02458     public:
02459         Tab<ParamDlg*>  secondaryDlgs;  // secondary ParamDlgs if this is a master
02460         ParamDlg*       delegateDlg;    // my delegate's dialog if any
02461         MSPlugin*       plugin;         // target plugin
02462         Rollout*        ro;             // rollout controlling dialog
02463         ReferenceTarget* mtl;           // material in the dialog
02464         IMtlParams*     ip;             // mtl interface
02465         TexDADMgr       texDadMgr;
02466         MtlDADMgr       mtlDadMgr;
02467         HWND            hwmedit;        // medit window
02468 
02469                     MSAutoMParamDlg(HWND hMedit, IMtlParams *i, ReferenceTarget* mtl, MSPlugin* plugin, Rollout* ro);
02470                    ~MSAutoMParamDlg();
02471 
02472         // from ParamDlg
02473         Class_ID    ClassID() { return mtl->ClassID(); }
02474         ReferenceTarget* GetThing() { return mtl; }
02475         void        SetThing(ReferenceTarget *m);
02476         void        DeleteThis();
02477         void        SetTime(TimeValue t);
02478         void        ReloadDialog();
02479         void        ActivateDlg(BOOL onOff);
02480         int         FindSubTexFromHWND(HWND hw);    
02481         int         FindSubMtlFromHWND(HWND hw);    
02482 
02483         void        InvalidateUI() { ReloadDialog(); }
02484         void        MtlChanged() { ip->MtlChanged(); }
02485         // secondary dialog list management
02486         int         NumDlgs() { return secondaryDlgs.Count(); }
02487         void        AddDlg(ParamDlg* dlg);
02488         ParamDlg*   GetDlg(int i);
02489         void        SetDlg(int i, ParamDlg* dlg);
02490         void        DeleteDlg(ParamDlg* dlg);
02491 
02492         // access to this dlg's parammap stuff
02493         IParamMap2* GetMap() { return NULL; }
02494 };
02495 
02496 // RK: Start
02497 // ----------------------- MSPluginSpecialFX ----------------------
02498 
02499 //  template for MSPlugin classes derived from SpecialFX
02500 template <class TYPE> class MSPluginSpecialFX : public MSPlugin, public TYPE
02501 {
02502 public:
02503     IRendParams     *ip;
02504 
02505     void            DeleteThis();
02506 
02507     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
02508     using Collectable::operator new;
02509     using Collectable::operator delete;
02510     
02511     // From MSPlugin
02512     HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
02513     void            DeleteRollupPage(HWND hRollup);
02514     IRollupWindow*  GetRollupWindow();
02515     ReferenceTarget* get_delegate() { return NULL; }  // no delegate
02516 
02517     // From Animatable
02518     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02519     Class_ID        ClassID() { return pc->class_id; }
02520     void            FreeCaches() { }        
02521     int             NumSubs() { return pblocks.Count(); }  
02522     Animatable*     SubAnim(int i) { return pblocks[i]; }
02523     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
02524     int             NumParamBlocks() { return pblocks.Count(); }
02525     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02526     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02527     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return TYPE::GetInterface(id); }
02528     
02529     
02530     virtual BaseInterface*GetInterface(Interface_ID id){ 
02532         // GetInterface(Interface_ID) was added after the MAX 4
02533         // SDK shipped. This did not break the SDK because
02534         // it only calls the base class implementation. If you add
02535         // any other code here, plugins compiled with the MAX 4 SDK
02536         // that derive from MSPluginSpecialFX and call Base class
02537         // implementations of GetInterface(Interface_ID), will not call
02538         // that code in this routine. This means that the interface
02539         // you are adding will not be exposed for these objects,
02540         // and could have unexpected results.
02541         return TYPE::GetInterface(id); 
02543     }
02544     
02545 
02546     // From ReferenceMaker
02547     RefResult       NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message)
02548                     { 
02549                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
02550                     }
02551 
02552     // From ReferenceTarget
02553     int             NumRefs();
02554     RefTargetHandle GetReference(int i);
02555     void            SetReference(int i, RefTargetHandle rtarg);
02556     void            RefDeleted() { MSPlugin::RefDeleted(); }
02557     void            RefAdded(RefMakerHandle rm) { MSPlugin::RefAdded( rm); }
02558     IOResult        Save(ISave *isave) { MSPlugin::Save(isave); return SpecialFX::Save(isave); }
02559     IOResult        Load(ILoad *iload) { MSPlugin::Load(iload); return SpecialFX::Load(iload); }
02560 
02561     // From SpecialFX
02562     MSTR            GetName() { return pc->class_name->to_string(); }
02563     BOOL            Active(TimeValue t) { return SpecialFX::Active(t); }
02564     void            Update(TimeValue t, Interval& valid) { SpecialFX::Update(t, valid); }
02565     int             NumGizmos() { return SpecialFX::NumGizmos(); }
02566     INode*          GetGizmo(int i) { return SpecialFX::GetGizmo(i); }
02567     void            DeleteGizmo(int i) { SpecialFX::DeleteGizmo(i); }
02568     void            AppendGizmo(INode *node) { SpecialFX::AppendGizmo(node); }
02569     BOOL            OKGizmo(INode *node) { return SpecialFX::OKGizmo(node); } 
02570     void            EditGizmo(INode *node) { SpecialFX::EditGizmo(node); } 
02571 };
02572 
02573 //  template for MSPlugin Xtnd classes derived from SpecialFX
02574 template <class TYPE, class MS_SUPER> class MSSpecialFXXtnd : public MS_SUPER
02575 {
02576 public:
02577     TYPE*           delegate;       // my delegate
02578 
02579     void            DeleteThis();
02580 
02581     // From MSPlugin
02582     ReferenceTarget* get_delegate() { return delegate; } 
02583 
02584     // From Animatable
02585     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02586     Class_ID        ClassID() { return pc->class_id; }
02587     void            FreeCaches() { delegate->FreeCaches(); }        
02588     int             NumSubs() { return pblocks.Count() + 1; }  
02589     Animatable*     SubAnim(int i) { if (i == 0) { return delegate; } else return pblocks[i-1]; }
02590     MSTR            SubAnimName(int i) { if (i == 0) { MSTR n; delegate->GetClassName(n); return n; } else return pblocks[i-1]->GetLocalName(); }
02591     int             NumParamBlocks() { return pblocks.Count(); }
02592     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02593     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02594     void*           GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return MS_SUPER::GetInterface(id); }
02595 
02596     
02597     virtual BaseInterface* GetInterface(Interface_ID id){ 
02599         // GetInterface(Interface_ID) was added after the MAX 4
02600         // SDK shipped. This did not break the SDK because
02601         // it only calls the base class implementation. If you add
02602         // any other code here, plugins compiled with the MAX 4 SDK
02603         // that derive from MSSpecialFXXtnd and call Base class
02604         // implementations of GetInterface(Interface_ID), will not call
02605         // that code in this routine. This means that the interface
02606         // you are adding will not be exposed for these objects,
02607         // and could have unexpected results.
02608         return MS_SUPER::GetInterface(id); 
02610     }
02611 
02612     // From ReferenceMaker
02613 //  RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) { return REF_SUCCEED; }
02614 
02615     // From ReferenceTarget
02616     int             NumRefs();
02617     RefTargetHandle GetReference(int i);
02618     void            SetReference(int i, RefTargetHandle rtarg);
02619 
02620     // From SpecialFX
02621     BOOL            Active(TimeValue t) { return delegate->Active(t); }
02622     void            Update(TimeValue t, Interval& valid);
02623     int             NumGizmos() { return delegate->NumGizmos(); }
02624     INode*          GetGizmo(int i) { return delegate->GetGizmo(i); }
02625     void            DeleteGizmo(int i) { delegate->DeleteGizmo(i); }
02626     void            AppendGizmo(INode *node) { delegate->AppendGizmo(node); }
02627     BOOL            OKGizmo(INode *node) { return delegate->OKGizmo(node); } 
02628     void            EditGizmo(INode *node) { delegate->EditGizmo(node); } 
02629 };
02630 
02631 // ----------------------- MSPluginEffect ----------------------
02632 // scripted Effect
02633 
02634 class MSPluginEffect : public MSPluginSpecialFX<Effect8>
02635 {
02636 public:
02637     MSAutoEParamDlg* masterFXDlg;                       // master dialog containing all scripted rollout
02638 
02639                     MSPluginEffect() { }
02640                     MSPluginEffect(MSPluginClass* pc, BOOL loading);
02641                    ~MSPluginEffect() { DeleteAllRefsFromMe(); }
02642 
02643     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
02644     RefTargetHandle Clone(RemapDir& remap);
02645 
02646     // from Effect
02647     EffectParamDlg* CreateParamDialog(IRendParams* imp);
02648     DWORD           GBufferChannelsRequired(TimeValue t);
02649     void            Apply(TimeValue t, Bitmap *bm, RenderGlobalContext *gc, CheckAbortCallback *cb );
02650 
02651     // from Effect8
02652     virtual bool SupportsBitmap(Bitmap& bitmap);
02653 
02654     Effect*         to_effect() { return this; }
02655 };
02656 
02657 class MSEffectXtnd : public MSSpecialFXXtnd<Effect, MSPluginEffect>
02658 {
02659 public:
02660                     MSEffectXtnd(MSPluginClass* pc, BOOL loading);
02661     RefTargetHandle Clone(RemapDir& remap);
02662 
02663     // from Effect
02664     EffectParamDlg* CreateParamDialog(IRendParams* imp);
02665     DWORD           GBufferChannelsRequired(TimeValue t);
02666     void            Apply(TimeValue t, Bitmap *bm, RenderGlobalContext *gc, CheckAbortCallback *cb );
02667 
02668 };
02669 
02670 /* ------------- ParamDlg class for scripter effect plug-ins --------------- */
02671 
02672 class MSAutoEParamDlg : public IAutoEParamDlg 
02673 {
02674     public:
02675         Tab<SFXParamDlg*> secondaryDlgs; // secondary ParamDlgs if this is a master
02676         SFXParamDlg*    delegateDlg;    // my delegate's dialog if any
02677         MSPlugin*       plugin;         // target plugin
02678         Rollout*        ro;             // rollout controlling dialog
02679         SpecialFX*      sfx;            // effect/atmos in the dialog
02680         IRendParams*    ip;             // render interface
02681 
02682                     MSAutoEParamDlg(IRendParams *i, SpecialFX* fx, MSPlugin* plugin, Rollout* ro);
02683                    ~MSAutoEParamDlg();
02684 
02685         // from ParamDlg
02686         Class_ID    ClassID() { return sfx->ClassID(); }
02687         ReferenceTarget* GetThing() { return sfx; }
02688         void        SetThing(ReferenceTarget *fx);
02689         void        DeleteThis();
02690         void        SetTime(TimeValue t);
02691 
02692         void        InvalidateUI(); 
02693         // secondary dialog list management
02694         int         NumDlgs() { return secondaryDlgs.Count(); }
02695         void        AddDlg(SFXParamDlg* dlg);
02696         SFXParamDlg* GetDlg(int i);
02697         void        SetDlg(int i, SFXParamDlg* dlg);
02698         void        DeleteDlg(SFXParamDlg* dlg);
02699 
02700         // access to this dlg's parammap stuff
02701         IParamMap2* GetMap() { return NULL; }
02702 };
02703 
02704 // RK: End 
02705 
02706 // ----------------------- MSPluginAtmos ----------------------
02707 // scripted Atmospheric
02708 
02709 class MSPluginAtmos : public MSPluginSpecialFX<Atmospheric>
02710 {
02711 public:
02712     MSAutoEParamDlg* masterFXDlg;                       // master dialog containing all scripted rollout
02713 
02714                     MSPluginAtmos() { }
02715                     MSPluginAtmos(MSPluginClass* pc, BOOL loading);
02716                    ~MSPluginAtmos() { DeleteAllRefsFromMe(); }
02717 
02718     static RefTargetHandle create(MSPluginClass* pc, BOOL loading);
02719     RefTargetHandle Clone(RemapDir& remap);
02720 
02721     // from Atmospheric
02722     AtmosParamDlg *CreateParamDialog(IRendParams *ip);
02723     BOOL SetDlgThing(AtmosParamDlg* dlg);
02724     void Shade(ShadeContext& sc,const Point3& p0,const Point3& p1,Color& color, Color& trans, BOOL isBG=FALSE) { };
02725 
02726     Atmospheric* to_atmospheric() { return this; }
02727 };
02728 
02729 class MSAtmosXtnd : public MSSpecialFXXtnd<Atmospheric, MSPluginAtmos>
02730 {
02731 public:
02732                     MSAtmosXtnd(MSPluginClass* pc, BOOL loading);
02733                    ~MSAtmosXtnd() { DeleteAllRefsFromMe(); }
02734     RefTargetHandle Clone(RemapDir& remap);
02735 
02736     // from Atmospheric
02737     AtmosParamDlg *CreateParamDialog(IRendParams *ip);
02738     BOOL SetDlgThing(AtmosParamDlg* dlg);
02739     void Shade(ShadeContext& sc,const Point3& p0,const Point3& p1,Color& color, Color& trans, BOOL isBG=FALSE) 
02740         { delegate->Shade(sc, p0, p1, color, trans, isBG); }
02741 
02742 };
02743 
02744 // RK: End 
02745 
02746 class MSPluginTrackViewUtility : public MSPlugin, public TrackViewUtility, public ReferenceTarget
02747 {
02748 public:
02749     Interface*      ip;                 // ip for any currently open command panel dialogs
02750     ITVUtility*     iu;                 // access to various trackview methods
02751 
02752     MSPluginTrackViewUtility() { }
02753     MSPluginTrackViewUtility(MSPluginClass* pc, BOOL loading);
02754     ~MSPluginTrackViewUtility() { DeleteAllRefsFromMe(); }
02755 
02756     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
02757     using Collectable::operator new;
02758     using Collectable::operator delete;
02759 
02760     // From TrackViewUtility
02761     virtual void BeginEditParams(Interface *ip,ITVUtility *iu);
02762     virtual void EndEditParams(Interface *ip,ITVUtility *iu);
02763     virtual void TrackSelectionChanged();
02764     virtual void NodeSelectionChanged();
02765     virtual void KeySelectionChanged();
02766     virtual void TimeSelectionChanged();
02767     virtual void MajorModeChanged();
02768     virtual void TrackListChanged();
02769     virtual int FilterAnim(Animatable* anim, Animatable* client, int subNum);
02770 
02771     static TrackViewUtility* create(MSPluginClass* pc, BOOL loading);
02772 
02773 
02774     // From MSPlugin
02775     virtual HWND            AddRollupPage(HINSTANCE hInst, MCHAR *dlgTemplate, DLGPROC dlgProc, MCHAR *title, LPARAM param=0,DWORD flags=0, int category=ROLLUP_CAT_STANDARD);
02776     virtual void            DeleteRollupPage(HWND hRollup);
02777     virtual IRollupWindow* GetRollupWindow();
02778     virtual ReferenceTarget* get_delegate() { return NULL; }  // no delegate 
02779 
02780     // From Animatable
02781     using ReferenceTarget::GetInterface;
02782 
02783     void            DeleteThis() {  MSPlugin::DeleteThis(); }
02784     void            GetClassName(MSTR& s) { s = MSTR(pc->class_name->to_string()); }  
02785     Class_ID        ClassID() { return pc->class_id; }
02786     void            FreeCaches() { }        
02787     int             NumSubs() { return pblocks.Count(); }  
02788     Animatable*     SubAnim(int i) { return pblocks[i]; }
02789     MSTR            SubAnimName(int i) { return pblocks[i]->GetLocalName(); }
02790     int             NumParamBlocks() { return pblocks.Count(); }
02791     IParamBlock2*   GetParamBlock(int i) { return pblocks[i]; }
02792     IParamBlock2*   GetParamBlockByID(BlockID id) { return MSPlugin::GetParamBlockByID(id); }
02793     virtual void*   GetInterface(ULONG id) { if (id == I_MAXSCRIPTPLUGIN) return (MSPlugin*)this; else return ReferenceTarget::GetInterface(id); }
02794 
02795     // From ReferenceMaker
02796     RefResult       NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message) 
02797                     { 
02798                         return ((MSPlugin*)this)->NotifyRefChanged(changeInt, hTarget, partID, message); 
02799                     }
02800 
02801     // From ReferenceTarget
02802     int             NumRefs();
02803     RefTargetHandle GetReference(int i);
02804 protected:
02805     virtual void            SetReference(int i, RefTargetHandle rtarg); 
02806 public:
02807     RefTargetHandle Clone(RemapDir& remap);
02808 
02809 };
02810 #pragma warning(pop)
02811 
02812 #ifdef _DEBUG
02813   extern BOOL dump_load_postload_callback_order;
02814 #endif
02815 
02816 // A pair of post load callback2 to process possible redefinition of loaded instances of scripted classes
02817 // LAM - 3/7/03. Added per iload processing, 2 pass processing
02818 // PluginClassDefPLCB1 - migrates parameter blocks, calls update handler if needed
02819 // PluginClassDefPLCB2 - calls load handler, all set handlers, post load handler
02820 class PluginClassDefPLCB1 : public PostLoadCallback 
02821 {
02822 public:
02823     Tab<ILoad*> registeredILoads;
02824     bool isRegistered(ILoad* iload)
02825     {   int count = registeredILoads.Count();
02826         for (int i = 0; i< count; i++)
02827             if (registeredILoads[i] == iload)
02828                 return true;
02829         return false;
02830     }
02831     void Register(ILoad* iload)
02832     {   registeredILoads.Append(1,&iload);
02833     }
02834     void Unregister(ILoad* iload)
02835     {   int count = registeredILoads.Count();
02836         for (int i = 0; i< count; i++)
02837             if (registeredILoads[i] == iload)
02838             {
02839                 registeredILoads.Delete(i,1);
02840                 return;
02841             }
02842     }
02843     
02844     PluginClassDefPLCB1() { }
02845     int Priority() { return 5; }
02846 
02847     void proc(ILoad *iload)
02848     {
02849 #ifdef _DEBUG
02850         if (dump_load_postload_callback_order) 
02851             DebugPrint(_M("MXS: PostLoadCallback1 run: thePluginClassDefPLCB1\n"));
02852 #endif
02853         MSPluginClass::post_load(iload,0);
02854         Unregister(iload);
02855     }
02856 };
02857 
02858 extern PluginClassDefPLCB1 thePluginClassDefPLCB1;
02859 
02860 class PluginClassDefPLCB2 : public PostLoadCallback 
02861 {
02862 public:
02863     
02864     PluginClassDefPLCB2() { }
02865     int Priority() { return 10; }
02866     
02867     void proc(ILoad *iload)
02868     {
02869 #ifdef _DEBUG
02870         if (dump_load_postload_callback_order) 
02871             DebugPrint(_M("MXS: PostLoadCallback2 run: thePluginClassDefPLCB2\n"));
02872 #endif
02873         MSPluginClass::post_load(iload,1);
02874     }
02875 };
02876 extern PluginClassDefPLCB2 thePluginClassDefPLCB2;
02877 
02878 
02880 class CustAttribClassDefPLCB1 : public PostLoadCallback 
02881 {
02882 public:
02883     Tab<ILoad*> registeredILoads;
02884     bool isRegistered(ILoad* iload)
02885     {
02886         int count = registeredILoads.Count();
02887         for (int i = 0; i< count; i++)
02888             if (registeredILoads[i] == iload)
02889                 return true;
02890         return false;
02891     }
02892     void Register(ILoad* iload)
02893     {
02894         registeredILoads.Append(1,&iload);
02895     }
02896     void Unregister(ILoad* iload)
02897     {
02898         int count = registeredILoads.Count();
02899         for (int i = 0; i< count; i++)
02900             if (registeredILoads[i] == iload)
02901             {
02902                 registeredILoads.Delete(i,1);
02903                 return;
02904             }
02905     }
02906 
02907     MAX_DEPRECATED CustAttribClassDefPLCB1() { }
02908     int Priority() { return 5; }
02909 
02910     void proc(ILoad *iload)
02911     {
02912 #ifdef _DEBUG
02913         if (dump_load_postload_callback_order) 
02914             DebugPrint(_M("MXS: PostLoadCallback1 run: theCustAttribClassDefPLCB1\n"));
02915 #endif
02916         MSPluginClass::post_load(iload,2);
02917         Unregister(iload);
02918     }
02919 };
02920 
02921 extern CustAttribClassDefPLCB1 theCustAttribClassDefPLCB1;
02922 
02924 class CustAttribClassDefPLCB2 : public PostLoadCallback 
02925 {
02926 public:
02927 
02928     MAX_DEPRECATED CustAttribClassDefPLCB2() { }
02929     int Priority() { return 10; }
02930 
02931     void proc(ILoad *iload)
02932     {
02933 #ifdef _DEBUG
02934         if (dump_load_postload_callback_order) 
02935             DebugPrint(_M("MXS: PostLoadCallback2 run: theCustAttribClassDefPLCB2\n"));
02936 #endif
02937         MSPluginClass::post_load(iload,3);
02938     }
02939 };
02940 extern CustAttribClassDefPLCB2 theCustAttribClassDefPLCB2;
02941 
02942