Scene.h



Your Ad Here

00001 /****************************************************************************************
00002 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00003 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE 
00004 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00005 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00006 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00007 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE . 
00008  
00009 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00010 
00011 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00012 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00013 trademarks contained herein are the property of their respective owners. 
00014 ****************************************************************************************/
00015 
00016 #ifndef _SCENE_H
00017 #define _SCENE_H
00018 
00019 #include "Template.h"
00020 #include "Logger.h"
00021 
00022 class CSLScene;
00023 class CSLModel;
00024 class CSLAmbience;
00025 class CSLAngle;
00026 class CSLCoordinateSystem;
00027 class CSLFileInfo;
00028 class CSLSceneInfo;
00029 class CSLEnvelopeList;
00030 class CSLMaterialLibrary;
00031 class CSLFog;
00032 class CSLActionFCurve;
00033 class CSLFCurve;
00034 class CSLTransform;
00035 class CSLAction;
00036 class CSLShapeAnimation;
00037 class CSLVisibility;
00038 class CSLXSIMaterial;
00039 class CSLImageLibrary;
00040 class CSLImage;
00041 class CSLXSIShader;
00042 
00048 class XSIEXPORT CSLUnresolvedElement
00049 {
00050 public:
00051     CSLUnresolvedElement
00052     ( 
00053         CSLTemplate *in_pUnresolvedObject,  
00054         CSLTemplate *in_pUnresolvedParent = 0,  
00055         SI_Char *in_pReferenceName = 0,
00056         void *in_pUserData = 0
00057     );
00058 
00062     inline CSLTemplate* UnresolvedObject();
00063 
00067     inline CSLTemplate* UnresolvedParent();
00068 
00072     inline SI_Char*  ReferenceName();
00073 
00077     inline void*         UserData();
00078 
00079 private:
00080     CSLTemplate *m_pUnresolvedObject;
00081     CSLTemplate *m_pUnresolvedParent;
00082     SI_Char *m_pReferenceName;
00083     void *m_pUserData;
00084 
00085     // This member is here to allow future improvement of the class.
00086     void *m_pReserved;
00087 };
00088 
00089 inline CSLTemplate* CSLUnresolvedElement::UnresolvedObject()
00090 {
00091     return m_pUnresolvedObject;
00092 }
00093 
00094 inline CSLTemplate* CSLUnresolvedElement::UnresolvedParent()
00095 {
00096     return m_pUnresolvedParent;
00097 }
00098 inline SI_Char* CSLUnresolvedElement::ReferenceName()
00099 {
00100     return m_pReferenceName;
00101 }
00102 
00103 inline void* CSLUnresolvedElement::UserData()
00104 {
00105     return m_pUserData;
00106 }
00107 
00108 #ifdef  FTK_KERNEL
00109 typedef std::multimap<SI_Char *, CSLUnresolvedElement, StrLessPred> CSLUnresolvedMap;
00110 typedef CSLUnresolvedMap::iterator CSLUnresolvedMapIterator;
00111 typedef std::pair<CSLUnresolvedMapIterator,CSLUnresolvedMapIterator> CSLUnresolvedMapRange;
00112 
00113 typedef SI_StrMap<CSLModel *> CSLModelMap;
00114 typedef CSLModelMap::iterator CSLModelMapIterator;
00115 #else
00116 typedef void CSLUnresolvedMap;
00117 typedef void CSLModelMap;
00118 #endif
00119 
00126 struct XSIEXPORT SLContext
00127 {
00128 public:
00129     SLContext();
00130     SI_Void AddOrphan(CSLTemplate *in_pOrphanTemplate); 
00132     CSLTemplate *m_pCurrentTemplate;                    
00133     CSLModel *m_pCurrentModel;                          
00134     CSLScene *m_pScene;                                 
00135     CSLMaterialLibrary *m_pMaterialLibrary;             
00136     CSLXSIMaterial *m_pCurrentMaterial;                 
00137     CSIBCArray<CSLTemplate *> *m_pOrphanList;           
00138     void *m_pTemplateUserData;                          
00139     CSLUnresolvedMap *m_pUnresolvedMap;                 
00140     CSLModelMap *m_pModelMap;                           
00141     CSLImageLibrary *m_pImageLibrary;                   
00142     CSLImage *m_pCurrentImage;                          
00143     CSLXSIShader *m_pCurrentXSIShader;                  
00144     void *m_pUserData;                                  
00146 private:
00147     // This member is here to allow future improvement of the class.
00148     void *m_pReserved;
00149 };
00150 
00151 typedef CSLTemplate *(*CSLCALLBACK) (CdotXSITemplate *in_pTemplate, SLContext *in_pContext);
00152 typedef SI_Error (*CSLPOSTCHILDRENCALLBACK) (CSLTemplate *in_pTemplate, SLContext *in_pContext);
00153 typedef SI_Error (*CSLLOADCALLBACK) (SLContext *in_pContext);
00154 
00171 class XSIEXPORT SLTemplateCallback
00172 {
00173 public: 
00174     SLTemplateCallback();
00175     void Clear();
00176 
00177     CSLLOADCALLBACK m_PreLoadCallback;
00178     CSLCALLBACK m_Callback;
00179     CSLPOSTCHILDRENCALLBACK m_PostChildrenCallback;
00180     CSLLOADCALLBACK m_PostLibraryCallback;
00181     CSLLOADCALLBACK m_PostLoadCallback;
00182 
00183     void *m_pUserData;
00184 
00185 private:
00186     // This member is here to allow future improvement of the class.
00187     void *m_pReserved;
00188 };
00189 
00197 class XSIEXPORT CSLScene
00198 {
00199 public:
00201     // Construction/destruction
00203     CSLScene();
00204     virtual ~CSLScene();
00205 
00207     // File manipulation functions.
00209 
00214     SI_Error Open(SI_Char *in_szFileName);
00215 
00222     SI_Error Open(SI_Char *in_szFileName, SI_READ_CALLBACK_FNC in_pFunc);
00223 
00231     SI_Error Create(SI_Char *in_szFileName, SI_Int in_nVersionMajor, SI_Int in_nVersionMinor, SI_Int in_nFormat = FORMAT_TEXT);
00232 
00239     SI_Error Create(SI_Int in_nVersionMajor, SI_Int in_nVersionMinor, SI_Int in_nFormat = FORMAT_TEXT);
00240 
00245     SI_Error Open(CXSIParser * in_parser);
00249     SI_Error Read();
00250 
00254     virtual SI_Error Write();
00255 
00260     virtual SI_Error Write(SI_Char* in_szFileName);
00261 
00265     SI_Error Close();
00266 
00271     CSLModel*           FindModel(SI_Char* in_szModelName);
00272 
00278     CSLModel*           FindModelRecursively(SI_Char* in_szModelName, CSLModel* in_pModel);
00279 
00287     CSLAnimatableType*  FindParameter(SI_Char* in_szParameterName);
00288 
00294     SI_Error            GetValue(SI_Char* in_szParameterName, SI_Float* out_pfValue);
00295 
00301     SI_Error            SetValue(SI_Char* in_szParameterName, SI_Float in_fValue);
00302 
00304     // Accessors
00306     
00310     CSLAmbience *Ambience();
00311 
00315     CSLCoordinateSystem* CoordinateSystem();
00316 
00320     CSLEnvelopeList* EnvelopeList();
00321     
00325     CSLFog* Fog();
00326 
00330     CSLMaterialLibrary* GetMaterialLibrary();
00331 
00335     CSLModel *Root();
00336 
00340     CXSIParser* Parser();
00341 
00345     CSLAngle* Angle();
00346     
00350     CSLFileInfo* FileInfo();
00351 
00355     CSLSceneInfo* SceneInfo();
00356 
00360     CSLLogger* Logger();
00361 
00365     CSIBCString &FileName();
00366 
00370     CSLImageLibrary* GetImageLibrary();
00371 
00375     SI_Error DestroyFog();
00376 
00380     CSLFog* CreateFog();
00381 
00385     SI_Error DestroyEnvelopeList();
00386 
00390     virtual CSLEnvelopeList* CreateEnvelopeList();
00391 
00396     virtual CSLImageLibrary* CreateImageLibrary();
00397 
00402     SI_Error DestroyImageLibrary();
00403     
00404     
00406     // Connection functions.
00408     
00413     virtual CSLMaterialLibrary* ConnectMaterialLibrary(CSLMaterialLibrary *in_pNewMaterialLibrary);
00414 
00419     CSLAngle* ConnectAngle(CSLAngle *in_pNewAngle);
00420 
00425     CSLFileInfo* ConnectFileInfo(CSLFileInfo *in_pNewFileInfo);
00426 
00431     CSLSceneInfo* ConnectSceneInfo(CSLSceneInfo* in_pToConnect);
00432 
00437     CSLFog* ConnectFog( CSLFog *in_pNewFog );
00438 
00443     CSLAmbience* ConnectAmbience( CSLAmbience *in_pNewAmbience );
00444 
00449     CSLCoordinateSystem* ConnectCoordinateSystem( CSLCoordinateSystem *in_pNewCoordSystem );
00450 
00455     CSLEnvelopeList* ConnectEnvelopeList( CSLEnvelopeList* in_pNewEnvList );
00456 
00462     CSLImageLibrary* ConnectImageLibrary( CSLImageLibrary* in_pImageLibrary );
00463 
00498     SI_Error RegisterCallback(SI_Char *in_pName, SLTemplateCallback *in_pTemplateCallback);
00499 
00504     SI_Error UnregisterCallback(SI_Char *in_pName);
00505 
00509     SI_Error UnregisterAllCallbacks();
00510 
00515     SLTemplateCallback *Callback(SI_Char *in_pName);
00516 
00518     // Coherancy functions
00520     virtual SI_Error Fix();
00521     virtual SI_Error Synchronize();
00522 
00524     // Utility functions
00526     SI_Error RemoveTemplate(CdotXSITemplate *in_pElement);
00527     SI_Error ClearSLObjectArray(CSIBCArray<CSLTemplate *> *in_pArray);
00528 
00534     SI_Bool SupportsTemplates( SI_Int in_nMajor, SI_Int in_nMinor );
00535 
00539     SI_Void SetWarningCallback ( SI_WARNING_CALLBACK_FNC in_pfncCallback ) { m_pfncCallback = in_pfncCallback; };
00540 
00544     SI_Void SetReadCallback ( SI_READ_CALLBACK_FNC in_pfncCallback ) { m_pfncReadCallback = in_pfncCallback; };
00551     SI_Error    GetRefCount( CSLTemplate                ** in_ppObjects,
00552                              SI_Int                     ** out_ppRefCounts,
00553                              SI_Int                     in_iObjectCount,
00554                              CSLTemplate::ETemplateType in_eType );
00555 
00556 
00557     static CSLScene * CreateScene();
00558 protected:
00559 
00560     SI_Error    GetRefCountRecursively      ( CSLModel* in_pModel, 
00561                                                     CSLTemplate** in_ppObjects, 
00562                                                     SI_Int**    out_ppRefCounts, 
00563                                                     SI_Int      in_iObjectCount, 
00564                                                     CSLTemplate::ETemplateType in_eType );
00565 
00566 
00567 protected:
00568     CSLModel    * FindFullyQualifiedObject( SI_Char * in_pName, SI_Char ** out_pContainer, SI_Char ** out_pParameter );
00569     virtual SI_Error PopulateScene();
00570     SI_Error ReadTemplateRecursively(CdotXSITemplate *in_pTemplate, SLContext *in_pContext);
00571     SI_Error ExecutePreLoadCallbacks(SLContext *in_pContext);
00572     SI_Error ExecutePostLibraryCallbacks(SLContext *in_pContext);
00573     SI_Error ExecutePostLoadCallbacks(SLContext *in_pContext);
00574     virtual SI_Error RegisterAllCallbacks();
00575     SI_Error Clear();
00576 
00577 #ifdef  FTK_KERNEL
00578     typedef SI_StrMap<SLTemplateCallback> CSLCallbackMap;
00579     typedef CSLCallbackMap::iterator CSLCallbackMapIterator;
00580 #else
00581     typedef void    CSLCallbackMap;
00582 #endif
00583 
00584     CSLSceneInfo* m_pSceneInfo;
00585     CSLFileInfo* m_pFileInfo;
00586     CSLAmbience* m_pAmbience;
00587     CSLAngle* m_pAngle;
00588     CSLFog* m_pFog;
00589     CSLEnvelopeList* m_pEnvelopeList;
00590     CSLMaterialLibrary* m_pMaterialLibrary;
00591     CSLCoordinateSystem* m_pCoordinateSystem;
00592     CXSIParser* m_pParser;
00593     CSLCallbackMap* m_pCallbackMap;
00594     CSLModel *m_pRoot;
00595     CSLLogger m_Logger;
00596     CSLImageLibrary *m_pImageLibrary;
00597 
00598     CSIBCString m_FileName;
00599 
00600     SI_WARNING_CALLBACK_FNC m_pfncCallback;
00601     SI_READ_CALLBACK_FNC    m_pfncReadCallback;
00602 
00603     // This member is here to allow future improvement of the class.
00604     void *m_pReserved;
00605 };
00606 
00607 #endif

Return to Softimage XSI Index


Your Ad Here