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