sceneio.h

Go to the documentation of this file.
00001 /*  
00002  *      SceneIO.h - MAXScript-related scene file I/O (persistent globals, on-open script, etc.)
00003  *
00004  *          Copyright (c) Autodesk, Inc, 1998.  John Wainwright.
00005  *
00006  */
00007 
00008 #pragma once
00009 #include "mxsMaxFileVersion.h"
00010 
00011 #include "..\ScripterExport.h"
00012 #include "..\kernel\value.h"
00013 #include "..\..\maxtypes.h"
00014 #include "..\..\tab.h"
00015 #include "..\..\ioapi.h"
00016 
00017 // forward declarations
00018 class ValueLoader;
00019 class ILoad;
00020 class ISave;
00021 
00022 /* --------- Scene I/O chunk ID's ---------- */
00023 
00024 #define OPENSCRIPT_CHUNK            0x0010    // obsoleted by CALLBACKSCRIPT_CHUNK
00025 #define SAVESCRIPT_CHUNK            0x0020    // obsoleted by CALLBACKSCRIPT_CHUNK
00026 #define PSGLOBALS_CHUNK             0x0030
00027 #define MSPLUGINCLASS_CHUNK         0x0040
00028 #define MSPLUGINCLASSHDR_CHUNK      0x0050
00029 #define LENGTH_CHUNK                0x0060
00030 #define CALLBACKSCRIPT_CHUNK        0x0070
00031 #define CUSTATTRIBDEF_CHUNK         0x0080
00032 #define SOURCE_CHUNK                0x00a0
00033 
00034 /* ---- persistent global value loading ----- */
00035 
00036 typedef Value* (*load_fn)(ILoad* iload, USHORT chunkID, ValueLoader* vl);
00037 
00038 enum LoadableClassID 
00039 {
00040     Undefined_Chunk = 0,    Boolean_Chunk,          Ok_Chunk,
00041     Integer_Chunk,          Float_Chunk,            String_Chunk, 
00042     Name_Chunk,             Array_Chunk,            Point3Value_Chunk, 
00043     QuatValue_Chunk,        RayValue_Chunk,         AngAxisValue_Chunk,
00044     EulerAnglesValue_Chunk, Matrix3Value_Chunk,     Point2Value_Chunk,
00045     ColorValue_Chunk,       MSTime_Chunk,           MSInterval_Chunk,
00046     MAXWrapper_Chunk,       Unsupplied_Chunk,       Struct_Chunk,
00047     Point4Value_Chunk,      Empty_Chunk,            Integer64_Chunk,
00048     DoubleValue_Chunk,
00049 
00050     // add more here...
00051 
00052     HIGH_CLASS_CHUNK  // must be last
00053 };
00054 
00055 
00056 extern ScripterExport Value* load_value(ILoad* iload, ValueLoader* vload);
00057 extern void save_persistent_callback_scripts(ISave* isave);
00058 extern IOResult load_persistent_callback_script(ILoad* iload);
00059 extern Tab<ValueLoader*> value_loaders;
00060 
00061 #ifdef _DEBUG
00062   extern BOOL dump_load_postload_callback_order;
00063 #endif
00064 
00065 // post global load callback scheme, allows different loaders to 
00066 // permit ::Load() fns to register a callback to clean-up a load.  
00067 // Eg, Array loader gets such a callback from MAXWrapper::Load() which
00068 // uses this to build the MAXWrapper at post-load time, after object pointers
00069 // have been back-patched.
00070 
00071 // ::Load()'s that need to specialize this to provide a callback
00072 class ValueLoadCallback
00073 {
00074 public:
00075     virtual Value* post_load() { return &undefined; }  // return the cleaned-up value
00076 };
00077 
00078 // each loader specializes this and gives it to the ::Load()
00079 class ValueLoader
00080 {
00081 public:
00082     virtual void register_callback(ValueLoadCallback* cb) { UNUSED_PARAM(cb); }
00083     virtual void call_back() { }
00084 };
00085 
00086 // A post load callback to process persistent value load callbacks
00087 class ValueLoadPLCB : public PostLoadCallback 
00088 {
00089 public:
00090     ScripterExport void proc(ILoad *iload);
00091 };
00092 
00093 // callback script  (see MAXCallbacks.cpp)
00094 class CallbackScript 
00095 { 
00096 public:
00097     MSTR    script;     // callback script or script filename
00098     Value*  code;       // cached compiled code
00099     Value*  id;         // script ID
00100     short   flags;      // flags
00101 
00102     CallbackScript(MCHAR* iscript, Value* iid, short iflags)
00103     {
00104         script = iscript; code = NULL; id = iid; flags = iflags;
00105     }
00106 };
00107 
00108 #define MCB_SCRIPT_IS_FILE      0x0001
00109 #define MCB_PERSISTENT          0x0002
00110 #define MCB_HAS_ID              0x0004
00111 #define MCB_INVALID             0x0008
00112 
00113 extern Tab<CallbackScript*>* callback_scripts[];
00114