You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

156 line
5.0 KiB

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