# COLLADAScene.h

    00001 //***************************************************************************************
    00002 //
    00003 // File supervisor: Crosswalk team
    00004 //
    00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.
    00006 // Use of this software is subject to the terms of the Autodesk license agreement
    00007 // provided at the time of installation or download, or which otherwise accompanies
    00008 // this software in either electronic or hard copy form.
    00009 //
    00010 //***************************************************************************************
    00011
    00012 #ifndef _COLLADASCENE_H
    00013 #define _COLLADASCENE_H
    00014
    00015 #include "Template.h"
    00016 #include "Logger.h"
    00017 #include "Scene.h"
    00018 #include "COLLADATemplate.h"
    00019 #include "COLLADAMaterialLibrary.h"
    00020 #include "COLLADAEffectLibrary.h"
    00021 #include <SIBCArray.h>
    00022 #include <SIBCStringTable.h>
    00023
    00024 #if defined(unix)
    00025 # include <unistd.h>
    00026 # include <limits.h>
    00027 # if !defined(MAX_PATH)
    00028 #  define MAX_PATH PATH_MAX
    00029 # endif
    00030 #endif
    00031
    00032
    00033 class CSLModel;
    00034 class CSLAmbience;
    00035 class CSLAngle;
    00036 class CSLCoordinateSystem;
    00037 class CSLFileInfo;
    00038 class CSLSceneInfo;
    00039 class CSLEnvelopeList;
    00040 class CSLMaterialLibrary;
    00041 class CSLFog;
    00042 class CSLActionFCurve;
    00043 class CSLFCurve;
    00044 class CSLTransform;
    00045 class CSLAction;
    00046 class CSLShapeAnimation;
    00047 class CSLVisibility;
    00048 class CSLXSIMaterial;
    00049 class CSLImageLibrary;
    00050 class CSLImage;
    00051 class CSLXSIShader;
    00052
    00053
    00054 typedef struct tagTemplateMap
    00055 {
    00056     CCOLLADATemplate*   m_pCollada;
    00057     CdotXSITemplate*    m_pLegacy;
    00058 } TemplateMap;
    00059
    00060 typedef struct tagSkinMap
    00061 {
    00062     CCOLLADATemplate*   m_pSkinTemplate;
    00063     CSLModel*           m_pEnvelope;
    00064 } SkinMap;
    00065
    00066
    00067 typedef struct tagSIDMap {
    00068     CSLTemplate*                m_pTemplate;
    00069     SI_Int                      m_hSID;
    00070     CSLAnimatableType*          m_pProxy;
    00071     CSLTemplate::EFCurveType    m_CurveType;
    00072     SI_Int                      m_hXSIName;
    00073 } SIDMap;
    00074
    00075 typedef struct tagUnresolvedMaterialMap
    00076 {
    00077     CSLCOLLADAMaterial* m_pMaterial;
    00078     CCOLLADATemplate*   m_pEffectTemplate;
    00079     CCOLLADATemplate*   m_pInstanceEffect;
    00080 } UnresolvedMaterialMap;
    00081
    00086 class XSIEXPORT CSLCOLLADALibrary : public CCOLLADATemplate
    00087 {
    00088 public:
    00089     CSLCOLLADALibrary(CCOLLADATemplate* in_pParent, const SI_Char* in_szName);
    00090     virtual ~CSLCOLLADALibrary();
    00091
    00092     // valid for library_visual_scenes only
    00093     CdotXSITemplate*    GetSceneTemplate(CSLCOLLADAScene* in_pScene);
    00094
    00095     SI_Char*            GenerateID();
    00096
    00097 private:
    00098     char                m_szSuffix[MAX_PATH];
    00099     char                m_szID[MAX_PATH];
    00100     LONG                m_iCount;
    00101 };
    00102
    00110 class XSIEXPORT CSLCOLLADAScene : public CSLScene
    00111 {
    00112 public:
    00114     // Construction/destruction
    00116     CSLCOLLADAScene();
    00117     virtual ~CSLCOLLADAScene();
    00118
    00119     static CSLCOLLADAScene * CreateScene();
    00120
    00123     virtual SI_Error Fix();
    00124     virtual SI_Error Synchronize();
    00125     virtual SI_Error Write();
    00126     virtual SI_Error Write(SI_Char* in_szFileName);
    00127     virtual CSLImageLibrary* CreateImageLibrary();
    00128     virtual CSLEnvelopeList* CreateEnvelopeList();
    00129
    00132     void    AddExtra( CCOLLADATemplate* in_pExtra );
    00133
    00136     CSLCOLLADALibrary*  GetLibrary( const SI_Char* in_szLibrarySuffix );
    00137
    00140     SI_Void ExportExtra ( bool in_bExtra ) { m_bExportExtra = in_bExtra; };
    00141     bool ExportExtra() { return m_bExportExtra; };
    00142
    00145     SI_Void GenerateIDAndInstanciate ( CCOLLADATemplate *in_pNode, CCOLLADATemplate *in_pLib, const SI_Char* in_szLibSuffix );
    00146
    00149     SI_Void InstanciateScene ( CCOLLADATemplate *in_pScene );
    00150
    00153     CCOLLADATemplate*       GetInstanciatedSceneTemplate ();
    00154
    00157     SI_Bool ChangeNodeInstanciation     ( SI_Char* in_szNodeID, SI_Char* in_szNewLib, SI_Char* in_szNewURL );
    00158
    00162     virtual CSLCOLLADAEffectLibrary* GetEffectLibrary();
    00163
    00168     virtual CSLCOLLADAEffectLibrary* ConnectEffectLibrary(CSLCOLLADAEffectLibrary *in_pNewEffectLibrary);
    00169
    00170
    00171     SI_Void AddSIDMap ( CSLTemplate* in_pTemplate, const char* in_szSID,
    00172                         const char* in_szSIDSuffix, CSLAnimatableType* in_pProxy,
    00173                         CSLTemplate::EFCurveType in_CurveType, const char* in_szXSIName );
    00174     SI_Void ResetSIDMap();
    00175
    00176     const char* GetString(SI_Int in_hString);
    00177     SIDMap* ResolveTarget(CSLTemplate* in_pTemplate, char* in_szSID);
    00178     SIDMap* ResolveTarget(char* in_szOwner, char* in_szSID);
    00179     SIDMap* FindParameterSID(CSLAnimatableType* in_pParam);
    00180
    00181     const char*     GetXSINameFromSIDTable ( CSLAnimatableType* in_pParam );
    00182
    00183     SI_Void AddSource ( CCOLLADATemplate *in_pParent,
    00184                                 SI_Char* in_szName,
    00185                                 SI_Char* in_szType,
    00186                                 SI_TinyVariant* in_pData,
    00187                                 SI_Long in_lCount,
    00188                                 SI_Long in_lStride,
    00189                                 SI_Char* in_szAccessorType );
    00190
    00191 protected:
    00192
    00193     virtual SI_Error RegisterAllCallbacks();
    00194     virtual SI_Error PopulateScene();
    00195
    00196
    00198     // Helpers
    00200
    00201     void    FixWriteCallbacks( CdotXSITemplate* in_pTemplate);
    00202     void    ReorderExtra( CdotXSITemplate* in_pTemplate);
    00203
    00205     // Members
    00207
    00208     CCOLLADATemplate*                           m_pTechTemplate;
    00209     CCOLLADATemplate*                           m_pRootTemplate;
    00210     CSLCOLLADAEffectLibrary*                    m_pEffectLibrary;
    00211
    00212     CSIBCArray<CSLCOLLADALibrary*>              m_Librairies;
    00213     CSIBCArray<TemplateMap>                     m_pReparentMap;
    00214     bool                                        m_bExportExtra;
    00215     CSIBCArray<CCOLLADATemplate*>               m_pInstanciatedNodes;
    00216     CSIBCArray<SIDMap>                          m_pSIDMap;
    00217     CSIBCStringTable                            m_pStringTable;
    00218
    00219 };
    00220
    00221 #endif