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