add missing constructor.

pull/3012/head
kimkulling 2020-03-19 16:20:55 +01:00
parent 9ba014739a
commit de06c860ea
1 changed files with 157 additions and 153 deletions

View File

@ -8,17 +8,16 @@
#define INCLUDED_AI_X3D_EXPORTER_H #define INCLUDED_AI_X3D_EXPORTER_H
// Header files, Assimp. // Header files, Assimp.
#include <assimp/DefaultLogger.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/material.h> #include <assimp/material.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/Exporter.hpp>
// Header files, stdlib. // Header files, stdlib.
#include <list> #include <list>
#include <string> #include <string>
namespace Assimp namespace Assimp {
{
/// \class X3DExporter /// \class X3DExporter
/// Class which export aiScene to X3D file. /// Class which export aiScene to X3D file.
@ -45,196 +44,201 @@ namespace Assimp
/// Texturing component: /// Texturing component:
/// "ImageTexture", "TextureCoordinate", "TextureTransform" /// "ImageTexture", "TextureCoordinate", "TextureTransform"
/// ///
class X3DExporter class X3DExporter {
{ /***********************************************/
/***********************************************/ /******************** Types ********************/
/******************** Types ********************/ /***********************************************/
/***********************************************/
struct SAttribute struct SAttribute {
{ const std::string Name;
const std::string Name; const std::string Value;
const std::string Value;
SAttribute() : SAttribute() :
Name(), Name(),
Value() { Value() {
// empty // empty
} }
}; SAttribute(std::string name, std::string value) :
Name(name),
Value(value) {
// empty
}
};
/***********************************************/ /***********************************************/
/****************** Constants ******************/ /****************** Constants ******************/
/***********************************************/ /***********************************************/
const aiScene* const mScene; const aiScene *const mScene;
/***********************************************/ /***********************************************/
/****************** Variables ******************/ /****************** Variables ******************/
/***********************************************/ /***********************************************/
IOStream* mOutFile; IOStream *mOutFile;
std::map<size_t, std::string> mDEF_Map_Mesh; std::map<size_t, std::string> mDEF_Map_Mesh;
std::map<size_t, std::string> mDEF_Map_Material; std::map<size_t, std::string> mDEF_Map_Material;
private: private:
std::string mIndentationString;
std::string mIndentationString; /***********************************************/
/****************** Functions ******************/
/***********************************************/
/***********************************************/ /// \fn void IndentationStringSet(const size_t pNewLevel)
/****************** Functions ******************/ /// Set value of the indentation string.
/***********************************************/ /// \param [in] pNewLevel - new level of the indentation.
void IndentationStringSet(const size_t pNewLevel);
/// \fn void IndentationStringSet(const size_t pNewLevel) /// \fn void XML_Write(const std::string& pData)
/// Set value of the indentation string. /// Write data to XML-file.
/// \param [in] pNewLevel - new level of the indentation. /// \param [in] pData - reference to string which must be written.
void IndentationStringSet(const size_t pNewLevel); void XML_Write(const std::string &pData);
/// \fn void XML_Write(const std::string& pData) /// \fn aiMatrix4x4 Matrix_GlobalToCurrent(const aiNode& pNode) const
/// Write data to XML-file. /// Calculate transformation matrix for transformation from global coordinate system to pointed aiNode.
/// \param [in] pData - reference to string which must be written. /// \param [in] pNode - reference to local node.
void XML_Write(const std::string& pData); /// \return calculated matrix.
aiMatrix4x4 Matrix_GlobalToCurrent(const aiNode &pNode) const;
/// \fn aiMatrix4x4 Matrix_GlobalToCurrent(const aiNode& pNode) const /// \fn void AttrHelper_CommaToPoint(std::string& pStringWithComma)
/// Calculate transformation matrix for transformation from global coordinate system to pointed aiNode. /// Convert commas in string to points. That's needed because "std::to_string" result depends on locale (regional settings).
/// \param [in] pNode - reference to local node. /// \param [in, out] pStringWithComma - reference to string, which must be modified.
/// \return calculated matrix. void AttrHelper_CommaToPoint(std::string &pStringWithComma) {
aiMatrix4x4 Matrix_GlobalToCurrent(const aiNode& pNode) const; for (char &c : pStringWithComma) {
if (c == ',') c = '.';
}
}
/// \fn void AttrHelper_CommaToPoint(std::string& pStringWithComma) /// \fn void AttrHelper_FloatToString(const float pValue, std::string& pTargetString)
/// Convert commas in string to points. That's needed because "std::to_string" result depends on locale (regional settings). /// Converts float to string.
/// \param [in, out] pStringWithComma - reference to string, which must be modified. /// \param [in] pValue - value for converting.
void AttrHelper_CommaToPoint(std::string& pStringWithComma) { for(char& c: pStringWithComma) { if(c == ',') c = '.'; } } /// \param [out] pTargetString - reference to string where result will be placed. Will be cleared before using.
void AttrHelper_FloatToString(const float pValue, std::string &pTargetString);
/// \fn void AttrHelper_FloatToString(const float pValue, std::string& pTargetString) /// \fn void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// Converts float to string. /// Converts array of vectors to string.
/// \param [in] pValue - value for converting. /// \param [in] pArray - pointer to array of vectors.
/// \param [out] pTargetString - reference to string where result will be placed. Will be cleared before using. /// \param [in] pArray_Size - count of elements in array.
void AttrHelper_FloatToString(const float pValue, std::string& pTargetString); /// \param [out] pTargetString - reference to string where result will be placed. Will be cleared before using.
void AttrHelper_Vec3DArrToString(const aiVector3D *pArray, const size_t pArray_Size, std::string &pTargetString);
/// \fn void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \fn void AttrHelper_Vec2DArrToString(const aiVector2D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// Converts array of vectors to string. /// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// \param [in] pArray - pointer to array of vectors. void AttrHelper_Vec2DArrToString(const aiVector2D *pArray, const size_t pArray_Size, std::string &pTargetString);
/// \param [in] pArray_Size - count of elements in array.
/// \param [out] pTargetString - reference to string where result will be placed. Will be cleared before using.
void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString);
/// \fn void AttrHelper_Vec2DArrToString(const aiVector2D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \fn void AttrHelper_Vec3DAsVec2fArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString)
void AttrHelper_Vec2DArrToString(const aiVector2D* pArray, const size_t pArray_Size, std::string& pTargetString); /// Only x, y is used from aiVector3D.
void AttrHelper_Vec3DAsVec2fArrToString(const aiVector3D *pArray, const size_t pArray_Size, std::string &pTargetString);
/// \fn void AttrHelper_Vec3DAsVec2fArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \fn void AttrHelper_Col4DArrToString(const aiColor4D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// Only x, y is used from aiVector3D. /// Converts array of colors to string.
void AttrHelper_Vec3DAsVec2fArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString); void AttrHelper_Col4DArrToString(const aiColor4D *pArray, const size_t pArray_Size, std::string &pTargetString);
/// \fn void AttrHelper_Col4DArrToString(const aiColor4D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \fn void AttrHelper_Col3DArrToString(const aiColor3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// \overload void AttrHelper_Vec3DArrToString(const aiVector3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \overload void AttrHelper_Col4DArrToString(const aiColor4D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// Converts array of colors to string. /// Converts array of colors to string.
void AttrHelper_Col4DArrToString(const aiColor4D* pArray, const size_t pArray_Size, std::string& pTargetString); void AttrHelper_Col3DArrToString(const aiColor3D *pArray, const size_t pArray_Size, std::string &pTargetString);
/// \fn void AttrHelper_Col3DArrToString(const aiColor3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \fn void AttrHelper_FloatToAttrList(std::list<SAttribute> pList, const std::string& pName, const float pValue, const float pDefaultValue)
/// \overload void AttrHelper_Col4DArrToString(const aiColor4D* pArray, const size_t pArray_Size, std::string& pTargetString) /// \overload void AttrHelper_Col3DArrToString(const aiColor3D* pArray, const size_t pArray_Size, std::string& pTargetString)
/// Converts array of colors to string. void AttrHelper_FloatToAttrList(std::list<SAttribute> &pList, const std::string &pName, const float pValue, const float pDefaultValue);
void AttrHelper_Col3DArrToString(const aiColor3D* pArray, const size_t pArray_Size, std::string& pTargetString);
/// \fn void AttrHelper_FloatToAttrList(std::list<SAttribute> pList, const std::string& pName, const float pValue, const float pDefaultValue) /// \fn void AttrHelper_Color3ToAttrList(std::list<SAttribute> pList, const std::string& pName, const aiColor3D& pValue, const aiColor3D& pDefaultValue)
/// \overload void AttrHelper_Col3DArrToString(const aiColor3D* pArray, const size_t pArray_Size, std::string& pTargetString) /// Add attribute to list if value not equal to default.
void AttrHelper_FloatToAttrList(std::list<SAttribute> &pList, const std::string& pName, const float pValue, const float pDefaultValue); /// \param [in] pList - target list of the attributes.
/// \param [in] pName - name of new attribute.
/// \param [in] pValue - value of the new attribute.
/// \param [in] pDefaultValue - default value for checking: if pValue is equal to pDefaultValue then attribute will not be added.
void AttrHelper_Color3ToAttrList(std::list<SAttribute> &pList, const std::string &pName, const aiColor3D &pValue, const aiColor3D &pDefaultValue);
/// \fn void AttrHelper_Color3ToAttrList(std::list<SAttribute> pList, const std::string& pName, const aiColor3D& pValue, const aiColor3D& pDefaultValue) /// \fn void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute>& pAttrList)
/// Add attribute to list if value not equal to default. /// Begin new XML-node element.
/// \param [in] pList - target list of the attributes. /// \param [in] pNodeName - name of the element.
/// \param [in] pName - name of new attribute. /// \param [in] pTabLevel - indentation level.
/// \param [in] pValue - value of the new attribute. /// \param [in] pEmtyElement - if true then empty element will be created.
/// \param [in] pDefaultValue - default value for checking: if pValue is equal to pDefaultValue then attribute will not be added. /// \param [in] pAttrList - list of the attributes for element.
void AttrHelper_Color3ToAttrList(std::list<SAttribute> &pList, const std::string& pName, const aiColor3D& pValue, const aiColor3D& pDefaultValue); void NodeHelper_OpenNode(const std::string &pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute> &pAttrList);
/// \fn void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute>& pAttrList) /// \fn void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement = false)
/// Begin new XML-node element. /// \overload void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute>& pAttrList)
/// \param [in] pNodeName - name of the element. void NodeHelper_OpenNode(const std::string &pNodeName, const size_t pTabLevel, const bool pEmptyElement = false);
/// \param [in] pTabLevel - indentation level.
/// \param [in] pEmtyElement - if true then empty element will be created.
/// \param [in] pAttrList - list of the attributes for element.
void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute>& pAttrList);
/// \fn void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement = false) /// \fn void NodeHelper_CloseNode(const std::string& pNodeName, const size_t pTabLevel)
/// \overload void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const std::list<SAttribute>& pAttrList) /// End XML-node element.
void NodeHelper_OpenNode(const std::string& pNodeName, const size_t pTabLevel, const bool pEmptyElement = false); /// \param [in] pNodeName - name of the element.
/// \param [in] pTabLevel - indentation level.
void NodeHelper_CloseNode(const std::string &pNodeName, const size_t pTabLevel);
/// \fn void NodeHelper_CloseNode(const std::string& pNodeName, const size_t pTabLevel) /// \fn void Export_Node(const aiNode* pNode, const size_t pTabLevel)
/// End XML-node element. /// Export data from scene to XML-file: aiNode.
/// \param [in] pNodeName - name of the element. /// \param [in] pNode - source aiNode.
/// \param [in] pTabLevel - indentation level. /// \param [in] pTabLevel - indentation level.
void NodeHelper_CloseNode(const std::string& pNodeName, const size_t pTabLevel); void Export_Node(const aiNode *pNode, const size_t pTabLevel);
/// \fn void Export_Node(const aiNode* pNode, const size_t pTabLevel) /// \fn void Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel)
/// Export data from scene to XML-file: aiNode. /// Export data from scene to XML-file: aiMesh.
/// \param [in] pNode - source aiNode. /// \param [in] pMesh - index of the source aiMesh.
/// \param [in] pTabLevel - indentation level. /// \param [in] pTabLevel - indentation level.
void Export_Node(const aiNode* pNode, const size_t pTabLevel); void Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel);
/// \fn void Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) /// \fn void Export_Material(const size_t pIdxMaterial, const size_t pTabLevel)
/// Export data from scene to XML-file: aiMesh. /// Export data from scene to XML-file: aiMaterial.
/// \param [in] pMesh - index of the source aiMesh. /// \param [in] pIdxMaterial - index of the source aiMaterial.
/// \param [in] pTabLevel - indentation level. /// \param [in] pTabLevel - indentation level.
void Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel); void Export_Material(const size_t pIdxMaterial, const size_t pTabLevel);
/// \fn void Export_Material(const size_t pIdxMaterial, const size_t pTabLevel) /// \fn void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
/// Export data from scene to XML-file: aiMaterial. /// Export data from scene to XML-file: aiMetadata.
/// \param [in] pIdxMaterial - index of the source aiMaterial. /// \param [in] pKey - source data: value of the metadata key.
/// \param [in] pTabLevel - indentation level. /// \param [in] pValue - source data: value of the metadata value.
void Export_Material(const size_t pIdxMaterial, const size_t pTabLevel); /// \param [in] pTabLevel - indentation level.
void Export_MetadataBoolean(const aiString &pKey, const bool pValue, const size_t pTabLevel);
/// \fn void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel) /// \fn void Export_MetadataDouble(const aiString& pKey, const double pValue, const size_t pTabLevel)
/// Export data from scene to XML-file: aiMetadata. /// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
/// \param [in] pKey - source data: value of the metadata key. void Export_MetadataDouble(const aiString &pKey, const double pValue, const size_t pTabLevel);
/// \param [in] pValue - source data: value of the metadata value.
/// \param [in] pTabLevel - indentation level.
void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel);
/// \fn void Export_MetadataDouble(const aiString& pKey, const double pValue, const size_t pTabLevel) /// \fn void Export_MetadataFloat(const aiString& pKey, const float pValue, const size_t pTabLevel)
/// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel) /// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
void Export_MetadataDouble(const aiString& pKey, const double pValue, const size_t pTabLevel); void Export_MetadataFloat(const aiString &pKey, const float pValue, const size_t pTabLevel);
/// \fn void Export_MetadataFloat(const aiString& pKey, const float pValue, const size_t pTabLevel) /// \fn void Export_MetadataInteger(const aiString& pKey, const int32_t pValue, const size_t pTabLevel)
/// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel) /// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
void Export_MetadataFloat(const aiString& pKey, const float pValue, const size_t pTabLevel); void Export_MetadataInteger(const aiString &pKey, const int32_t pValue, const size_t pTabLevel);
/// \fn void Export_MetadataInteger(const aiString& pKey, const int32_t pValue, const size_t pTabLevel) /// \fn void Export_MetadataString(const aiString& pKey, const aiString& pValue, const size_t pTabLevel)
/// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel) /// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel)
void Export_MetadataInteger(const aiString& pKey, const int32_t pValue, const size_t pTabLevel); void Export_MetadataString(const aiString &pKey, const aiString &pValue, const size_t pTabLevel);
/// \fn void Export_MetadataString(const aiString& pKey, const aiString& pValue, const size_t pTabLevel) /// \fn bool CheckAndExport_Light(const aiNode& pNode, const size_t pTabLevel)
/// \overload void Export_MetadataBoolean(const aiString& pKey, const bool pValue, const size_t pTabLevel) /// Check if node point to light source. If yes then export light source.
void Export_MetadataString(const aiString& pKey, const aiString& pValue, const size_t pTabLevel); /// \param [in] pNode - reference to node for checking.
/// \param [in] pTabLevel - indentation level.
/// \return true - if node assigned with light and it was exported, else - return false.
bool CheckAndExport_Light(const aiNode &pNode, const size_t pTabLevel);
/// \fn bool CheckAndExport_Light(const aiNode& pNode, const size_t pTabLevel) /***********************************************/
/// Check if node point to light source. If yes then export light source. /************** Functions: LOG set *************/
/// \param [in] pNode - reference to node for checking. /***********************************************/
/// \param [in] pTabLevel - indentation level.
/// \return true - if node assigned with light and it was exported, else - return false.
bool CheckAndExport_Light(const aiNode& pNode, const size_t pTabLevel);
/***********************************************/ /// \fn void LogError(const std::string& pMessage)
/************** Functions: LOG set *************/ /// Short variant for calling \ref DefaultLogger::get()->error()
/***********************************************/ void LogError(const std::string &pMessage) { DefaultLogger::get()->error(pMessage); }
/// \fn void LogError(const std::string& pMessage)
/// Short variant for calling \ref DefaultLogger::get()->error()
void LogError(const std::string& pMessage) { DefaultLogger::get()->error(pMessage); }
public: public:
/// \fn X3DExporter()
/// Default constructor.
X3DExporter(const char *pFileName, IOSystem *pIOSystem, const aiScene *pScene, const ExportProperties *pProperties);
/// \fn X3DExporter() /// \fn ~X3DExporter()
/// Default constructor. /// Default destructor.
X3DExporter(const char* pFileName, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties); ~X3DExporter() {}
/// \fn ~X3DExporter() }; // class X3DExporter
/// Default destructor.
~X3DExporter() {}
};// class X3DExporter } // namespace Assimp
}// namespace Assimp
#endif // INCLUDED_AI_X3D_EXPORTER_H #endif // INCLUDED_AI_X3D_EXPORTER_H