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