00001
00002
00012
00013
00014 #ifndef _SCENE_H
00015 #define _SCENE_H
00016
00017 #include "Template.h"
00018 #include "Logger.h"
00019
00020 class CSLScene;
00021 class CSLModel;
00022 class CSLAmbience;
00023 class CSLAngle;
00024 class CSLCoordinateSystem;
00025 class CSLFileInfo;
00026 class CSLSceneInfo;
00027 class CSLEnvelopeList;
00028 class CSLMaterialLibrary;
00029 class CSLFog;
00030 class CSLActionFCurve;
00031 class CSLFCurve;
00032 class CSLTransform;
00033 class CSLAction;
00034 class CSLShapeAnimation;
00035 class CSLVisibility;
00036 class CSLXSIMaterial;
00037 class CSLImageLibrary;
00038 class CSLImage;
00039 class CSLXSIShader;
00040
00044 class XSIEXPORT CSLUnresolvedElement
00045 {
00046 public:
00047 CSLUnresolvedElement
00048 (
00049 CSLTemplate *in_pUnresolvedObject,
00050 CSLTemplate *in_pUnresolvedParent = 0,
00051 SI_Char *in_pReferenceName = 0,
00052 void *in_pUserData = 0
00053 );
00054
00058 inline CSLTemplate* UnresolvedObject();
00059
00063 inline CSLTemplate* UnresolvedParent();
00064
00068 inline SI_Char* ReferenceName();
00069
00073 inline void* UserData();
00074
00075 private:
00076 CSLTemplate *m_pUnresolvedObject;
00077 CSLTemplate *m_pUnresolvedParent;
00078 SI_Char *m_pReferenceName;
00079 void *m_pUserData;
00080
00081
00082 void *m_pReserved;
00083 };
00084
00085 inline CSLTemplate* CSLUnresolvedElement::UnresolvedObject()
00086 {
00087 return m_pUnresolvedObject;
00088 }
00089
00090 inline CSLTemplate* CSLUnresolvedElement::UnresolvedParent()
00091 {
00092 return m_pUnresolvedParent;
00093 }
00094 inline SI_Char* CSLUnresolvedElement::ReferenceName()
00095 {
00096 return m_pReferenceName;
00097 }
00098
00099 inline void* CSLUnresolvedElement::UserData()
00100 {
00101 return m_pUserData;
00102 }
00103
00104 #ifdef FTK_KERNEL
00105 typedef std::multimap<SI_Char *, CSLUnresolvedElement, StrLessPred> CSLUnresolvedMap;
00106 typedef CSLUnresolvedMap::iterator CSLUnresolvedMapIterator;
00107 typedef std::pair<CSLUnresolvedMapIterator,CSLUnresolvedMapIterator> CSLUnresolvedMapRange;
00108
00109 typedef SI_StrMap<CSLModel *> CSLModelMap;
00110 typedef CSLModelMap::iterator CSLModelMapIterator;
00111 #else
00112 typedef void CSLUnresolvedMap;
00113 typedef void CSLModelMap;
00114 #endif
00115
00119 struct XSIEXPORT SLContext
00120 {
00121 public:
00122 SLContext();
00127 SI_Void AddOrphan(CSLTemplate *in_pOrphanTemplate);
00128
00129 CSLTemplate *m_pCurrentTemplate;
00130 CSLModel *m_pCurrentModel;
00131 CSLScene *m_pScene;
00132 CSLMaterialLibrary *m_pMaterialLibrary;
00133 CSLXSIMaterial *m_pCurrentMaterial;
00134 CSIBCArray<CSLTemplate *> *m_pOrphanList;
00135 void *m_pTemplateUserData;
00136 CSLUnresolvedMap *m_pUnresolvedMap;
00137 CSLModelMap *m_pModelMap;
00138 CSLImageLibrary *m_pImageLibrary;
00139 CSLImage *m_pCurrentImage;
00140 CSLXSIShader *m_pCurrentXSIShader;
00141 void *m_pUserData;
00143 private:
00144
00145 void *m_pReserved;
00146 };
00147
00148 typedef CSLTemplate *(*CSLCALLBACK) (CdotXSITemplate *in_pTemplate, SLContext *in_pContext);
00149 typedef SI_Error (*CSLPOSTCHILDRENCALLBACK) (CSLTemplate *in_pTemplate, SLContext *in_pContext);
00150 typedef SI_Error (*CSLLOADCALLBACK) (SLContext *in_pContext);
00151
00166 class XSIEXPORT SLTemplateCallback
00167 {
00168 public:
00169 SLTemplateCallback();
00170 void Clear();
00171
00172 CSLLOADCALLBACK m_PreLoadCallback;
00173 CSLCALLBACK m_Callback;
00174 CSLPOSTCHILDRENCALLBACK m_PostChildrenCallback;
00175 CSLLOADCALLBACK m_PostLibraryCallback;
00176 CSLLOADCALLBACK m_PostLoadCallback;
00177
00178 void *m_pUserData;
00179
00180 private:
00181
00182 void *m_pReserved;
00183 };
00184
00191 class XSIEXPORT CSLScene
00192 {
00193 public:
00195
00197 CSLScene();
00198 virtual ~CSLScene();
00199
00201
00203
00208 SI_Error Open(SI_Char *in_szFileName);
00209
00216 SI_Error Open(SI_Char *in_szFileName, SI_READ_CALLBACK_FNC in_pFunc);
00217
00225 SI_Error Create(SI_Char *in_szFileName, SI_Int in_nVersionMajor, SI_Int in_nVersionMinor, SI_Int in_nFormat = FORMAT_TEXT);
00226
00233 SI_Error Create(SI_Int in_nVersionMajor, SI_Int in_nVersionMinor, SI_Int in_nFormat = FORMAT_TEXT);
00234
00239 SI_Error Open(CXSIParser * in_parser);
00240
00244 SI_Error Read();
00245
00250 virtual SI_Error Write(bool in_bSynchronize = true);
00251
00257 virtual SI_Error Write(SI_Char* in_szFileName, bool in_bSynchronize = true);
00258
00262 SI_Error Close();
00263
00268 CSLModel* FindModel(SI_Char* in_szModelName);
00269
00275 CSLModel* FindModelRecursively(SI_Char* in_szModelName, CSLModel* in_pModel);
00276
00282 CSLAnimatableType* FindParameter(SI_Char* in_szParameterName);
00283
00290 SI_Error GetValue(SI_Char* in_szParameterName, SI_Float* out_pfValue);
00291
00298 SI_Error SetValue(SI_Char* in_szParameterName, SI_Float in_fValue);
00299
00301
00303
00307 CSLAmbience *Ambience();
00308
00312 CSLAmbience *CreateAmbience();
00313
00317 SI_Error DestroyAmbience();
00318
00322 CSLCoordinateSystem* CoordinateSystem();
00323
00327 CSLEnvelopeList* EnvelopeList();
00328
00332 CSLFog* Fog();
00333
00337 CSLMaterialLibrary* GetMaterialLibrary();
00338
00342 CSLModel *Root();
00343
00347 CXSIParser* Parser();
00348
00352 CSLAngle* Angle();
00353
00357 CSLFileInfo* FileInfo();
00358
00362 CSLSceneInfo* SceneInfo();
00363
00367 CSLLogger* Logger();
00368
00372 CSIBCString &FileName();
00373
00377 CSLImageLibrary* GetImageLibrary();
00378
00382 SI_Error DestroyFog();
00383
00387 CSLFog* CreateFog();
00388
00392 SI_Error DestroyEnvelopeList();
00393
00397 virtual CSLEnvelopeList* CreateEnvelopeList();
00398
00403 virtual CSLImageLibrary* CreateImageLibrary();
00404
00409 SI_Error DestroyImageLibrary();
00410
00411
00413
00415
00420 virtual CSLMaterialLibrary* ConnectMaterialLibrary(CSLMaterialLibrary *in_pNewMaterialLibrary);
00421
00426 CSLAngle* ConnectAngle(CSLAngle *in_pNewAngle);
00427
00432 CSLFileInfo* ConnectFileInfo(CSLFileInfo *in_pNewFileInfo);
00433
00438 CSLSceneInfo* ConnectSceneInfo(CSLSceneInfo* in_pToConnect);
00439
00444 CSLFog* ConnectFog( CSLFog *in_pNewFog );
00445
00450 CSLAmbience* ConnectAmbience( CSLAmbience *in_pNewAmbience );
00451
00456 CSLCoordinateSystem* ConnectCoordinateSystem( CSLCoordinateSystem *in_pNewCoordSystem );
00457
00462 CSLEnvelopeList* ConnectEnvelopeList( CSLEnvelopeList* in_pNewEnvList );
00463
00470 CSLImageLibrary* ConnectImageLibrary( CSLImageLibrary* in_pImageLibrary );
00471
00506 SI_Error RegisterCallback(SI_Char *in_pName, SLTemplateCallback *in_pTemplateCallback);
00507
00512 SI_Error UnregisterCallback(SI_Char *in_pName);
00513
00517 SI_Error UnregisterAllCallbacks();
00518
00523 SLTemplateCallback *Callback(SI_Char *in_pName);
00524
00526
00528 virtual SI_Error Fix();
00529 virtual SI_Error Synchronize();
00530
00532
00534 SI_Error RemoveTemplate(CdotXSITemplate *in_pElement);
00535 SI_Error ClearSLObjectArray(CSIBCArray<CSLTemplate *> *in_pArray);
00536
00543 SI_Bool SupportsTemplates( SI_Int in_nMajor, SI_Int in_nMinor );
00544
00548 SI_Void SetWarningCallback ( SI_WARNING_CALLBACK_FNC in_pfncCallback ) { m_pfncCallback = in_pfncCallback; };
00549
00553 SI_Void SetReadCallback ( SI_READ_CALLBACK_FNC in_pfncCallback ) { m_pfncReadCallback = in_pfncCallback; };
00560 SI_Error GetRefCount( CSLTemplate ** in_ppObjects,
00561 SI_Int ** out_ppRefCounts,
00562 SI_Int in_iObjectCount,
00563 CSLTemplate::ETemplateType in_eType );
00564
00565
00566 static CSLScene * CreateScene();
00567 protected:
00568
00569 SI_Error GetRefCountRecursively ( CSLModel* in_pModel,
00570 CSLTemplate** in_ppObjects,
00571 SI_Int** out_ppRefCounts,
00572 SI_Int in_iObjectCount,
00573 CSLTemplate::ETemplateType in_eType );
00574
00575
00576 protected:
00577 CSLModel * FindFullyQualifiedObject( SI_Char * in_pName, SI_Char ** out_pContainer, SI_Char ** out_pParameter );
00578 virtual SI_Error PopulateScene();
00579 SI_Error ReadTemplateRecursively(CdotXSITemplate *in_pTemplate, SLContext *in_pContext);
00580 SI_Error ExecutePreLoadCallbacks(SLContext *in_pContext);
00581 SI_Error ExecutePostLibraryCallbacks(SLContext *in_pContext);
00582 SI_Error ExecutePostLoadCallbacks(SLContext *in_pContext);
00583 virtual SI_Error RegisterAllCallbacks();
00584 SI_Error Clear();
00585
00586 #ifdef FTK_KERNEL
00587 typedef SI_StrMap<SLTemplateCallback> CSLCallbackMap;
00588 typedef CSLCallbackMap::iterator CSLCallbackMapIterator;
00589 #else
00590 typedef void CSLCallbackMap;
00591 #endif
00592
00593 CSLSceneInfo* m_pSceneInfo;
00594 CSLFileInfo* m_pFileInfo;
00595 CSLAmbience* m_pAmbience;
00596 CSLAngle* m_pAngle;
00597 CSLFog* m_pFog;
00598 CSLEnvelopeList* m_pEnvelopeList;
00599 CSLMaterialLibrary* m_pMaterialLibrary;
00600 CSLCoordinateSystem* m_pCoordinateSystem;
00601 CXSIParser* m_pParser;
00602 CSLCallbackMap* m_pCallbackMap;
00603 CSLModel *m_pRoot;
00604 CSLLogger m_Logger;
00605 CSLImageLibrary *m_pImageLibrary;
00606
00607 CSIBCString m_FileName;
00608
00609 SI_WARNING_CALLBACK_FNC m_pfncCallback;
00610 SI_READ_CALLBACK_FNC m_pfncReadCallback;
00611
00612
00613 void *m_pReserved;
00614 };
00615
00616 #endif