Debian Codegraph @

code/AssetLib/MD5/MD5Loader.h

raw
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4
5 Copyright (c) 2006-2026, assimp team
6
7 All rights reserved.
8
9 Redistribution and use of this software in source and binary forms,
10 with or without modification, are permitted provided that the
11 following 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
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39 ----------------------------------------------------------------------
40 */
41
42 /** @file MD5Loader.h
43 * @brief Definition of the .MD5 importer class.
44 * http://www.modwiki.net/wiki/MD5_(file_format)
45 */
46 #pragma once
47 #ifndef AI_MD5LOADER_H_INCLUDED
48 #define AI_MD5LOADER_H_INCLUDED
49
50 #include "MD5Parser.h"
51 #include <assimp/BaseImporter.h>
52 #include <assimp/types.h>
53
54 struct aiNode;
55 struct aiNodeAnim;
56
57 namespace Assimp {
58
59 class IOStream;
60 using namespace Assimp::MD5;
61
62 // ---------------------------------------------------------------------------
63 /** Importer class for the MD5 file format
64 */
65 class MD5Importer : public BaseImporter {
66 public:
67 MD5Importer();
68 ~MD5Importer() override = default;
69
70 // -------------------------------------------------------------------
71 /** Returns whether the class can handle the format of the given file.
72 * See BaseImporter::CanRead() for details.
73 */
74 bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
75 bool checkSig) const override;
76
77 protected:
78 // -------------------------------------------------------------------
79 /** Return importer meta information.
80 * See #BaseImporter::GetInfo for the details
81 */
82 const aiImporterDesc *GetInfo() const override;
83
84 // -------------------------------------------------------------------
85 /** Called prior to ReadFile().
86 * The function is a request to the importer to update its configuration
87 * basing on the Importer's configuration property list.
88 */
89 void SetupProperties(const Importer *pImp) override;
90
91 // -------------------------------------------------------------------
92 /** Imports the given file into the given scene structure.
93 * See BaseImporter::InternReadFile() for details
94 */
95 void InternReadFile(const std::string &pFile, aiScene *pScene,
96 IOSystem *pIOHandler) override;
97
98 // -------------------------------------------------------------------
99 /** Load a *.MD5MESH file.
100 */
101 void LoadMD5MeshFile();
102
103 // -------------------------------------------------------------------
104 /** Load a *.MD5ANIM file.
105 */
106 void LoadMD5AnimFile();
107
108 // -------------------------------------------------------------------
109 /** Load a *.MD5CAMERA file.
110 */
111 void LoadMD5CameraFile();
112
113 // -------------------------------------------------------------------
114 /** Construct node hierarchy from a given MD5ANIM
115 * @param iParentID Current parent ID
116 * @param piParent Parent node to attach to
117 * @param bones Input bones
118 * @param node_anims Generated node animations
119 */
120 void AttachChilds_Anim(int iParentID, aiNode *piParent,
121 AnimBoneArray &bones, const aiNodeAnim **node_anims);
122
123 // -------------------------------------------------------------------
124 /** Construct node hierarchy from a given MD5MESH
125 * @param iParentID Current parent ID
126 * @param piParent Parent node to attach to
127 * @param bones Input bones
128 */
129 void AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneArray &bones);
130
131 // -------------------------------------------------------------------
132 /** Build unique vertex buffers from a given MD5ANIM
133 * @param meshSrc Input data
134 */
135 void MakeDataUnique(MD5::MeshDesc &meshSrc);
136
137 // -------------------------------------------------------------------
138 /** Load the contents of a specific file into memory and
139 * allocates a buffer to keep it.
140 *
141 * mBuffer is modified to point to this buffer.
142 * @param pFile File stream to be read
143 */
144 void LoadFileIntoMemory(IOStream *pFile);
145 void UnloadFileFromMemory();
146
147 /** IOSystem to be used to access files */
148 IOSystem *mIOHandler;
149
150 /** Path to the file, excluding the file extension but
151 with the dot */
152 std::string mFile;
153
154 /** Buffer to hold the loaded file */
155 char *mBuffer;
156
157 /** Size of the file */
158 unsigned int mFileSize;
159
160 /** Current line number. For debugging purposes */
161 unsigned int mLineNumber;
162
163 /** Scene to be filled */
164 aiScene *mScene;
165
166 /** true if a MD5MESH file has already been parsed */
167 bool mHadMD5Mesh;
168
169 /** true if a MD5ANIM file has already been parsed */
170 bool mHadMD5Anim;
171
172 /** true if a MD5CAMERA file has already been parsed */
173 bool mHadMD5Camera;
174
175 /** configuration option: prevent anim autoload */
176 bool mCconfigNoAutoLoad;
177 };
178
179 } // end of namespace Assimp
180
181 #endif // AI_3DSIMPORTER_H_INC