- UPDATE : Add documentation to Q3BSP-importer.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@822 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
72e5b99baa
commit
733fd48f9e
|
@ -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,
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;"..\..\lib\assimp_debug-dll_win32""
|
||||
AdditionalLibraryDirectories="..\glut;"..\..\lib\assimp_debug-dll_win32";..\..\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 "$(ConfigurationName)\$(TargetFileName)" ..\bin
copy ..\..\bin\assimp_debug-dll_Win32\Assimp32d.dll ..\bin
"
|
||||
|
@ -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 "$(ConfigurationName)\$(TargetFileName)" ..\bin
copy ..\..\bin\assimp_release-dll_Win32\Assimp32.dll ..\bin
"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue