Skip to content

Commit

Permalink
- UPDATE : Add documentation to Q3BSP-importer.
Browse files Browse the repository at this point in the history
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@822 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
kimmi committed Sep 29, 2010
1 parent 72e5b99 commit 733fd48
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
3 changes: 2 additions & 1 deletion code/Q3BSPFileData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 35 additions & 3 deletions code/Q3BSPFileImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() :
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 ) );
}
Expand Down
10 changes: 6 additions & 4 deletions code/Q3BSPFileImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 7 additions & 8 deletions samples/SimpleOpenGL/SimpleOpenGL.vcproj
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;"
Expand Down Expand Up @@ -146,6 +146,8 @@
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Expand All @@ -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;"
Expand Down
4 changes: 2 additions & 2 deletions samples/SimpleOpenGL/SimpleOpenGL_VC8.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 733fd48

Please sign in to comment.