Browse Source

- UPDATE : Add documentation to Q3BSP-importer.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@822 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
kimmi 15 years ago
parent
commit
733fd48f9e

+ 2 - 1
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,

+ 35 - 3
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<numDelimiters; i++ )
+	{
+		for ( size_t j=0; j<rNormalizedPath.size(); j++ )
+		{
+			if ( rNormalizedPath[j] == delimiters[ i ] )
+			{
+				rNormalizedPath[ j ] = sep[0];
+			}
+		}
+	}
+}
+
 // ------------------------------------------------------------------------------------------------
 //	Constructor.
 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)
 {
 	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 ) );
 			}

+ 6 - 4
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:

+ 7 - 8
samples/SimpleOpenGL/SimpleOpenGL.vcproj

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

+ 2 - 2
samples/SimpleOpenGL/SimpleOpenGL_VC8.sln

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