2020-03-21 06:34:12 +00:00
|
|
|
/*
|
2016-10-03 17:24:14 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2024-02-23 21:30:05 +00:00
|
|
|
Copyright (c) 2006-2024, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2016-10-03 17:24:14 +00:00
|
|
|
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
|
2016-09-28 14:49:15 +00:00
|
|
|
/// \brief Elements of scene graph.
|
|
|
|
/// \date 2016
|
|
|
|
/// \author smal.root@gmail.com
|
|
|
|
|
2016-10-03 17:24:14 +00:00
|
|
|
#pragma once
|
2016-09-28 14:49:15 +00:00
|
|
|
#ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H
|
|
|
|
#define INCLUDED_AI_AMF_IMPORTER_NODE_H
|
|
|
|
|
2021-09-13 20:38:20 +00:00
|
|
|
// Header files, Assimp.
|
|
|
|
#include <assimp/scene.h>
|
|
|
|
#include <assimp/types.h>
|
|
|
|
|
2016-09-28 14:49:15 +00:00
|
|
|
#include <list>
|
|
|
|
#include <string>
|
2016-09-29 20:19:47 +00:00
|
|
|
#include <vector>
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Base class for elements of nodes.
|
2020-02-26 21:19:42 +00:00
|
|
|
class AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
public:
|
|
|
|
/// Define what data type contain node element.
|
2017-05-10 16:29:42 +00:00
|
|
|
enum EType {
|
2020-02-26 21:19:42 +00:00
|
|
|
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.
|
2016-09-28 14:49:15 +00:00
|
|
|
};
|
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
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.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
public: /// Destructor, virtual..
|
2023-01-16 20:47:11 +00:00
|
|
|
virtual ~AMFNodeElementBase() = default;
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2018-09-21 14:07:09 +00:00
|
|
|
/// Disabled copy constructor and co.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFNodeElementBase(const AMFNodeElementBase &pNodeElement) = delete;
|
|
|
|
AMFNodeElementBase(AMFNodeElementBase &&) = delete;
|
|
|
|
AMFNodeElementBase &operator=(const AMFNodeElementBase &pNodeElement) = delete;
|
|
|
|
AMFNodeElementBase() = delete;
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// In constructor inheritor must set element type.
|
|
|
|
/// \param [in] pType - element type.
|
|
|
|
/// \param [in] pParent - parent element.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFNodeElementBase(const EType pType, AMFNodeElementBase *pParent) :
|
2023-01-16 20:47:11 +00:00
|
|
|
Type(pType), Parent(pParent) {
|
2020-02-26 21:19:42 +00:00
|
|
|
// empty
|
|
|
|
}
|
|
|
|
}; // class IAMFImporter_NodeElement
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// A collection of objects or constellations with specific relative locations.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFConstellation : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFConstellation(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Constellation, pParent) {}
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
}; // struct CAMFImporter_NodeElement_Constellation
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Part of constellation.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFInstance : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
std::string ObjectID; ///< ID of object for instantiation.
|
2016-09-28 14:49:15 +00:00
|
|
|
/// \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.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFInstance(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Instance, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define metadata node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFMetadata : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
std::string Type; ///< Type of "Value".
|
|
|
|
std::string Value; ///< Value.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFMetadata(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Metadata, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define root node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFRoot : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
std::string Unit; ///< The units to be used. May be "inch", "millimeter", "meter", "feet", or "micron".
|
|
|
|
std::string Version; ///< Version of format.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFRoot(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Root, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define object node.
|
2020-02-26 21:19:42 +00:00
|
|
|
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..
|
2018-09-21 14:07:09 +00:00
|
|
|
|
|
|
|
/// @brief Constructor.
|
|
|
|
/// @param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFColor(AMFNodeElementBase *pParent) :
|
2023-01-16 20:47:11 +00:00
|
|
|
AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color() {
|
2020-02-26 21:19:42 +00:00
|
|
|
// empty
|
|
|
|
}
|
2018-09-21 14:07:09 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define material node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFMaterial : public AMFNodeElementBase {
|
|
|
|
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFMaterial(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Material, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define object node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFObject : public AMFNodeElementBase {
|
2018-09-21 16:59:47 +00:00
|
|
|
|
2020-02-26 21:19:42 +00:00
|
|
|
/// Constructor.
|
2016-09-28 14:49:15 +00:00
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFObject(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Object, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// \struct CAMFImporter_NodeElement_Mesh
|
|
|
|
/// Structure that define mesh node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFMesh : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFMesh(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Mesh, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define vertex node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFVertex : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFVertex(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Vertex, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define edge node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFEdge : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFEdge(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Edge, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define vertices node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFVertices : public AMFNodeElementBase {
|
2016-09-28 14:49:15 +00:00
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFVertices(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Vertices, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define volume node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFVolume : public AMFNodeElementBase {
|
|
|
|
std::string MaterialID; ///< Which material to use.
|
2021-02-14 02:28:14 +00:00
|
|
|
std::string Type; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFVolume(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Volume, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define coordinates node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFCoordinates : public AMFNodeElementBase {
|
|
|
|
aiVector3D Coordinate; ///< Coordinate.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFCoordinates(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Coordinates, pParent) {}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define texture coordinates node.
|
2020-02-26 21:19:42 +00:00
|
|
|
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.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFTexMap(AMFNodeElementBase *pParent) :
|
2023-01-16 20:47:11 +00:00
|
|
|
AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{} {
|
2020-02-26 21:19:42 +00:00
|
|
|
// empty
|
|
|
|
}
|
2018-09-21 14:07:09 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define triangle node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFTriangle : public AMFNodeElementBase {
|
|
|
|
size_t V[3]; ///< Triangle vertices.
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFTriangle(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Triangle, pParent) {
|
|
|
|
// empty
|
|
|
|
}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
/// Structure that define texture node.
|
2020-02-26 21:19:42 +00:00
|
|
|
struct AMFTexture : public AMFNodeElementBase {
|
|
|
|
size_t Width, Height, Depth; ///< Size of the texture.
|
|
|
|
std::vector<uint8_t> Data; ///< Data of the texture.
|
2016-09-28 14:49:15 +00:00
|
|
|
bool Tiled;
|
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// \param [in] pParent - pointer to parent node.
|
2020-02-26 21:19:42 +00:00
|
|
|
AMFTexture(AMFNodeElementBase *pParent) :
|
|
|
|
AMFNodeElementBase(ENET_Texture, pParent), Width(0), Height(0), Depth(0), Data(), Tiled(false) {
|
|
|
|
// empty
|
|
|
|
}
|
2018-09-21 16:59:47 +00:00
|
|
|
};
|
2016-09-28 14:49:15 +00:00
|
|
|
|
|
|
|
#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H
|