2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** @file IRRShared.h
|
2023-07-02 18:17:52 +00:00
|
|
|
* @brief Shared utilities for the IRR and IRRMESH loaders
|
|
|
|
*/
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
#ifndef INCLUDED_AI_IRRSHARED_H
|
|
|
|
#define INCLUDED_AI_IRRSHARED_H
|
|
|
|
|
2018-01-06 00:18:33 +00:00
|
|
|
#include <assimp/BaseImporter.h>
|
2020-06-27 13:57:06 +00:00
|
|
|
#include <assimp/XmlParser.h>
|
2021-09-13 20:38:20 +00:00
|
|
|
#include <cstdint>
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
struct aiMaterial;
|
|
|
|
|
2020-06-27 13:57:06 +00:00
|
|
|
namespace Assimp {
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
/** @brief Matrix to convert from Assimp to IRR and backwards
|
|
|
|
*/
|
|
|
|
extern const aiMatrix4x4 AI_TO_IRR_MATRIX;
|
|
|
|
|
|
|
|
// Default: 0 = solid, one texture
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_solid_2layer 0x10000
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Transparency flags
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_trans_vertex_alpha 0x1
|
|
|
|
#define AI_IRRMESH_MAT_trans_add 0x2
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Lightmapping flags
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_lightmap 0x2
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_m2 (AI_IRRMESH_MAT_lightmap | 0x4)
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_m4 (AI_IRRMESH_MAT_lightmap | 0x8)
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_light (AI_IRRMESH_MAT_lightmap | 0x10)
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_light_m2 (AI_IRRMESH_MAT_lightmap | 0x20)
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_light_m4 (AI_IRRMESH_MAT_lightmap | 0x40)
|
|
|
|
#define AI_IRRMESH_MAT_lightmap_add (AI_IRRMESH_MAT_lightmap | 0x80)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Standard NormalMap (or Parallax map, they're treated equally)
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_normalmap_solid (0x100)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Normal map combined with vertex alpha
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_normalmap_tva \
|
2015-05-19 03:57:13 +00:00
|
|
|
(AI_IRRMESH_MAT_normalmap_solid | AI_IRRMESH_MAT_trans_vertex_alpha)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Normal map combined with additive transparency
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_MAT_normalmap_ta \
|
2015-05-19 03:57:13 +00:00
|
|
|
(AI_IRRMESH_MAT_normalmap_solid | AI_IRRMESH_MAT_trans_add)
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// Special flag. It indicates a second texture has been found
|
|
|
|
// Its type depends ... either a normal textue or a normal map
|
2020-06-27 13:57:06 +00:00
|
|
|
#define AI_IRRMESH_EXTRA_2ND_TEXTURE 0x100000
|
2015-05-19 03:48:29 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Base class for the Irr and IrrMesh importers.
|
|
|
|
*
|
|
|
|
* Declares some irrlight-related xml parsing utilities and provides tools
|
2015-05-19 03:52:10 +00:00
|
|
|
* to load materials from IRR and IRRMESH files.
|
2015-05-19 03:48:29 +00:00
|
|
|
*/
|
2020-06-27 13:57:06 +00:00
|
|
|
class IrrlichtBase {
|
2015-05-19 03:48:29 +00:00
|
|
|
protected:
|
2023-06-26 19:15:30 +00:00
|
|
|
IrrlichtBase() {
|
2020-06-27 13:57:06 +00:00
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2023-01-16 20:47:11 +00:00
|
|
|
~IrrlichtBase() = default;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
/** @brief Data structure for a simple name-value property
|
|
|
|
*/
|
|
|
|
template <class T>
|
2020-06-27 13:57:06 +00:00
|
|
|
struct Property {
|
2015-05-19 03:57:13 +00:00
|
|
|
std::string name;
|
|
|
|
T value;
|
|
|
|
};
|
|
|
|
|
2020-06-27 13:57:06 +00:00
|
|
|
typedef Property<uint32_t> HexProperty;
|
|
|
|
typedef Property<std::string> StringProperty;
|
|
|
|
typedef Property<bool> BoolProperty;
|
|
|
|
typedef Property<float> FloatProperty;
|
|
|
|
typedef Property<aiVector3D> VectorProperty;
|
|
|
|
typedef Property<int> IntProperty;
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2020-01-23 20:16:10 +00:00
|
|
|
/// XML reader instance
|
2020-06-27 13:57:06 +00:00
|
|
|
XmlParser mParser;
|
2015-05-19 03:48:29 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Parse a material description from the XML
|
|
|
|
* @return The created material
|
|
|
|
* @param matFlags Receives AI_IRRMESH_MAT_XX flags
|
|
|
|
*/
|
2023-06-26 19:15:30 +00:00
|
|
|
aiMaterial *ParseMaterial(pugi::xml_node &materialNode, unsigned int &matFlags);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Read a property of the specified type from the current XML element.
|
2018-05-13 14:35:03 +00:00
|
|
|
* @param out Receives output data
|
2023-06-30 23:57:09 +00:00
|
|
|
* @param node XML attribute element containing data
|
2015-05-19 03:57:13 +00:00
|
|
|
*/
|
2023-06-26 19:15:30 +00:00
|
|
|
void ReadHexProperty(HexProperty &out, pugi::xml_node& hexnode);
|
|
|
|
void ReadStringProperty(StringProperty &out, pugi::xml_node& stringnode);
|
|
|
|
void ReadBoolProperty(BoolProperty &out, pugi::xml_node& boolnode);
|
|
|
|
void ReadFloatProperty(FloatProperty &out, pugi::xml_node& floatnode);
|
|
|
|
void ReadVectorProperty(VectorProperty &out, pugi::xml_node& vectornode);
|
|
|
|
void ReadIntProperty(IntProperty &out, pugi::xml_node& intnode);
|
2015-05-19 03:48:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Unpack a hex color, e.g. 0xdcdedfff
|
2020-06-27 13:57:06 +00:00
|
|
|
inline void ColorFromARGBPacked(uint32_t in, aiColor4D &clr) {
|
2015-05-19 03:57:13 +00:00
|
|
|
clr.a = ((in >> 24) & 0xff) / 255.f;
|
|
|
|
clr.r = ((in >> 16) & 0xff) / 255.f;
|
2020-06-27 13:57:06 +00:00
|
|
|
clr.g = ((in >> 8) & 0xff) / 255.f;
|
|
|
|
clr.b = ((in)&0xff) / 255.f;
|
2015-05-19 03:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace Assimp
|
|
|
|
|
|
|
|
#endif // !! INCLUDED_AI_IRRSHARED_H
|