Warning: That file was not part of the compilation database. It may have many parsing errors.

1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41#ifndef ASSIMP_Q3BSPFILEIMPORTER_H_INC
42#define ASSIMP_Q3BSPFILEIMPORTER_H_INC
43
44#include "BaseImporter.h"
45
46#include <map>
47
48struct aiMesh;
49struct aiNode;
50struct aiFace;
51struct aiMaterial;
52struct aiTexture;
53
54namespace Assimp {
55namespace Q3BSP {
56 class Q3BSPZipArchive;
57 struct Q3BSPModel;
58 struct sQ3BSPFace;
59}
60
61// ------------------------------------------------------------------------------------------------
62/** Loader to import BSP-levels from a PK3 archive or from a unpacked BSP-level.
63 */
64// ------------------------------------------------------------------------------------------------
65class Q3BSPFileImporter : public BaseImporter {
66public:
67 /// @brief Default constructor.
68 Q3BSPFileImporter();
69
70 /// @brief Destructor.
71 ~Q3BSPFileImporter();
72
73public:
74 /// @brief Returns whether the class can handle the format of the given file.
75 /// @remark See BaseImporter::CanRead() for details.
76 bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const;
77
78private:
79 typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*> FaceMap;
80 typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator FaceMapIt;
81 typedef std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator FaceMapConstIt;
82
83 const aiImporterDesc* GetInfo () const;
84 void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler);
85 void separateMapName( const std::string &rImportName, std::string &rArchiveName, std::string &rMapName );
86 bool findFirstMapInArchive( Q3BSP::Q3BSPZipArchive &rArchive, std::string &rMapName );
87 void CreateDataFromImport( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
88 void CreateNodes( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiNode *pParent );
89 aiNode *CreateTopology( const Q3BSP::Q3BSPModel *pModel, unsigned int materialIdx,
90 std::vector<Q3BSP::sQ3BSPFace*> &rArray, aiMesh* pMesh );
91 void createTriangleTopology( const Q3BSP::Q3BSPModel *pModel, Q3BSP::sQ3BSPFace *pQ3BSPFace, aiMesh* pMesh, unsigned int &rFaceIdx,
92 unsigned int &rVertIdx );
93 void createMaterials( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, Q3BSP::Q3BSPZipArchive *pArchive );
94 size_t countData( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
95 size_t countFaces( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
96 size_t countTriangles( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const;
97 void createMaterialMap( const Q3BSP::Q3BSPModel *pModel);
98 aiFace *getNextFace( aiMesh *pMesh, unsigned int &rFaceIdx );
99 bool importTextureFromArchive( const Q3BSP::Q3BSPModel *pModel, Q3BSP::Q3BSPZipArchive *pArchive, aiScene* pScene,
100 aiMaterial *pMatHelper, int textureId );
101 bool importLightmap( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene, aiMaterial *pMatHelper, int lightmapId );
102 bool importEntities( const Q3BSP::Q3BSPModel *pModel, aiScene* pScene );
103 bool expandFile( Q3BSP::Q3BSPZipArchive *pArchive, const std::string &rFilename, const std::vector<std::string> &rExtList,
104 std::string &rFile, std::string &rExt );
105
106private:
107 aiMesh *m_pCurrentMesh;
108 aiFace *m_pCurrentFace;
109 FaceMap m_MaterialLookupMap;
110 std::vector<aiTexture*> mTextures;
111};
112
113// ------------------------------------------------------------------------------------------------
114
115} // Namespace Assimp
116
117
118#endif // ASSIMP_Q3BSPFILEIMPORTER_H_INC
119

Warning: That file was not part of the compilation database. It may have many parsing errors.