- UPDATE : Add documentation to Q3BSP-importer.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@822 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
kimmi 2010-09-29 19:42:50 +00:00
parent 72e5b99baa
commit 733fd48f9e
5 changed files with 52 additions and 18 deletions

View File

@ -50,6 +50,7 @@ namespace Q3BSP
static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ). 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 enum Q3BSPGeoType
{ {
Polygon = 1, Polygon = 1,

View File

@ -92,6 +92,34 @@ static void extractIds( const std::string &rKey, int &rId1, int &rId2 )
rId2 = atoi( tmp2.c_str() ); 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<numDelimiters; i++ )
{
for ( size_t j=0; j<rNormalizedPath.size(); j++ )
{
if ( rNormalizedPath[j] == delimiters[ i ] )
{
rNormalizedPath[ j ] = sep[0];
}
}
}
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor. // Constructor.
Q3BSPFileImporter::Q3BSPFileImporter() : Q3BSPFileImporter::Q3BSPFileImporter() :
@ -142,6 +170,7 @@ void Q3BSPFileImporter::GetExtensionList( std::set<std::string>& extensions )
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Import method.
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* pScene, IOSystem* pIOHandler) void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene* pScene, IOSystem* pIOHandler)
{ {
Q3BSPZipArchive Archive( rFile ); Q3BSPZipArchive Archive( rFile );
@ -375,7 +404,7 @@ void Q3BSPFileImporter::createTriangleTopology( const Q3BSP::Q3BSPModel *pModel,
m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ]; m_pCurrentFace->mIndices = new unsigned int[ m_pCurrentFace->mNumIndices ];
size_t idx = 0; 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 ]; const size_t index = pQ3BSPFace->iVertexIndex + pModel->m_Indices[ pQ3BSPFace->iFaceVertexIndex + i ];
ai_assert( index < pModel->m_Vertices.size() ); 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; const std::string matName = (*it).first;
if ( matName.empty() ) if ( matName.empty() )
{
continue; continue;
}
aiString aiMatName; aiString aiMatName;
aiMatName.Set( matName ); aiMatName.Set( matName );
@ -445,8 +476,9 @@ void Q3BSPFileImporter::createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScen
sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ]; sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
if ( NULL != pTexture ) if ( NULL != pTexture )
{ {
std::string texName( pTexture->strName ); std::string tmp( pTexture->strName ), texName( "" );
texName += ".jpg"; tmp += ".jpg";
normalizePathName( tmp, texName );
aiString textureName( texName.c_str() ); aiString textureName( texName.c_str() );
pMatHelper->AddProperty( &textureName, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) ); pMatHelper->AddProperty( &textureName, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
} }

View File

@ -55,20 +55,22 @@ struct sQ3BSPFace;
} }
/** Loader to import BSP-levels from a PK3 archive or from a unpacked BSP-level.
*/
class Q3BSPFileImporter : BaseImporter class Q3BSPFileImporter : BaseImporter
{ {
friend class Importer; friend class Importer;
protected: protected:
/// \brief Default constructor. /// @brief Default constructor.
Q3BSPFileImporter(); Q3BSPFileImporter();
/// \brief Destructor. /// @brief Destructor.
~Q3BSPFileImporter(); ~Q3BSPFileImporter();
public: public:
/// \brief Returns whether the class can handle the format of the given file. /// @brief Returns whether the class can handle the format of the given file.
/// \remark See BaseImporter::CanRead() for details. /// @remark See BaseImporter::CanRead() for details.
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const; bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const;
private: private:

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="9,00"
Name="SimpleOpenGL" Name="SimpleOpenGL"
ProjectGUID="{A53D047C-2C35-44FB-B7DB-2066FE520950}" ProjectGUID="{A53D047C-2C35-44FB-B7DB-2066FE520950}"
RootNamespace="SimpleOpenGL" RootNamespace="SimpleOpenGL"
Keyword="Win32Proj" Keyword="Win32Proj"
TargetFrameworkVersion="131072"
> >
<Platforms> <Platforms>
<Platform <Platform
@ -64,9 +65,11 @@
AdditionalDependencies="glut32.lib assimp.lib" AdditionalDependencies="glut32.lib assimp.lib"
OutputFile="$(OutDir)\$(ProjectName)_Debug.exe" OutputFile="$(OutDir)\$(ProjectName)_Debug.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\glut;&quot;..\..\lib\assimp_debug-dll_win32&quot;" AdditionalLibraryDirectories="..\glut;&quot;..\..\lib\assimp_debug-dll_win32&quot;;..\..\bin\debug\"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@ -87,9 +90,6 @@
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool
Name="VCWebDeploymentTool"
/>
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(ConfigurationName)\$(TargetFileName)&quot; ..\bin&#x0D;&#x0A;copy ..\..\bin\assimp_debug-dll_Win32\Assimp32d.dll ..\bin&#x0D;&#x0A;" CommandLine="copy &quot;$(ConfigurationName)\$(TargetFileName)&quot; ..\bin&#x0D;&#x0A;copy ..\..\bin\assimp_debug-dll_Win32\Assimp32d.dll ..\bin&#x0D;&#x0A;"
@ -146,6 +146,8 @@
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@ -166,9 +168,6 @@
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool
Name="VCWebDeploymentTool"
/>
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(ConfigurationName)\$(TargetFileName)&quot; ..\bin&#x0D;&#x0A;copy ..\..\bin\assimp_release-dll_Win32\Assimp32.dll ..\bin&#x0D;&#x0A;" CommandLine="copy &quot;$(ConfigurationName)\$(TargetFileName)&quot; ..\bin&#x0D;&#x0A;copy ..\..\bin\assimp_release-dll_Win32\Assimp32.dll ..\bin&#x0D;&#x0A;"

View File

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2005 # Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleOpenGL", "SimpleOpenGL.vcproj", "{A53D047C-2C35-44FB-B7DB-2066FE520950}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleOpenGL", "SimpleOpenGL.vcproj", "{A53D047C-2C35-44FB-B7DB-2066FE520950}"
EndProject EndProject
Global Global