"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSModelLib/Src/Models/LSDSharedModel.h

00001 
00021 #ifndef __LSD_SHAREDMODEL_H__
00022 #define __LSD_SHAREDMODEL_H__
00023 
00024 #include "../LSDModelLib.h"
00025 #include "../ModelTextures/LSDModelTexture.h"
00026 #include "LSDIntermediateMeshInstance.h"
00027 #include "LSDIntermediateSharedMesh.h"
00028 #include "LSDMaterial.h"
00029 #include "Streams/LSSTDStream.h"
00030 
00031 namespace lsd {
00032 
00044         class CSharedModel {
00045         public :
00046                 // == Various constructors.
00047                 LSE_CALLCTOR                                                    CSharedModel();
00048                 virtual LSE_CALLCTOR                                    ~CSharedModel();
00049 
00050 
00051                 // == Types.
00055                 typedef struct LSD_MODEL_IMAGE {
00059                         CString                                                         sPath;
00060 
00064                         CMisc::LSC_BUFFER                                       bData;
00065 
00069                         LSUINT32                                                        ui32Crc1;
00070 
00074                         LSUINT32                                                        ui32Crc2;
00075 
00079                         LSUINT8                                                         ui8Flip;
00080 
00084                         LSUINT8                                                         ui8BnW;
00085 
00086 
00087                         // == Operators.
00094                         LSD_MODEL_IMAGE & LSE_CALL                      operator = ( const LSD_MODEL_IMAGE &_miOther );
00095 
00096 
00097                         // == Functions.
00101                         LSVOID LSE_CALL                                         Trash();
00102                 } * LPLSD_MODEL_IMAGE, * const LPCLSD_MODEL_IMAGE;
00103 
00104 
00105                 // == Operators.
00112                 CSharedModel & LSE_CALL                                 operator = ( const CSharedModel &_smOther );
00113 
00114 
00115                 // == Functions.
00122                 LSSTD_ERRORS LSE_CALL                                   LoadFromFile( const LSCHAR * _pcFile );
00123 
00130                 virtual LSSTD_ERRORS LSE_CALL                   LoadFromStream( const lsstd::IStream &_sStream );
00131 
00135                 virtual LSVOID LSE_CALL                                 Reset();
00136 
00142                 LSE_INLINE LSUINT32 LSE_CALL                    TotalMeshes() const;
00143 
00150                 LSE_INLINE const CIntermediateMeshInstance & LSE_CALL
00151                                                                                                 MeshByIndex( LSUINT32 _ui32Index ) const;
00152 
00159                 LSE_INLINE CIntermediateMeshInstance & LSE_CALL
00160                                                                                                 MeshByIndex( LSUINT32 _ui32Index );
00161 
00168                 const CIntermediateMeshInstance * LSE_CALL
00169                                                                                                 MeshById( LSUINT64 _ui64Id ) const;
00170 
00176                 LSE_INLINE const CAabb & LSE_CALL               Aabb() const;
00177 
00183                 LSE_INLINE const CSphere & LSE_CALL             BoundingSphere() const;
00184 
00185         protected :
00186                 // == Members.
00190                 CVectorPoD<CIntermediateSharedMesh *, LSUINT32>
00191                                                                                                 m_vSharedMeshes;
00192 
00196                 CVector<CIntermediateMeshInstance, LSUINT32>
00197                                                                                                 m_vMeshInstances;
00198 
00202                 CVectorPoD<CMaterial *, LSUINT32>               m_vMaterials;
00203 
00207                 CVector<CModelTexture>                                  m_vTextures;
00208 
00212                 CVector<LSD_MODEL_IMAGE>                                m_vImages;
00213 
00217                 CAabb                                                                   m_aAabb;
00218 
00222                 CSphere                                                                 m_sBoundingSphere;
00223 
00227                 CStdAllocator *                                                 m_psaAllocator;
00228 
00232                 CAllocator                                                              m_aVecAllocator;
00233 
00234 
00235                 // == Functions.
00242                 LSSTD_ERRORS LSE_CALL                                   LoadMaterials( const lsstd::IStream &_sStream );
00243 
00252                 LSSTD_ERRORS LSE_CALL                                   LoadTextures( const lsstd::IStream &_sStream, LSUINT8 &_ui8TexturesLoaded );
00253 
00260                 LSSTD_ERRORS LSE_CALL                                   LoadImages( const lsstd::IStream &_sStream );
00261 
00269                 static LSBOOL LSE_CALL                                  ReadString( const lsstd::IStream &_sStream, CString &_sRet );
00270         };
00271 
00272 
00273         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00274         // DEFINITIONS
00275         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00276         // == Functions.
00282          LSE_INLINE LSUINT32 LSE_CALL CSharedModel::TotalMeshes() const {
00283                  return m_vMeshInstances.Length();
00284          }
00285 
00292         LSE_INLINE const CIntermediateMeshInstance & LSE_CALL CSharedModel::MeshByIndex( LSUINT32 _ui32Index ) const {
00293                 return m_vMeshInstances[_ui32Index];
00294         }
00295 
00302         LSE_INLINE CIntermediateMeshInstance & LSE_CALL CSharedModel::MeshByIndex( LSUINT32 _ui32Index ) {
00303                 return m_vMeshInstances[_ui32Index];
00304         }
00305 
00311         LSE_INLINE const CAabb & LSE_CALL CSharedModel::Aabb() const {
00312                 return m_aAabb;
00313         }
00314 
00320         LSE_INLINE const CSphere & LSE_CALL CSharedModel::BoundingSphere() const {
00321                 return m_sBoundingSphere;
00322         }
00323 
00324 }       // namespace lsd
00325 
00326 #endif  // __LSD_SHAREDMODEL_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator