assimp/code/AssetLib/AMF/AMFImporter_Node.hpp

307 lines
11 KiB
C++
Raw Normal View History

/*
2016-10-03 17:24:14 +00:00
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, 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
/// \brief Elements of scene graph.
/// \date 2016
/// \author smal.root@gmail.com
2016-10-03 17:24:14 +00:00
#pragma once
#ifndef INCLUDED_AI_AMF_IMPORTER_NODE_H
#define INCLUDED_AI_AMF_IMPORTER_NODE_H
// Header files, stdlib.
#include <list>
#include <string>
2016-09-29 20:19:47 +00:00
#include <vector>
// Header files, Assimp.
#include "assimp/scene.h"
2020-02-26 21:19:42 +00:00
#include "assimp/types.h"
/// \class CAMFImporter_NodeElement
/// Base class for elements of nodes.
2020-02-26 21:19:42 +00:00
class AMFNodeElementBase {
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.
};
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.
2020-02-26 21:19:42 +00:00
public: /// Destructor, virtual..
virtual ~AMFNodeElementBase() {
// empty
}
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;
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) :
Type(pType), ID(), Parent(pParent), Child() {
// empty
}
}; // class IAMFImporter_NodeElement
/// \struct CAMFImporter_NodeElement_Constellation
/// A collection of objects or constellations with specific relative locations.
2020-02-26 21:19:42 +00:00
struct AMFConstellation : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFConstellation(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Constellation, pParent) {}
2020-02-26 21:19:42 +00:00
}; // struct CAMFImporter_NodeElement_Constellation
/// \struct CAMFImporter_NodeElement_Instance
/// Part of constellation.
2020-02-26 21:19:42 +00:00
struct AMFInstance : public AMFNodeElementBase {
2020-02-26 21:19:42 +00:00
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.
2020-02-26 21:19:42 +00:00
AMFInstance(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Instance, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Metadata
/// Structure that define metadata node.
2020-02-26 21:19:42 +00:00
struct AMFMetadata : public AMFNodeElementBase {
2020-02-26 21:19:42 +00:00
std::string Type; ///< Type of "Value".
std::string Value; ///< Value.
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFMetadata(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Metadata, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Root
/// Structure that define root node.
2020-02-26 21:19:42 +00:00
struct AMFRoot : public AMFNodeElementBase {
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.
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFRoot(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Root, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Color
/// 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) :
AMFNodeElementBase(ENET_Color, pParent), Composed(false), Color(), Profile() {
// empty
}
2018-09-21 14:07:09 +00:00
};
/// \struct CAMFImporter_NodeElement_Material
/// Structure that define material node.
2020-02-26 21:19:42 +00:00
struct AMFMaterial : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFMaterial(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Material, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Object
/// Structure that define object node.
2020-02-26 21:19:42 +00:00
struct AMFObject : public AMFNodeElementBase {
2020-02-26 21:19:42 +00:00
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFObject(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Object, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Mesh
/// Structure that define mesh node.
2020-02-26 21:19:42 +00:00
struct AMFMesh : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFMesh(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Mesh, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Vertex
/// Structure that define vertex node.
2020-02-26 21:19:42 +00:00
struct AMFVertex : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFVertex(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Vertex, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Edge
/// Structure that define edge node.
2020-02-26 21:19:42 +00:00
struct AMFEdge : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFEdge(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Edge, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Vertices
/// Structure that define vertices node.
2020-02-26 21:19:42 +00:00
struct AMFVertices : public AMFNodeElementBase {
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFVertices(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Vertices, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Volume
/// Structure that define volume node.
2020-02-26 21:19:42 +00:00
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.
2020-02-26 21:19:42 +00:00
AMFVolume(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Volume, pParent) {}
};
/// \struct CAMFImporter_NodeElement_Coordinates
/// Structure that define coordinates node.
2020-02-26 21:19:42 +00:00
struct AMFCoordinates : public AMFNodeElementBase {
aiVector3D Coordinate; ///< Coordinate.
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFCoordinates(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Coordinates, pParent) {}
};
/// \struct CAMFImporter_NodeElement_TexMap
/// 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.
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFTexMap(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_TexMap, pParent), TextureCoordinate{}, TextureID_R(), TextureID_G(), TextureID_B(), TextureID_A() {
// empty
}
2018-09-21 14:07:09 +00:00
};
/// \struct CAMFImporter_NodeElement_Triangle
/// Structure that define triangle node.
2020-02-26 21:19:42 +00:00
struct AMFTriangle : public AMFNodeElementBase {
size_t V[3]; ///< Triangle vertices.
/// Constructor.
/// \param [in] pParent - pointer to parent node.
2020-02-26 21:19:42 +00:00
AMFTriangle(AMFNodeElementBase *pParent) :
AMFNodeElementBase(ENET_Triangle, pParent) {
// empty
}
};
/// 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.
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
}
};
#endif // INCLUDED_AI_AMF_IMPORTER_NODE_H