From 733fd48f9e4f04703e6d0eb51b470b6ebb29c80d Mon Sep 17 00:00:00 2001 From: kimmi Date: Wed, 29 Sep 2010 19:42:50 +0000 Subject: [PATCH] - UPDATE : Add documentation to Q3BSP-importer. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@822 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/Q3BSPFileData.h | 3 +- code/Q3BSPFileImporter.cpp | 38 +++++++++++++++++++++-- code/Q3BSPFileImporter.h | 10 +++--- samples/SimpleOpenGL/SimpleOpenGL.vcproj | 15 +++++---- samples/SimpleOpenGL/SimpleOpenGL_VC8.sln | 4 +-- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/code/Q3BSPFileData.h b/code/Q3BSPFileData.h index b6c9ef48e..aff4d133f 100644 --- a/code/Q3BSPFileData.h +++ b/code/Q3BSPFileData.h @@ -48,8 +48,9 @@ namespace Q3BSP { static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ). -static const int VERION_Q3LEVEL = 46; ///< Supported version. +static const int VERION_Q3LEVEL = 46; ///< Supported version. +/// Geometric type enumeration enum Q3BSPGeoType { Polygon = 1, diff --git a/code/Q3BSPFileImporter.cpp b/code/Q3BSPFileImporter.cpp index da5077d6a..7b626c987 100644 --- a/code/Q3BSPFileImporter.cpp +++ b/code/Q3BSPFileImporter.cpp @@ -92,6 +92,34 @@ static void extractIds( const std::string &rKey, int &rId1, int &rId2 ) rId2 = atoi( tmp2.c_str() ); } +// ------------------------------------------------------------------------------------------------ +static void normalizePathName( const std::string &rPath, std::string &rNormalizedPath ) +{ + rNormalizedPath = ""; + if ( rPath.empty() ) + return; + +#ifdef _WIN32 + std::string sep = "\\"; +#else + std::string sep = "/"; +#endif + + static const unsigned int numDelimiters = 2; + const char delimiters[ numDelimiters ] = { '/', '\\' }; + rNormalizedPath = rPath; + for ( unsigned int i=0; i& extensions ) } // ------------------------------------------------------------------------------------------------ +// Import method. void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* pScene, IOSystem* pIOHandler) { Q3BSPZipArchive Archive( rFile ); @@ -375,7 +404,7 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ]; size_t idx = 0; - for ( size_t i = 0; i < pQ3BSPFace->iNumOfFaceVerts; i++ ) + for ( size_t i = 0; i < (size_t) pQ3BSPFace->iNumOfFaceVerts; i++ ) { const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ]; ai_assert( index < pModel->m_Vertices.size() ); @@ -429,7 +458,9 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen { const std::string matName = (*it).first; if ( matName.empty() ) + { continue; + } aiString aiMatName; aiMatName.Set( matName ); @@ -445,8 +476,9 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ]; if ( NULL != pTexture ) { - std::string texName( pTexture->strName ); - texName += ".jpg"; + std::string tmp( pTexture->strName ), texName( "" ); + tmp += ".jpg"; + normalizePathName( tmp, texName ); aiString textureName( texName.c_str() ); pMatHelper->AddProperty( &textureName, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) ); } diff --git a/code/Q3BSPFileImporter.h b/code/Q3BSPFileImporter.h index a68a8366f..d5adcc8e1 100644 --- a/code/Q3BSPFileImporter.h +++ b/code/Q3BSPFileImporter.h @@ -55,20 +55,22 @@ struct sQ3BSPFace; } +/** Loader to import BSP-levels from a PK3 archive or from a unpacked BSP-level. + */ class Q3BSPFileImporter : BaseImporter { friend class Importer; protected: - /// \brief Default constructor. + /// @brief Default constructor. Q3BSPFileImporter(); - /// \brief Destructor. + /// @brief Destructor. ~Q3BSPFileImporter(); public: - /// \brief Returns whether the class can handle the format of the given file. - /// \remark See BaseImporter::CanRead() for details. + /// @brief Returns whether the class can handle the format of the given file. + /// @remark See BaseImporter::CanRead() for details. bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const; private: diff --git a/samples/SimpleOpenGL/SimpleOpenGL.vcproj b/samples/SimpleOpenGL/SimpleOpenGL.vcproj index 14ddd0c5d..6ee257a8d 100644 --- a/samples/SimpleOpenGL/SimpleOpenGL.vcproj +++ b/samples/SimpleOpenGL/SimpleOpenGL.vcproj @@ -1,11 +1,12 @@ - -