Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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