AMFImporter_Node.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2016, 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. {
  52. /***********************************************/
  53. /******************** Types ********************/
  54. /***********************************************/
  55. public:
  56. /// \enum EType
  57. /// Define what data type contain node element.
  58. enum EType
  59. {
  60. ENET_Color, ///< Color element: <color>.
  61. ENET_Constellation,///< Grouping element: <constellation>.
  62. ENET_Coordinates, ///< Coordinates element: <coordinates>.
  63. ENET_Edge, ///< Edge element: <edge>.
  64. ENET_Instance, ///< Grouping element: <constellation>.
  65. ENET_Material, ///< Material element: <material>.
  66. ENET_Metadata, ///< Metadata element: <metadata>.
  67. ENET_Mesh, ///< Metadata element: <mesh>.
  68. ENET_Object, ///< Element which hold object: <object>.
  69. ENET_Root, ///< Root element: <amf>.
  70. ENET_Triangle, ///< Triangle element: <triangle>.
  71. ENET_TexMap, ///< Texture coordinates element: <texmap> or <map>.
  72. ENET_Texture, ///< Texture element: <texture>.
  73. ENET_Vertex, ///< Vertex element: <vertex>.
  74. ENET_Vertices, ///< Vertex element: <vertices>.
  75. ENET_Volume, ///< Volume element: <volume>.
  76. ENET_Invalid ///< Element has invalid type and possible contain invalid data.
  77. };
  78. /***********************************************/
  79. /****************** Constants ******************/
  80. /***********************************************/
  81. public:
  82. const EType Type;///< Type of element.
  83. /***********************************************/
  84. /****************** Variables ******************/
  85. /***********************************************/
  86. public:
  87. std::string ID;///< ID of element.
  88. CAMFImporter_NodeElement* Parent;///< Parrent element. If nullptr then this node is root.
  89. std::list<CAMFImporter_NodeElement*> Child;///< Child elements.
  90. /***********************************************/
  91. /****************** Functions ******************/
  92. /***********************************************/
  93. private:
  94. /// \fn CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement)
  95. /// Disabled copy constructor.
  96. CAMFImporter_NodeElement(const CAMFImporter_NodeElement& pNodeElement);
  97. /// \fn CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement)
  98. /// Disabled assign operator.
  99. CAMFImporter_NodeElement& operator=(const CAMFImporter_NodeElement& pNodeElement);
  100. /// \fn CAMFImporter_NodeElement()
  101. /// Disabled default constructor.
  102. CAMFImporter_NodeElement();
  103. protected:
  104. /// \fn CAMFImporter_NodeElement(const EType pType, CAMFImporter_NodeElement* pParent)
  105. /// In constructor inheritor must set element type.
  106. /// \param [in] pType - element type.
  107. /// \param [in] pParent - parent element.
  108. CAMFImporter_NodeElement(const EType pType, CAMFImporter_NodeElement* pParent)
  109. : Type(pType), Parent(pParent)
  110. {}
  111. };// class IAMFImporter_NodeElement
  112. /// \struct CAMFImporter_NodeElement_Constellation
  113. /// A collection of objects or constellations with specific relative locations.
  114. struct CAMFImporter_NodeElement_Constellation : public CAMFImporter_NodeElement
  115. {
  116. /// \fn CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent)
  117. /// Constructor.
  118. /// \param [in] pParent - pointer to parent node.
  119. CAMFImporter_NodeElement_Constellation(CAMFImporter_NodeElement* pParent)
  120. : CAMFImporter_NodeElement(ENET_Constellation, pParent)
  121. {}
  122. };// struct CAMFImporter_NodeElement_Constellation
  123. /// \struct CAMFImporter_NodeElement_Instance
  124. /// Part of constellation.
  125. struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement
  126. {
  127. /****************** Variables ******************/
  128. std::string ObjectID;///< ID of object for instanciation.
  129. /// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to
  130. /// create an instance of the object in the current constellation.
  131. aiVector3D Delta;
  132. /// \var Rotation - The rotation, in degrees, to rotate the referenced object about its x, y, and z axes, respectively, to create an
  133. /// instance of the object in the current constellation. Rotations shall be executed in order of x first, then y, then z.
  134. aiVector3D Rotation;
  135. /****************** Functions ******************/
  136. /// \fn CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent)
  137. /// Constructor.
  138. /// \param [in] pParent - pointer to parent node.
  139. CAMFImporter_NodeElement_Instance(CAMFImporter_NodeElement* pParent)
  140. : CAMFImporter_NodeElement(ENET_Instance, pParent)
  141. {}
  142. };// struct CAMFImporter_NodeElement_Instance
  143. /// \struct CAMFImporter_NodeElement_Metadata
  144. /// Structure that define metadata node.
  145. struct CAMFImporter_NodeElement_Metadata : public CAMFImporter_NodeElement
  146. {
  147. /****************** Variables ******************/
  148. std::string Type;///< Type of "Value".
  149. std::string Value;///< Value.
  150. /****************** Functions ******************/
  151. /// \fn CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent)
  152. /// Constructor.
  153. /// \param [in] pParent - pointer to parent node.
  154. CAMFImporter_NodeElement_Metadata(CAMFImporter_NodeElement* pParent)
  155. : CAMFImporter_NodeElement(ENET_Metadata, pParent)
  156. {}
  157. };// struct CAMFImporter_NodeElement_Metadata
  158. /// \struct CAMFImporter_NodeElement_Root
  159. /// Structure that define root node.
  160. struct CAMFImporter_NodeElement_Root : public CAMFImporter_NodeElement
  161. {
  162. /****************** Variables ******************/
  163. std::string Unit;///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
  164. std::string Version;///< Version of format.
  165. /****************** Functions ******************/
  166. /// \fn CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent)
  167. /// Constructor.
  168. /// \param [in] pParent - pointer to parent node.
  169. CAMFImporter_NodeElement_Root(CAMFImporter_NodeElement* pParent)
  170. : CAMFImporter_NodeElement(ENET_Root, pParent)
  171. {}
  172. };// struct CAMFImporter_NodeElement_Root
  173. /// \struct CAMFImporter_NodeElement_Color
  174. /// Structure that define object node.
  175. struct CAMFImporter_NodeElement_Color : public CAMFImporter_NodeElement
  176. {
  177. /****************** Variables ******************/
  178. bool Composed;///< Type of color stored: if true then look for formula in \ref Color_Composed[4], else - in \ref Color.
  179. std::string Color_Composed[4];///< By components formulas of composed color. [0..3] => RGBA.
  180. aiColor4D Color;///< Constant color.
  181. std::string Profile;///< The ICC color space used to interpret the three color channels <r>, <g> and <b>..
  182. /****************** Functions ******************/
  183. /// \fn CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
  184. /// Constructor.
  185. /// \param [in] pParent - pointer to parent node.
  186. CAMFImporter_NodeElement_Color(CAMFImporter_NodeElement* pParent)
  187. : CAMFImporter_NodeElement(ENET_Color, pParent)
  188. {}
  189. };// struct CAMFImporter_NodeElement_Color
  190. /// \struct CAMFImporter_NodeElement_Material
  191. /// Structure that define material node.
  192. struct CAMFImporter_NodeElement_Material : public CAMFImporter_NodeElement
  193. {
  194. /// \fn CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
  195. /// Constructor.
  196. /// \param [in] pParent - pointer to parent node.
  197. CAMFImporter_NodeElement_Material(CAMFImporter_NodeElement* pParent)
  198. : CAMFImporter_NodeElement(ENET_Material, pParent)
  199. {}
  200. };// struct CAMFImporter_NodeElement_Material
  201. /// \struct CAMFImporter_NodeElement_Object
  202. /// Structure that define object node.
  203. struct CAMFImporter_NodeElement_Object : public CAMFImporter_NodeElement
  204. {
  205. /// \fn CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent)
  206. /// Constructor.
  207. /// \param [in] pParent - pointer to parent node.
  208. CAMFImporter_NodeElement_Object(CAMFImporter_NodeElement* pParent)
  209. : CAMFImporter_NodeElement(ENET_Object, pParent)
  210. {}
  211. };// struct CAMFImporter_NodeElement_Object
  212. /// \struct CAMFImporter_NodeElement_Mesh
  213. /// Structure that define mesh node.
  214. struct CAMFImporter_NodeElement_Mesh : public CAMFImporter_NodeElement
  215. {
  216. /// \fn CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent)
  217. /// Constructor.
  218. /// \param [in] pParent - pointer to parent node.
  219. CAMFImporter_NodeElement_Mesh(CAMFImporter_NodeElement* pParent)
  220. : CAMFImporter_NodeElement(ENET_Mesh, pParent)
  221. {}
  222. };// struct CAMFImporter_NodeElement_Mesh
  223. /// \struct CAMFImporter_NodeElement_Vertex
  224. /// Structure that define vertex node.
  225. struct CAMFImporter_NodeElement_Vertex : public CAMFImporter_NodeElement
  226. {
  227. /// \fn CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent)
  228. /// Constructor.
  229. /// \param [in] pParent - pointer to parent node.
  230. CAMFImporter_NodeElement_Vertex(CAMFImporter_NodeElement* pParent)
  231. : CAMFImporter_NodeElement(ENET_Vertex, pParent)
  232. {}
  233. };// struct CAMFImporter_NodeElement_Vertex
  234. /// \struct CAMFImporter_NodeElement_Edge
  235. /// Structure that define edge node.
  236. struct CAMFImporter_NodeElement_Edge : public CAMFImporter_NodeElement
  237. {
  238. /// \fn CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent)
  239. /// Constructor.
  240. /// \param [in] pParent - pointer to parent node.
  241. CAMFImporter_NodeElement_Edge(CAMFImporter_NodeElement* pParent)
  242. : CAMFImporter_NodeElement(ENET_Edge, pParent)
  243. {}
  244. };// struct CAMFImporter_NodeElement_Vertex
  245. /// \struct CAMFImporter_NodeElement_Vertices
  246. /// Structure that define vertices node.
  247. struct CAMFImporter_NodeElement_Vertices : public CAMFImporter_NodeElement
  248. {
  249. /// \fn CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent)
  250. /// Constructor.
  251. /// \param [in] pParent - pointer to parent node.
  252. CAMFImporter_NodeElement_Vertices(CAMFImporter_NodeElement* pParent)
  253. : CAMFImporter_NodeElement(ENET_Vertices, pParent)
  254. {}
  255. };// struct CAMFImporter_NodeElement_Vertices
  256. /// \struct CAMFImporter_NodeElement_Volume
  257. /// Structure that define volume node.
  258. struct CAMFImporter_NodeElement_Volume : public CAMFImporter_NodeElement
  259. {
  260. /****************** Variables ******************/
  261. std::string MaterialID;///< Which material to use.
  262. std::string Type;///< What this volume describes can be “region” or “support”. If none specified, “object” is assumed.
  263. /****************** Functions ******************/
  264. /// \fn CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent)
  265. /// Constructor.
  266. /// \param [in] pParent - pointer to parent node.
  267. CAMFImporter_NodeElement_Volume(CAMFImporter_NodeElement* pParent)
  268. : CAMFImporter_NodeElement(ENET_Volume, pParent)
  269. {}
  270. };// struct CAMFImporter_NodeElement_Volume
  271. /// \struct CAMFImporter_NodeElement_Coordinates
  272. /// Structure that define coordinates node.
  273. struct CAMFImporter_NodeElement_Coordinates : public CAMFImporter_NodeElement
  274. {
  275. /****************** Variables ******************/
  276. aiVector3D Coordinate;///< Coordinate.
  277. /****************** Functions ******************/
  278. /// \fn CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent)
  279. /// Constructor.
  280. /// \param [in] pParent - pointer to parent node.
  281. CAMFImporter_NodeElement_Coordinates(CAMFImporter_NodeElement* pParent)
  282. : CAMFImporter_NodeElement(ENET_Coordinates, pParent)
  283. {}
  284. };// struct CAMFImporter_NodeElement_Coordinates
  285. /// \struct CAMFImporter_NodeElement_TexMap
  286. /// Structure that define texture coordinates node.
  287. struct CAMFImporter_NodeElement_TexMap : public CAMFImporter_NodeElement
  288. {
  289. /****************** Variables ******************/
  290. aiVector3D TextureCoordinate[3];///< Texture coordinates.
  291. std::string TextureID_R;///< Texture ID for red color component.
  292. std::string TextureID_G;///< Texture ID for green color component.
  293. std::string TextureID_B;///< Texture ID for blue color component.
  294. std::string TextureID_A;///< Texture ID for alpha color component.
  295. /****************** Functions ******************/
  296. /// \fn CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
  297. /// Constructor.
  298. /// \param [in] pParent - pointer to parent node.
  299. CAMFImporter_NodeElement_TexMap(CAMFImporter_NodeElement* pParent)
  300. : CAMFImporter_NodeElement(ENET_TexMap, pParent)
  301. {}
  302. };// struct CAMFImporter_NodeElement_TexMap
  303. /// \struct CAMFImporter_NodeElement_Triangle
  304. /// Structure that define triangle node.
  305. struct CAMFImporter_NodeElement_Triangle : public CAMFImporter_NodeElement
  306. {
  307. /****************** Variables ******************/
  308. size_t V[3];///< Triangle vertices.
  309. /****************** Functions ******************/
  310. /// \fn CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
  311. /// Constructor.
  312. /// \param [in] pParent - pointer to parent node.
  313. CAMFImporter_NodeElement_Triangle(CAMFImporter_NodeElement* pParent)
  314. : CAMFImporter_NodeElement(ENET_Triangle, pParent)
  315. {}
  316. };// struct CAMFImporter_NodeElement_Triangle
  317. /// \struct CAMFImporter_NodeElement_Texture
  318. /// Structure that define texture node.
  319. struct CAMFImporter_NodeElement_Texture : public CAMFImporter_NodeElement
  320. {
  321. /****************** Variables ******************/
  322. size_t Width, Height, Depth;///< Size of the texture.
  323. std::vector<uint8_t> Data;///< Data of the texture.
  324. bool Tiled;
  325. /****************** Functions ******************/
  326. /// \fn CAMFImporter_NodeElement_Texture(CAMFImporter_NodeElement* pParent)
  327. /// Constructor.
  328. /// \param [in] pParent - pointer to parent node.
  329. CAMFImporter_NodeElement_Texture(CAMFImporter_NodeElement* pParent)
  330. : CAMFImporter_NodeElement(ENET_Texture, pParent)
  331. {}
  332. };// struct CAMFImporter_NodeElement_Texture
  333. #endif // INCLUDED_AI_AMF_IMPORTER_NODE_H