HMPLoader.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2020, 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. /** @file HMPLoader.h
  34. * @brief Declaration of the HMP importer class
  35. */
  36. #ifndef AI_HMPLOADER_H_INCLUDED
  37. #define AI_HMPLOADER_H_INCLUDED
  38. // internal headers
  39. #include <assimp/BaseImporter.h>
  40. #include "AssetLib/MDL/MDLLoader.h"
  41. #include "AssetLib/HMP/HMPFileData.h"
  42. namespace Assimp {
  43. using namespace HMP;
  44. // ---------------------------------------------------------------------------
  45. /** Used to load 3D GameStudio HMP files (terrains)
  46. */
  47. class HMPImporter : public MDLImporter
  48. {
  49. public:
  50. HMPImporter();
  51. ~HMPImporter();
  52. public:
  53. // -------------------------------------------------------------------
  54. /** Returns whether the class can handle the format of the given file.
  55. * See BaseImporter::CanRead() for details.
  56. */
  57. bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
  58. bool checkSig) const;
  59. protected:
  60. // -------------------------------------------------------------------
  61. /** Return importer meta information.
  62. * See #BaseImporter::GetInfo for the details
  63. */
  64. const aiImporterDesc* GetInfo () const;
  65. // -------------------------------------------------------------------
  66. /** Imports the given file into the given scene structure.
  67. * See BaseImporter::InternReadFile() for details
  68. */
  69. void InternReadFile( const std::string& pFile, aiScene* pScene,
  70. IOSystem* pIOHandler);
  71. protected:
  72. // -------------------------------------------------------------------
  73. /** Import a HMP4 file
  74. */
  75. void InternReadFile_HMP4( );
  76. // -------------------------------------------------------------------
  77. /** Import a HMP5 file
  78. */
  79. void InternReadFile_HMP5( );
  80. // -------------------------------------------------------------------
  81. /** Import a HMP7 file
  82. */
  83. void InternReadFile_HMP7( );
  84. // -------------------------------------------------------------------
  85. /** Validate a HMP 5,4,7 file header
  86. */
  87. void ValidateHeader_HMP457( );
  88. // -------------------------------------------------------------------
  89. /** Try to load one material from the file, if this fails create
  90. * a default material
  91. */
  92. void CreateMaterial(const unsigned char* szCurrent,
  93. const unsigned char** szCurrentOut);
  94. // -------------------------------------------------------------------
  95. /** Build a list of output faces and vertices. The function
  96. * triangulates the height map read from the file
  97. * \param width Width of the height field
  98. * \param width Height of the height field
  99. */
  100. void CreateOutputFaceList(unsigned int width,unsigned int height);
  101. // -------------------------------------------------------------------
  102. /** Generate planar texture coordinates for a terrain
  103. * \param width Width of the terrain, in vertices
  104. * \param height Height of the terrain, in vertices
  105. */
  106. void GenerateTextureCoords(const unsigned int width,
  107. const unsigned int height);
  108. // -------------------------------------------------------------------
  109. /** Read the first skin from the file and skip all others ...
  110. * \param iNumSkins Number of skins in the file
  111. * \param szCursor Position of the first skin (offset 84)
  112. */
  113. void ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szCursor,
  114. const unsigned char** szCursorOut);
  115. private:
  116. };
  117. } // end of namespace Assimp
  118. #endif // AI_HMPIMPORTER_H_INC