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