/src/assimp/code/AssetLib/AMF/AMFImporter_Node.hpp
Line | Count | Source |
1 | | /* |
2 | | --------------------------------------------------------------------------- |
3 | | Open Asset Import Library (assimp) |
4 | | --------------------------------------------------------------------------- |
5 | | |
6 | | Copyright (c) 2006-2026, assimp team |
7 | | |
8 | | All rights reserved. |
9 | | |
10 | | Redistribution and use of this software in source and binary forms, |
11 | | with or without modification, are permitted provided that the following |
12 | | conditions are met: |
13 | | |
14 | | * Redistributions of source code must retain the above |
15 | | copyright notice, this list of conditions and the |
16 | | following disclaimer. |
17 | | |
18 | | * Redistributions in binary form must reproduce the above |
19 | | copyright notice, this list of conditions and the |
20 | | following disclaimer in the documentation and/or other |
21 | | materials provided with the distribution. |
22 | | |
23 | | * Neither the name of the assimp team, nor the names of its |
24 | | contributors may be used to endorse or promote products |
25 | | derived from this software without specific prior |
26 | | written permission of the assimp team. |
27 | | |
28 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
29 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
31 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
32 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
33 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
34 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
35 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
36 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
37 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
38 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
39 | | --------------------------------------------------------------------------- |
40 | | */ |
41 | | |
42 | | /// \file AMFImporter_Node.hpp |
43 | | /// \brief Elements of scene graph. |
44 | | /// \date 2016 |
45 | | /// \author smal.root@gmail.com |
46 | | |
47 | | #pragma once |
48 | | #ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H |
49 | | #define INCLUDED_AI_AMF_IMPORTER_NODE_H |
50 | | |
51 | | // Header files, Assimp. |
52 | | #include <assimp/scene.h> |
53 | | #include <assimp/types.h> |
54 | | |
55 | | #include <list> |
56 | | #include <string> |
57 | | #include <vector> |
58 | | |
59 | | /// Base class for elements of nodes. |
60 | | class AMFNodeElementBase { |
61 | | public: |
62 | | /// Define what data type contain node element. |
63 | | enum EType { |
64 | | ENET_Color, ///< Color element: <color>. |
65 | | ENET_Constellation, ///< Grouping element: <constellation>. |
66 | | ENET_Coordinates, ///< Coordinates element: <coordinates>. |
67 | | ENET_Edge, ///< Edge element: <edge>. |
68 | | ENET_Instance, ///< Grouping element: <constellation>. |
69 | | ENET_Material, ///< Material element: <material>. |
70 | | ENET_Metadata, ///< Metadata element: <metadata>. |
71 | | ENET_Mesh, ///< Metadata element: <mesh>. |
72 | | ENET_Object, ///< Element which hold object: <object>. |
73 | | ENET_Root, ///< Root element: <amf>. |
74 | | ENET_Triangle, ///< Triangle element: <triangle>. |
75 | | ENET_TexMap, ///< Texture coordinates element: <texmap> or <map>. |
76 | | ENET_Texture, ///< Texture element: <texture>. |
77 | | ENET_Vertex, ///< Vertex element: <vertex>. |
78 | | ENET_Vertices, ///< Vertex element: <vertices>. |
79 | | ENET_Volume, ///< Volume element: <volume>. |
80 | | |
81 | | ENET_Invalid ///< Element has invalid type and possible contain invalid data. |
82 | | }; |
83 | | |
84 | | const EType Type; ///< Type of element. |
85 | | std::string ID; ///< ID of element. |
86 | | AMFNodeElementBase *Parent; ///< Parent element. If nullptr then this node is root. |
87 | | std::list<AMFNodeElementBase *> Child; ///< Child elements. |
88 | | |
89 | | public: |
90 | | /// Destructor, virtual.. |
91 | 1.61M | virtual ~AMFNodeElementBase() = default; |
92 | | |
93 | | /// Disabled copy constructor and co. |
94 | | AMFNodeElementBase(const AMFNodeElementBase &pNodeElement) = delete; |
95 | | AMFNodeElementBase(AMFNodeElementBase &&) = delete; |
96 | | AMFNodeElementBase &operator=(const AMFNodeElementBase &pNodeElement) = delete; |
97 | | AMFNodeElementBase() = delete; |
98 | | |
99 | | protected: |
100 | | /// In constructor inheritor must set element type. |
101 | | /// \param [in] type - element type. |
102 | | /// \param [in] pParent - parent element. |
103 | | AMFNodeElementBase(EType type, AMFNodeElementBase *pParent) : |
104 | 1.61M | Type(type), Parent(pParent) { |
105 | | // empty |
106 | 1.61M | } |
107 | | }; // class IAMFImporter_NodeElement |
108 | | |
109 | | /// A collection of objects or constellations with specific relative locations. |
110 | | struct AMFConstellation final : public AMFNodeElementBase { |
111 | | /// Constructor. |
112 | | /// \param [in] pParent - pointer to parent node. |
113 | | explicit AMFConstellation(AMFNodeElementBase *pParent) : |
114 | 5.27k | AMFNodeElementBase(ENET_Constellation, pParent) {} |
115 | | |
116 | | }; // struct CAMFImporter_NodeElement_Constellation |
117 | | |
118 | | /// Part of constellation. |
119 | | struct AMFInstance final : public AMFNodeElementBase { |
120 | | |
121 | | std::string ObjectID; ///< ID of object for instantiation. |
122 | | /// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to |
123 | | /// create an instance of the object in the current constellation. |
124 | | aiVector3D Delta; |
125 | | |
126 | | /// \var Rotation - The rotation, in degrees, to rotate the referenced object about its x, y, and z axes, respectively, to create an |
127 | | /// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z. |
128 | | aiVector3D Rotation; |
129 | | |
130 | | /// Constructor. |
131 | | /// \param [in] pParent - pointer to parent node. |
132 | | explicit AMFInstance(AMFNodeElementBase *pParent) : |
133 | 30.8k | AMFNodeElementBase(ENET_Instance, pParent) {} |
134 | | }; |
135 | | |
136 | | /// Structure that define metadata node. |
137 | | struct AMFMetadata : public AMFNodeElementBase { |
138 | | |
139 | | std::string MetaType; ///< Type of "Value". |
140 | | std::string Value; ///< Value. |
141 | | |
142 | | /// Constructor. |
143 | | /// \param [in] pParent - pointer to parent node. |
144 | | explicit AMFMetadata(AMFNodeElementBase *pParent) : |
145 | 252k | AMFNodeElementBase(ENET_Metadata, pParent) { |
146 | | // empty |
147 | 252k | } |
148 | | }; |
149 | | |
150 | | /// Structure that define root node. |
151 | | struct AMFRoot : public AMFNodeElementBase { |
152 | | |
153 | | std::string Unit; ///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron". |
154 | | std::string Version; ///< Version of format. |
155 | | |
156 | | /// Constructor. |
157 | | /// \param [in] pParent - pointer to parent node. |
158 | | explicit AMFRoot(AMFNodeElementBase *pParent) : |
159 | 2.88k | AMFNodeElementBase(ENET_Root, pParent) { |
160 | | // empty |
161 | 2.88k | } |
162 | | }; |
163 | | |
164 | | /// Structure that define object node. |
165 | | struct AMFColor : public AMFNodeElementBase { |
166 | | bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color. |
167 | | std::string Color_Composed[4]; ///< By components formulas of composed color. [0..3] - RGBA. |
168 | | aiColor4D Color; ///< Constant color. |
169 | | std::string Profile; ///< The ICC color space used to interpret the three color channels r, g and b.. |
170 | | |
171 | | /// @brief Constructor. |
172 | | /// @param [in] pParent - pointer to parent node. |
173 | | explicit AMFColor(AMFNodeElementBase *pParent) : |
174 | 62.3k | AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color() { |
175 | | // empty |
176 | 62.3k | } |
177 | | }; |
178 | | |
179 | | /// Structure that define material node. |
180 | | struct AMFMaterial : public AMFNodeElementBase { |
181 | | /// Constructor. |
182 | | /// \param [in] pParent - pointer to parent node. |
183 | | explicit AMFMaterial(AMFNodeElementBase *pParent) : |
184 | 7.64k | AMFNodeElementBase(ENET_Material, pParent) { |
185 | | // empty |
186 | 7.64k | } |
187 | | }; |
188 | | |
189 | | /// Structure that define object node. |
190 | | struct AMFObject : public AMFNodeElementBase { |
191 | | /// Constructor. |
192 | | /// \param [in] pParent - pointer to parent node. |
193 | | explicit AMFObject(AMFNodeElementBase *pParent) : |
194 | 193k | AMFNodeElementBase(ENET_Object, pParent) { |
195 | | // empty |
196 | 193k | } |
197 | | }; |
198 | | |
199 | | /// Structure that define mesh node. |
200 | | struct AMFMesh : public AMFNodeElementBase { |
201 | | /// Constructor. |
202 | | /// \param [in] pParent - pointer to parent node. |
203 | | explicit AMFMesh(AMFNodeElementBase *pParent) : |
204 | 39.0k | AMFNodeElementBase(ENET_Mesh, pParent) { |
205 | | // empty |
206 | 39.0k | } |
207 | | }; |
208 | | |
209 | | /// Structure that define vertex node. |
210 | | struct AMFVertex : public AMFNodeElementBase { |
211 | | /// Constructor. |
212 | | /// \param [in] pParent - pointer to parent node. |
213 | | explicit AMFVertex(AMFNodeElementBase *pParent) : |
214 | 143k | AMFNodeElementBase(ENET_Vertex, pParent) { |
215 | | // empty |
216 | 143k | } |
217 | | }; |
218 | | |
219 | | /// Structure that define edge node. |
220 | | struct AMFEdge : public AMFNodeElementBase { |
221 | | /// Constructor. |
222 | | /// \param [in] pParent - pointer to parent node. |
223 | | explicit AMFEdge(AMFNodeElementBase *pParent) : |
224 | 0 | AMFNodeElementBase(ENET_Edge, pParent) { |
225 | 0 | // empty |
226 | 0 | } |
227 | | }; |
228 | | |
229 | | /// Structure that define vertices node. |
230 | | struct AMFVertices : public AMFNodeElementBase { |
231 | | /// Constructor. |
232 | | /// \param [in] pParent - pointer to parent node. |
233 | | explicit AMFVertices(AMFNodeElementBase *pParent) : |
234 | 35.7k | AMFNodeElementBase(ENET_Vertices, pParent) { |
235 | | // empty |
236 | 35.7k | } |
237 | | }; |
238 | | |
239 | | /// Structure that define volume node. |
240 | | struct AMFVolume : public AMFNodeElementBase { |
241 | | std::string MaterialID; ///< Which material to use. |
242 | | std::string VolumeType; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed. |
243 | | |
244 | | /// Constructor. |
245 | | /// \param [in] pParent - pointer to parent node. |
246 | | explicit AMFVolume(AMFNodeElementBase *pParent) : |
247 | 36.3k | AMFNodeElementBase(ENET_Volume, pParent) { |
248 | | // empty |
249 | 36.3k | } |
250 | | }; |
251 | | |
252 | | /// Structure that define coordinates node. |
253 | | struct AMFCoordinates : public AMFNodeElementBase { |
254 | | aiVector3D Coordinate; ///< Coordinate. |
255 | | |
256 | | /// Constructor. |
257 | | /// \param [in] pParent - pointer to parent node. |
258 | | explicit AMFCoordinates(AMFNodeElementBase *pParent) : |
259 | 141k | AMFNodeElementBase(ENET_Coordinates, pParent) { |
260 | | // empty |
261 | 141k | } |
262 | | }; |
263 | | |
264 | | /// Structure that define texture coordinates node. |
265 | | struct AMFTexMap : public AMFNodeElementBase { |
266 | | aiVector3D TextureCoordinate[3]; ///< Texture coordinates. |
267 | | std::string TextureID_R; ///< Texture ID for red color component. |
268 | | std::string TextureID_G; ///< Texture ID for green color component. |
269 | | std::string TextureID_B; ///< Texture ID for blue color component. |
270 | | std::string TextureID_A; ///< Texture ID for alpha color component. |
271 | | |
272 | | /// Constructor. |
273 | | /// \param [in] pParent - pointer to parent node. |
274 | | explicit AMFTexMap(AMFNodeElementBase *pParent) : |
275 | 74 | AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{} { |
276 | | // empty |
277 | 74 | } |
278 | | }; |
279 | | |
280 | | /// Structure that define triangle node. |
281 | | struct AMFTriangle : public AMFNodeElementBase { |
282 | | size_t V[3] = { 0, 0, 0 }; ///< Triangle vertices. |
283 | | |
284 | | /// Constructor. |
285 | | /// \param [in] pParent - pointer to parent node. |
286 | | explicit AMFTriangle(AMFNodeElementBase *pParent) : |
287 | 662k | AMFNodeElementBase(ENET_Triangle, pParent) { |
288 | | // empty |
289 | 662k | } |
290 | | }; |
291 | | |
292 | | /// Structure that define texture node. |
293 | | struct AMFTexture : public AMFNodeElementBase { |
294 | | size_t Width, Height, Depth; ///< Size of the texture. |
295 | | std::vector<uint8_t> Data; ///< Data of the texture. |
296 | | bool Tiled; |
297 | | |
298 | | /// Constructor. |
299 | | /// \param [in] pParent - pointer to parent node. |
300 | | explicit AMFTexture(AMFNodeElementBase *pParent) : |
301 | 54 | AMFNodeElementBase(ENET_Texture, pParent), Width(0), Height(0), Depth(0), Data(), Tiled(false) { |
302 | | // empty |
303 | 54 | } |
304 | | }; |
305 | | |
306 | | #endif // INCLUDED_AI_AMF_IMPORTER_NODE_H |