AMFImporter_Node.hpp 14 KB

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