summaryrefslogtreecommitdiff
path: root/src/mesh/assimp-master/code/AssetLib/AMF/AMFImporter_Node.hpp
blob: c827533a607a592893f88faffa5bf66df8650386 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------

Copyright (c) 2006-2022, assimp team

All rights reserved.

Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:

* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.

* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/

/// \file AMFImporter_Node.hpp
/// \brief Elements of scene graph.
/// \date 2016
/// \author smal.root@gmail.com

#pragma once
#ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H
#define INCLUDED_AI_AMF_IMPORTER_NODE_H

// Header files, Assimp.
#include <assimp/scene.h>
#include <assimp/types.h>

#include <list>
#include <string>
#include <vector>

/// \class CAMFImporter_NodeElement
/// Base class for elements of nodes.
class AMFNodeElementBase {
public:
	/// Define what data type contain node element.
	enum EType {
		ENET_Color, ///< Color element: <color>.
		ENET_Constellation, ///< Grouping element: <constellation>.
		ENET_Coordinates, ///< Coordinates element: <coordinates>.
		ENET_Edge, ///< Edge element: <edge>.
		ENET_Instance, ///< Grouping element: <constellation>.
		ENET_Material, ///< Material element: <material>.
		ENET_Metadata, ///< Metadata element: <metadata>.
		ENET_Mesh, ///< Metadata element: <mesh>.
		ENET_Object, ///< Element which hold object: <object>.
		ENET_Root, ///< Root element: <amf>.
		ENET_Triangle, ///< Triangle element: <triangle>.
		ENET_TexMap, ///< Texture coordinates element: <texmap> or <map>.
		ENET_Texture, ///< Texture element: <texture>.
		ENET_Vertex, ///< Vertex element: <vertex>.
		ENET_Vertices, ///< Vertex element: <vertices>.
		ENET_Volume, ///< Volume element: <volume>.

		ENET_Invalid ///< Element has invalid type and possible contain invalid data.
	};

	const EType Type; ///< Type of element.
	std::string ID; ///< ID of element.
	AMFNodeElementBase *Parent; ///< Parent element. If nullptr then this node is root.
	std::list<AMFNodeElementBase *> Child; ///< Child elements.

public: /// Destructor, virtual..
	virtual ~AMFNodeElementBase() {
		// empty
	}

	/// Disabled copy constructor and co.
	AMFNodeElementBase(const AMFNodeElementBase &pNodeElement) = delete;
	AMFNodeElementBase(AMFNodeElementBase &&) = delete;
	AMFNodeElementBase &operator=(const AMFNodeElementBase &pNodeElement) = delete;
	AMFNodeElementBase() = delete;

protected:
	/// In constructor inheritor must set element type.
	/// \param [in] pType - element type.
	/// \param [in] pParent - parent element.
	AMFNodeElementBase(const EType pType, AMFNodeElementBase *pParent) :
			Type(pType), ID(), Parent(pParent), Child() {
		// empty
	}
}; // class IAMFImporter_NodeElement

/// \struct CAMFImporter_NodeElement_Constellation
/// A collection of objects or constellations with specific relative locations.
struct AMFConstellation : public AMFNodeElementBase {
	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFConstellation(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Constellation, pParent) {}

}; // struct CAMFImporter_NodeElement_Constellation

/// \struct CAMFImporter_NodeElement_Instance
/// Part of constellation.
struct AMFInstance : public AMFNodeElementBase {

	std::string ObjectID; ///< ID of object for instantiation.
	/// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to
	/// create an instance of the object in the current constellation.
	aiVector3D Delta;

	/// \var Rotation - The rotation, in degrees, to rotate the referenced object about its x, y, and z axes, respectively, to create an
	/// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z.
	aiVector3D Rotation;

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFInstance(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Instance, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Metadata
/// Structure that define metadata node.
struct AMFMetadata : public AMFNodeElementBase {

	std::string Type; ///< Type of "Value".
	std::string Value; ///< Value.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFMetadata(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Metadata, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Root
/// Structure that define root node.
struct AMFRoot : public AMFNodeElementBase {

	std::string Unit; ///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
	std::string Version; ///< Version of format.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFRoot(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Root, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Color
/// Structure that define object node.
struct AMFColor : public AMFNodeElementBase {
	bool Composed; ///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
	std::string Color_Composed[4]; ///< By components formulas of composed color. [0..3] - RGBA.
	aiColor4D Color; ///< Constant color.
	std::string Profile; ///< The ICC color space used to interpret the three color channels r, g and b..

	/// @brief  Constructor.
	/// @param [in] pParent - pointer to parent node.
	AMFColor(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color(), Profile() {
		// empty
	}
};

/// \struct CAMFImporter_NodeElement_Material
/// Structure that define material node.
struct AMFMaterial : public AMFNodeElementBase {

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFMaterial(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Material, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Object
/// Structure that define object node.
struct AMFObject : public AMFNodeElementBase {

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFObject(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Object, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Mesh
/// Structure that define mesh node.
struct AMFMesh : public AMFNodeElementBase {
	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFMesh(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Mesh, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Vertex
/// Structure that define vertex node.
struct AMFVertex : public AMFNodeElementBase {
	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFVertex(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Vertex, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Edge
/// Structure that define edge node.
struct AMFEdge : public AMFNodeElementBase {
	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFEdge(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Edge, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Vertices
/// Structure that define vertices node.
struct AMFVertices : public AMFNodeElementBase {
	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFVertices(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Vertices, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Volume
/// Structure that define volume node.
struct AMFVolume : public AMFNodeElementBase {
	std::string MaterialID; ///< Which material to use.
	std::string Type; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFVolume(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Volume, pParent) {}
};

/// \struct CAMFImporter_NodeElement_Coordinates
/// Structure that define coordinates node.
struct AMFCoordinates : public AMFNodeElementBase {
	aiVector3D Coordinate; ///< Coordinate.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFCoordinates(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Coordinates, pParent) {}
};

/// \struct CAMFImporter_NodeElement_TexMap
/// Structure that define texture coordinates node.
struct AMFTexMap : public AMFNodeElementBase {
	aiVector3D TextureCoordinate[3]; ///< Texture coordinates.
	std::string TextureID_R; ///< Texture ID for red color component.
	std::string TextureID_G; ///< Texture ID for green color component.
	std::string TextureID_B; ///< Texture ID for blue color component.
	std::string TextureID_A; ///< Texture ID for alpha color component.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFTexMap(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{}, TextureID_R(), TextureID_G(), TextureID_B(), TextureID_A() {
		// empty
	}
};

/// \struct CAMFImporter_NodeElement_Triangle
/// Structure that define triangle node.
struct AMFTriangle : public AMFNodeElementBase {
	size_t V[3]; ///< Triangle vertices.

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFTriangle(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Triangle, pParent) {
		// empty
	}
};

/// Structure that define texture node.
struct AMFTexture : public AMFNodeElementBase {
	size_t Width, Height, Depth; ///< Size of the texture.
	std::vector<uint8_t> Data; ///< Data of the texture.
	bool Tiled;

	/// Constructor.
	/// \param [in] pParent - pointer to parent node.
	AMFTexture(AMFNodeElementBase *pParent) :
			AMFNodeElementBase(ENET_Texture, pParent), Width(0), Height(0), Depth(0), Data(), Tiled(false) {
		// empty
	}
};

#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H