Refactoring: Some cleanups
parent
aa3abb3c06
commit
8cf2d6e588
|
@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Discreet 3DS Importer",
|
"Discreet 3DS Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Assimp {
|
||||||
|
|
||||||
using namespace D3MF;
|
using namespace D3MF;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"3mf Importer",
|
"3mf Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -62,7 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"AC3D Importer",
|
"AC3D Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
const aiImporterDesc AMFImporter::Description = {
|
static constexpr aiImporterDesc Description = {
|
||||||
"Additive manufacturing file format(AMF) Importer",
|
"Additive manufacturing file format(AMF) Importer",
|
||||||
"smalcom",
|
"smalcom",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -98,8 +98,12 @@ namespace Assimp {
|
||||||
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
|
/// old - <map> and children <u1>, <u2>, <u3>, <v1>, <v2>, <v3>
|
||||||
///
|
///
|
||||||
class AMFImporter : public BaseImporter {
|
class AMFImporter : public BaseImporter {
|
||||||
private:
|
using AMFMetaDataArray = std::vector<AMFMetadata *>;
|
||||||
struct SPP_Material; // forward declaration
|
using MeshArray = std::vector<aiMesh *>;
|
||||||
|
using NodeArray = std::vector<aiNode *>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct SPP_Material;
|
||||||
|
|
||||||
/// Data type for post-processing step. More suitable container for part of material's composition.
|
/// Data type for post-processing step. More suitable container for part of material's composition.
|
||||||
struct SPP_Composite {
|
struct SPP_Composite {
|
||||||
|
@ -107,22 +111,6 @@ private:
|
||||||
std::string Formula; ///< Formula for calculating ratio of \ref Material.
|
std::string Formula; ///< Formula for calculating ratio of \ref Material.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \struct SPP_Material
|
|
||||||
/// Data type for post-processing step. More suitable container for material.
|
|
||||||
struct SPP_Material {
|
|
||||||
std::string ID; ///< Material ID.
|
|
||||||
std::list<AMFMetadata *> Metadata; ///< Metadata of material.
|
|
||||||
AMFColor *Color; ///< Color of material.
|
|
||||||
std::list<SPP_Composite> Composition; ///< List of child materials if current material is composition of few another.
|
|
||||||
|
|
||||||
/// Return color calculated for specified coordinate.
|
|
||||||
/// \param [in] pX - "x" coordinate.
|
|
||||||
/// \param [in] pY - "y" coordinate.
|
|
||||||
/// \param [in] pZ - "z" coordinate.
|
|
||||||
/// \return calculated color.
|
|
||||||
aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Data type for post-processing step. More suitable container for texture.
|
/// Data type for post-processing step. More suitable container for texture.
|
||||||
struct SPP_Texture {
|
struct SPP_Texture {
|
||||||
std::string ID;
|
std::string ID;
|
||||||
|
@ -139,10 +127,52 @@ private:
|
||||||
const AMFTexMap *TexMap; ///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
|
const AMFTexMap *TexMap; ///< Face texture mapping data. Equal to nullptr if texture mapping is not set for the face.
|
||||||
};
|
};
|
||||||
|
|
||||||
using AMFMetaDataArray = std::vector<AMFMetadata*>;
|
/// Data type for post-processing step. More suitable container for material.
|
||||||
using MeshArray = std::vector<aiMesh*>;
|
struct SPP_Material {
|
||||||
using NodeArray = std::vector<aiNode*>;
|
std::string ID; ///< Material ID.
|
||||||
|
std::list<AMFMetadata *> Metadata; ///< Metadata of material.
|
||||||
|
AMFColor *Color; ///< Color of material.
|
||||||
|
std::list<SPP_Composite> Composition; ///< List of child materials if current material is composition of few another.
|
||||||
|
|
||||||
|
/// Return color calculated for specified coordinate.
|
||||||
|
/// \param [in] pX - "x" coordinate.
|
||||||
|
/// \param [in] pY - "y" coordinate.
|
||||||
|
/// \param [in] pZ - "z" coordinate.
|
||||||
|
/// \return calculated color.
|
||||||
|
aiColor4D GetColor(const float pX, const float pY, const float pZ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Default constructor.
|
||||||
|
AMFImporter() AI_NO_EXCEPT;
|
||||||
|
|
||||||
|
/// Default destructor.
|
||||||
|
~AMFImporter() override;
|
||||||
|
|
||||||
|
/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
|
||||||
|
/// Also exception can be thrown if trouble will found.
|
||||||
|
/// \param [in] pFile - name of file to be parsed.
|
||||||
|
/// \param [in] pIOHandler - pointer to IO helper object.
|
||||||
|
void ParseFile(const std::string &pFile, IOSystem *pIOHandler);
|
||||||
|
void ParseHelper_Node_Enter(AMFNodeElementBase *child);
|
||||||
|
void ParseHelper_Node_Exit();
|
||||||
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const override;
|
||||||
|
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||||
|
const aiImporterDesc *GetInfo() const override;
|
||||||
|
bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
|
||||||
|
bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const;
|
||||||
|
bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const;
|
||||||
|
AI_WONT_RETURN void Throw_CloseNotFound(const std::string &nodeName) AI_WONT_RETURN_SUFFIX;
|
||||||
|
AI_WONT_RETURN void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
|
||||||
|
AI_WONT_RETURN void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
|
||||||
|
AI_WONT_RETURN void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX;
|
||||||
|
AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX;
|
||||||
|
void XML_CheckNode_MustHaveChildren(pugi::xml_node &node);
|
||||||
|
bool XML_SearchNode(const std::string &nodeName);
|
||||||
|
void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString);
|
||||||
|
AMFImporter(const AMFImporter &pScene) = delete;
|
||||||
|
AMFImporter &operator=(const AMFImporter &pScene) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
/// Clear all temporary data.
|
/// Clear all temporary data.
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -262,40 +292,9 @@ private:
|
||||||
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
|
/// \param [in] pUseOldName - if true then use old name of node(and children) - <map>, instead of new name - <texmap>.
|
||||||
void ParseNode_TexMap(XmlNode &node, const bool pUseOldName = false);
|
void ParseNode_TexMap(XmlNode &node, const bool pUseOldName = false);
|
||||||
|
|
||||||
public:
|
|
||||||
/// Default constructor.
|
|
||||||
AMFImporter() AI_NO_EXCEPT;
|
|
||||||
|
|
||||||
/// Default destructor.
|
|
||||||
~AMFImporter() override;
|
|
||||||
|
|
||||||
/// Parse AMF file and fill scene graph. The function has no return value. Result can be found by analyzing the generated graph.
|
|
||||||
/// Also exception can be thrown if trouble will found.
|
|
||||||
/// \param [in] pFile - name of file to be parsed.
|
|
||||||
/// \param [in] pIOHandler - pointer to IO helper object.
|
|
||||||
void ParseFile(const std::string &pFile, IOSystem *pIOHandler);
|
|
||||||
void ParseHelper_Node_Enter(AMFNodeElementBase *child);
|
|
||||||
void ParseHelper_Node_Exit();
|
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool pCheckSig) const override;
|
|
||||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
|
||||||
const aiImporterDesc *GetInfo() const override;
|
|
||||||
bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const;
|
|
||||||
bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const;
|
|
||||||
bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const;
|
|
||||||
AI_WONT_RETURN void Throw_CloseNotFound(const std::string &nodeName) AI_WONT_RETURN_SUFFIX;
|
|
||||||
AI_WONT_RETURN void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
|
|
||||||
AI_WONT_RETURN void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX;
|
|
||||||
AI_WONT_RETURN void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX;
|
|
||||||
AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX;
|
|
||||||
void XML_CheckNode_MustHaveChildren(pugi::xml_node &node);
|
|
||||||
bool XML_SearchNode(const std::string &nodeName);
|
|
||||||
void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString);
|
|
||||||
AMFImporter(const AMFImporter &pScene) = delete;
|
|
||||||
AMFImporter &operator=(const AMFImporter &pScene) = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const aiImporterDesc Description;
|
|
||||||
|
|
||||||
AMFNodeElementBase *mNodeElement_Cur; ///< Current element.
|
AMFNodeElementBase *mNodeElement_Cur; ///< Current element.
|
||||||
std::list<AMFNodeElementBase *> mNodeElement_List; ///< All elements of scene graph.
|
std::list<AMFNodeElementBase *> mNodeElement_List; ///< All elements of scene graph.
|
||||||
XmlParser *mXmlParser;
|
XmlParser *mXmlParser;
|
||||||
|
|
|
@ -66,7 +66,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::ASE;
|
using namespace Assimp::ASE;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"ASE Importer",
|
"ASE Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Assimp Binary Importer",
|
"Assimp Binary Importer",
|
||||||
"Gargaj / Conspiracy",
|
"Gargaj / Conspiracy",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -62,7 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"BlitzBasic 3D Importer",
|
"BlitzBasic 3D Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"BVH Importer (MoCap)",
|
"BVH Importer (MoCap)",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -69,11 +69,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// zlib is needed for compressed blend files
|
// zlib is needed for compressed blend files
|
||||||
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
||||||
#include "Common/Compression.h"
|
#include "Common/Compression.h"
|
||||||
/* #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
|
||||||
# include <zlib.h>
|
|
||||||
# else
|
|
||||||
# include "../contrib/zlib/zlib.h"
|
|
||||||
# endif*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -89,7 +84,7 @@ using namespace Assimp;
|
||||||
using namespace Assimp::Blender;
|
using namespace Assimp::Blender;
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
|
||||||
static const aiImporterDesc blenderDesc = {
|
static constexpr aiImporterDesc blenderDesc = {
|
||||||
"Blender 3D Importer (http://www.blender3d.org)",
|
"Blender 3D Importer (http://www.blender3d.org)",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -65,7 +65,7 @@ using namespace Assimp;
|
||||||
using namespace Assimp::COB;
|
using namespace Assimp::COB;
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
|
||||||
static const float units[] = {
|
static constexpr float units[] = {
|
||||||
1000.f,
|
1000.f,
|
||||||
100.f,
|
100.f,
|
||||||
1.f,
|
1.f,
|
||||||
|
@ -76,7 +76,7 @@ static const float units[] = {
|
||||||
1.f / 1609.344f
|
1.f / 1609.344f
|
||||||
};
|
};
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"TrueSpace Object Importer",
|
"TrueSpace Object Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -89,14 +89,6 @@ static const aiImporterDesc desc = {
|
||||||
"cob scn"
|
"cob scn"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
COBImporter::COBImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
COBImporter::~COBImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool COBImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool COBImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -56,16 +56,16 @@ class LineSplitter;
|
||||||
|
|
||||||
// TinyFormatter.h
|
// TinyFormatter.h
|
||||||
namespace Formatter {
|
namespace Formatter {
|
||||||
template <typename T, typename TR, typename A>
|
template <typename T, typename TR, typename A>
|
||||||
class basic_formatter;
|
class basic_formatter;
|
||||||
typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
|
typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>> format;
|
||||||
} // namespace Formatter
|
} // namespace Formatter
|
||||||
|
|
||||||
// COBScene.h
|
// COBScene.h
|
||||||
namespace COB {
|
namespace COB {
|
||||||
struct ChunkInfo;
|
struct ChunkInfo;
|
||||||
struct Node;
|
struct Node;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
} // namespace COB
|
} // namespace COB
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
|
@ -75,8 +75,8 @@ struct Scene;
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
class COBImporter : public BaseImporter {
|
class COBImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
COBImporter();
|
COBImporter() = default;
|
||||||
~COBImporter() override;
|
~COBImporter() override = default;
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
|
|
|
@ -44,9 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @file CSMLoader.cpp
|
/** @file CSMLoader.cpp
|
||||||
* Implementation of the CSM importer class.
|
* Implementation of the CSM importer class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_CSM_IMPORTER
|
||||||
|
|
||||||
#include "CSMLoader.h"
|
#include "CSMLoader.h"
|
||||||
|
@ -63,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"CharacterStudio Motion Importer (MoCap)",
|
"CharacterStudio Motion Importer (MoCap)",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -79,13 +76,9 @@ static const aiImporterDesc desc = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
CSMImporter::CSMImporter()
|
CSMImporter::CSMImporter() : noSkeletonMesh(){
|
||||||
: noSkeletonMesh()
|
// empty
|
||||||
{}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
CSMImporter::~CSMImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Assimp {
|
||||||
class CSMImporter : public BaseImporter {
|
class CSMImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
CSMImporter();
|
CSMImporter();
|
||||||
~CSMImporter() override;
|
~CSMImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
|
@ -81,9 +81,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
bool noSkeletonMesh;
|
bool noSkeletonMesh;
|
||||||
|
|
||||||
}; // end of class CSMImporter
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // AI_AC3DIMPORTER_H_INC
|
#endif // AI_AC3DIMPORTER_H_INC
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Assimp {
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
using namespace Assimp::Collada;
|
using namespace Assimp::Collada;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Collada Importer",
|
"Collada Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -101,10 +101,6 @@ ColladaLoader::ColladaLoader() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
ColladaLoader::~ColladaLoader() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
ColladaLoader();
|
ColladaLoader();
|
||||||
|
|
||||||
/// The class destructor.
|
/// The class destructor.
|
||||||
~ColladaLoader() override;
|
~ColladaLoader() override = default;
|
||||||
|
|
||||||
/// Returns whether the class can handle the format of the given file.
|
/// Returns whether the class can handle the format of the given file.
|
||||||
/// @see BaseImporter::CanRead() for more details.
|
/// @see BaseImporter::CanRead() for more details.
|
||||||
|
|
|
@ -70,7 +70,7 @@ static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
||||||
|
|
||||||
// color indices for DXF - 16 are supported, the table is
|
// color indices for DXF - 16 are supported, the table is
|
||||||
// taken directly from the DXF spec.
|
// taken directly from the DXF spec.
|
||||||
static aiColor4D g_aclrDxfIndexColors[] = {
|
static const aiColor4D g_aclrDxfIndexColors[] = {
|
||||||
aiColor4D(0.6f, 0.6f, 0.6f, 1.0f),
|
aiColor4D(0.6f, 0.6f, 0.6f, 1.0f),
|
||||||
aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
|
aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
|
||||||
aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
|
aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
|
||||||
|
@ -97,7 +97,7 @@ static const int GroupCode_XComp = 10;
|
||||||
static const int GroupCode_YComp = 20;
|
static const int GroupCode_YComp = 20;
|
||||||
static const int GroupCode_ZComp = 30;
|
static const int GroupCode_ZComp = 30;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Drawing Interchange Format (DXF) Importer",
|
"Drawing Interchange Format (DXF) Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -72,25 +72,20 @@ using namespace Assimp::Formatter;
|
||||||
using namespace Assimp::FBX;
|
using namespace Assimp::FBX;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
static constexpr aiImporterDesc desc = {
|
||||||
static const aiImporterDesc desc = {
|
"Autodesk FBX Importer",
|
||||||
"Autodesk FBX Importer",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
aiImporterFlags_SupportTextFlavour,
|
||||||
aiImporterFlags_SupportTextFlavour,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
"fbx"
|
||||||
"fbx"
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by #Importer
|
|
||||||
FBXImporter::FBXImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool FBXImporter::CanRead(const std::string & pFile, IOSystem * pIOHandler, bool /*checkSig*/) const {
|
bool FBXImporter::CanRead(const std::string & pFile, IOSystem * pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -70,7 +70,7 @@ typedef class basic_formatter<char, std::char_traits<char>, std::allocator<char>
|
||||||
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
|
class FBXImporter : public BaseImporter, public LogFunctions<FBXImporter> {
|
||||||
public:
|
public:
|
||||||
/// @brief The class constructor.
|
/// @brief The class constructor.
|
||||||
FBXImporter();
|
FBXImporter() = default;
|
||||||
|
|
||||||
/// @brief The class destructor, default implementation.
|
/// @brief The class destructor, default implementation.
|
||||||
~FBXImporter() override = default;
|
~FBXImporter() override = default;
|
||||||
|
|
|
@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"3D GameStudio Heightmap (HMP) Importer",
|
"3D GameStudio Heightmap (HMP) Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -103,7 +103,7 @@ void ConvertUnit(const ::Assimp::STEP::EXPRESS::DataType &dt, ConversionData &co
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Industry Foundation Classes (IFC) Importer",
|
"Industry Foundation Classes (IFC) Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// http://sauerbraten.org/iqm/
|
// http://sauerbraten.org/iqm/
|
||||||
// https://github.com/lsalzman/iqm
|
// https://github.com/lsalzman/iqm
|
||||||
|
|
||||||
|
|
||||||
inline void swap_block( uint32_t *block, size_t size ){
|
inline void swap_block( uint32_t *block, size_t size ){
|
||||||
(void)block; // suppress 'unreferenced formal parameter' MSVC warning
|
(void)block; // suppress 'unreferenced formal parameter' MSVC warning
|
||||||
size >>= 2;
|
size >>= 2;
|
||||||
|
@ -67,7 +66,7 @@ inline void swap_block( uint32_t *block, size_t size ){
|
||||||
AI_SWAP4( block[ i ] );
|
AI_SWAP4( block[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Inter-Quake Model Importer",
|
"Inter-Quake Model Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -66,7 +66,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Irrlicht Scene Reader",
|
"Irrlicht Scene Reader",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Irrlicht Mesh Reader",
|
"Irrlicht Mesh Reader",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -51,64 +51,56 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "LWOLoader.h"
|
#include "LWOLoader.h"
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::LoadLWOBFile()
|
void LWOImporter::LoadLWOBFile() {
|
||||||
{
|
|
||||||
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
|
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running)
|
while (running) {
|
||||||
{
|
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)
|
||||||
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
|
break;
|
||||||
const IFF::ChunkHeader head = IFF::LoadChunk(mFileBuffer);
|
const IFF::ChunkHeader head = IFF::LoadChunk(mFileBuffer);
|
||||||
|
|
||||||
if (mFileBuffer + head.length > end)
|
if (mFileBuffer + head.length > end) {
|
||||||
{
|
|
||||||
throw DeadlyImportError("LWOB: Invalid chunk length");
|
throw DeadlyImportError("LWOB: Invalid chunk length");
|
||||||
}
|
}
|
||||||
uint8_t* const next = mFileBuffer+head.length;
|
uint8_t* const next = mFileBuffer+head.length;
|
||||||
switch (head.type)
|
switch (head.type) {
|
||||||
{
|
|
||||||
// vertex list
|
// vertex list
|
||||||
case AI_LWO_PNTS:
|
case AI_LWO_PNTS: {
|
||||||
{
|
|
||||||
if (!mCurLayer->mTempPoints.empty())
|
if (!mCurLayer->mTempPoints.empty())
|
||||||
ASSIMP_LOG_WARN("LWO: PNTS chunk encountered twice");
|
ASSIMP_LOG_WARN("LWO: PNTS chunk encountered twice");
|
||||||
else LoadLWOPoints(head.length);
|
else
|
||||||
break;
|
LoadLWOPoints(head.length);
|
||||||
}
|
} break;
|
||||||
// face list
|
case AI_LWO_POLS: { // face list
|
||||||
case AI_LWO_POLS:
|
if (!mCurLayer->mFaces.empty())
|
||||||
{
|
ASSIMP_LOG_WARN("LWO: POLS chunk encountered twice");
|
||||||
|
else
|
||||||
|
LoadLWOBPolygons(head.length);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case AI_LWO_SRFS: // list of tags
|
||||||
|
{
|
||||||
|
if (!mTags->empty())
|
||||||
|
ASSIMP_LOG_WARN("LWO: SRFS chunk encountered twice");
|
||||||
|
else
|
||||||
|
LoadLWOTags(head.length);
|
||||||
|
} break;
|
||||||
|
|
||||||
if (!mCurLayer->mFaces.empty())
|
case AI_LWO_SURF: // surface chunk
|
||||||
ASSIMP_LOG_WARN("LWO: POLS chunk encountered twice");
|
{
|
||||||
else LoadLWOBPolygons(head.length);
|
LoadLWOBSurface(head.length);
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
// list of tags
|
|
||||||
case AI_LWO_SRFS:
|
|
||||||
{
|
|
||||||
if (!mTags->empty())
|
|
||||||
ASSIMP_LOG_WARN("LWO: SRFS chunk encountered twice");
|
|
||||||
else LoadLWOTags(head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// surface chunk
|
default:
|
||||||
case AI_LWO_SURF:
|
|
||||||
{
|
|
||||||
LoadLWOBSurface(head.length);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mFileBuffer = next;
|
mFileBuffer = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::LoadLWOBPolygons(unsigned int length)
|
void LWOImporter::LoadLWOBPolygons(unsigned int length) {
|
||||||
{
|
|
||||||
// first find out how many faces and vertices we'll finally need
|
// first find out how many faces and vertices we'll finally need
|
||||||
LE_NCONST uint16_t* const end = (LE_NCONST uint16_t*)(mFileBuffer+length);
|
LE_NCONST uint16_t* const end = (LE_NCONST uint16_t*)(mFileBuffer+length);
|
||||||
LE_NCONST uint16_t* cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
LE_NCONST uint16_t* cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
||||||
|
@ -123,8 +115,7 @@ void LWOImporter::LoadLWOBPolygons(unsigned int length)
|
||||||
CountVertsAndFacesLWOB(iNumVertices,iNumFaces,cursor,end);
|
CountVertsAndFacesLWOB(iNumVertices,iNumFaces,cursor,end);
|
||||||
|
|
||||||
// allocate the output array and copy face indices
|
// allocate the output array and copy face indices
|
||||||
if (iNumFaces)
|
if (iNumFaces) {
|
||||||
{
|
|
||||||
cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
cursor = (LE_NCONST uint16_t*)mFileBuffer;
|
||||||
|
|
||||||
mCurLayer->mFaces.resize(iNumFaces);
|
mCurLayer->mFaces.resize(iNumFaces);
|
||||||
|
@ -135,10 +126,8 @@ void LWOImporter::LoadLWOBPolygons(unsigned int length)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& faces,
|
void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& faces,
|
||||||
LE_NCONST uint16_t*& cursor, const uint16_t* const end, unsigned int max)
|
LE_NCONST uint16_t*& cursor, const uint16_t* const end, unsigned int max) {
|
||||||
{
|
while (cursor < end && max--) {
|
||||||
while (cursor < end && max--)
|
|
||||||
{
|
|
||||||
uint16_t numIndices;
|
uint16_t numIndices;
|
||||||
// must have 2 shorts left for numIndices and surface
|
// must have 2 shorts left for numIndices and surface
|
||||||
if (end - cursor < 2) {
|
if (end - cursor < 2) {
|
||||||
|
@ -154,8 +143,7 @@ void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& face
|
||||||
cursor += numIndices;
|
cursor += numIndices;
|
||||||
int16_t surface;
|
int16_t surface;
|
||||||
::memcpy(&surface, cursor++, 2);
|
::memcpy(&surface, cursor++, 2);
|
||||||
if (surface < 0)
|
if (surface < 0) {
|
||||||
{
|
|
||||||
// there are detail polygons
|
// there are detail polygons
|
||||||
::memcpy(&numIndices, cursor++, 2);
|
::memcpy(&numIndices, cursor++, 2);
|
||||||
CountVertsAndFacesLWOB(verts,faces,cursor,end,numIndices);
|
CountVertsAndFacesLWOB(verts,faces,cursor,end,numIndices);
|
||||||
|
@ -167,18 +155,14 @@ void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& face
|
||||||
void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
|
void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
|
||||||
LE_NCONST uint16_t*& cursor,
|
LE_NCONST uint16_t*& cursor,
|
||||||
const uint16_t* const end,
|
const uint16_t* const end,
|
||||||
unsigned int max)
|
unsigned int max) {
|
||||||
{
|
while (cursor < end && max--) {
|
||||||
while (cursor < end && max--)
|
|
||||||
{
|
|
||||||
LWO::Face& face = *it;++it;
|
LWO::Face& face = *it;++it;
|
||||||
uint16_t numIndices;
|
uint16_t numIndices;
|
||||||
::memcpy(&numIndices, cursor++, 2);
|
::memcpy(&numIndices, cursor++, 2);
|
||||||
face.mNumIndices = numIndices;
|
face.mNumIndices = numIndices;
|
||||||
if(face.mNumIndices)
|
if(face.mNumIndices) {
|
||||||
{
|
if (cursor + face.mNumIndices >= end) {
|
||||||
if (cursor + face.mNumIndices >= end)
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
face.mIndices = new unsigned int[face.mNumIndices];
|
face.mIndices = new unsigned int[face.mNumIndices];
|
||||||
|
@ -187,8 +171,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
::memcpy(&index, cursor++, 2);
|
::memcpy(&index, cursor++, 2);
|
||||||
mi = index;
|
mi = index;
|
||||||
if (mi > mCurLayer->mTempPoints.size())
|
if (mi > mCurLayer->mTempPoints.size()) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_WARN("LWOB: face index is out of range");
|
ASSIMP_LOG_WARN("LWOB: face index is out of range");
|
||||||
mi = (unsigned int)mCurLayer->mTempPoints.size()-1;
|
mi = (unsigned int)mCurLayer->mTempPoints.size()-1;
|
||||||
}
|
}
|
||||||
|
@ -198,15 +181,13 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
|
||||||
}
|
}
|
||||||
int16_t surface;
|
int16_t surface;
|
||||||
::memcpy(&surface, cursor++, 2);
|
::memcpy(&surface, cursor++, 2);
|
||||||
if (surface < 0)
|
if (surface < 0) {
|
||||||
{
|
|
||||||
surface = -surface;
|
surface = -surface;
|
||||||
|
|
||||||
// there are detail polygons.
|
// there are detail polygons.
|
||||||
uint16_t numPolygons;
|
uint16_t numPolygons;
|
||||||
::memcpy(&numPolygons, cursor++, 2);
|
::memcpy(&numPolygons, cursor++, 2);
|
||||||
if (cursor < end)
|
if (cursor < end) {
|
||||||
{
|
|
||||||
CopyFaceIndicesLWOB(it,cursor,end,numPolygons);
|
CopyFaceIndicesLWOB(it,cursor,end,numPolygons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,8 +196,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size)
|
LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size) {
|
||||||
{
|
|
||||||
list.emplace_back();
|
list.emplace_back();
|
||||||
LWO::Texture* tex = &list.back();
|
LWO::Texture* tex = &list.back();
|
||||||
|
|
||||||
|
@ -224,8 +204,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
|
||||||
GetS0(type,size);
|
GetS0(type,size);
|
||||||
const char* s = type.c_str();
|
const char* s = type.c_str();
|
||||||
|
|
||||||
if(strstr(s, "Image Map"))
|
if(strstr(s, "Image Map")) {
|
||||||
{
|
|
||||||
// Determine mapping type
|
// Determine mapping type
|
||||||
if(strstr(s, "Planar"))
|
if(strstr(s, "Planar"))
|
||||||
tex->mapMode = LWO::Texture::Planar;
|
tex->mapMode = LWO::Texture::Planar;
|
||||||
|
@ -237,9 +216,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
|
||||||
tex->mapMode = LWO::Texture::Cubic;
|
tex->mapMode = LWO::Texture::Cubic;
|
||||||
else if(strstr(s, "Front"))
|
else if(strstr(s, "Front"))
|
||||||
tex->mapMode = LWO::Texture::FrontProjection;
|
tex->mapMode = LWO::Texture::FrontProjection;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// procedural or gradient, not supported
|
// procedural or gradient, not supported
|
||||||
ASSIMP_LOG_ERROR("LWOB: Unsupported legacy texture: ", type);
|
ASSIMP_LOG_ERROR("LWOB: Unsupported legacy texture: ", type);
|
||||||
}
|
}
|
||||||
|
@ -248,8 +225,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void LWOImporter::LoadLWOBSurface(unsigned int size)
|
void LWOImporter::LoadLWOBSurface(unsigned int size) {
|
||||||
{
|
|
||||||
LE_NCONST uint8_t* const end = mFileBuffer + size;
|
LE_NCONST uint8_t* const end = mFileBuffer + size;
|
||||||
|
|
||||||
mSurfaces->push_back( LWO::Surface () );
|
mSurfaces->push_back( LWO::Surface () );
|
||||||
|
@ -277,148 +253,147 @@ void LWOImporter::LoadLWOBSurface(unsigned int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* const next = mFileBuffer+head.length;
|
uint8_t* const next = mFileBuffer+head.length;
|
||||||
switch (head.type)
|
switch (head.type) {
|
||||||
{
|
// diffuse color
|
||||||
// diffuse color
|
case AI_LWO_COLR:
|
||||||
case AI_LWO_COLR:
|
{
|
||||||
{
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,COLR,3);
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,COLR,3);
|
surf.mColor.r = GetU1() / 255.0f;
|
||||||
surf.mColor.r = GetU1() / 255.0f;
|
surf.mColor.g = GetU1() / 255.0f;
|
||||||
surf.mColor.g = GetU1() / 255.0f;
|
surf.mColor.b = GetU1() / 255.0f;
|
||||||
surf.mColor.b = GetU1() / 255.0f;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
// diffuse strength ...
|
|
||||||
case AI_LWO_DIFF:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,DIFF,2);
|
|
||||||
surf.mDiffuseValue = GetU2() / 255.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// specular strength ...
|
|
||||||
case AI_LWO_SPEC:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPEC,2);
|
|
||||||
surf.mSpecularValue = GetU2() / 255.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// luminosity ...
|
|
||||||
case AI_LWO_LUMI:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,LUMI,2);
|
|
||||||
surf.mLuminosity = GetU2() / 255.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// transparency
|
|
||||||
case AI_LWO_TRAN:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TRAN,2);
|
|
||||||
surf.mTransparency = GetU2() / 255.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// surface flags
|
|
||||||
case AI_LWO_FLAG:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,FLAG,2);
|
|
||||||
uint16_t flag = GetU2();
|
|
||||||
if (flag & 0x4 ) surf.mMaximumSmoothAngle = 1.56207f;
|
|
||||||
if (flag & 0x8 ) surf.mColorHighlights = 1.f;
|
|
||||||
if (flag & 0x100) surf.bDoubleSided = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// maximum smoothing angle
|
|
||||||
case AI_LWO_SMAN:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
|
|
||||||
surf.mMaximumSmoothAngle = std::fabs( GetF4() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// glossiness
|
|
||||||
case AI_LWO_GLOS:
|
|
||||||
{
|
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,GLOS,2);
|
|
||||||
surf.mGlossiness = (float)GetU2();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// color texture
|
|
||||||
case AI_LWO_CTEX:
|
|
||||||
{
|
|
||||||
pTex = SetupNewTextureLWOB(surf.mColorTextures,
|
|
||||||
head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// diffuse texture
|
|
||||||
case AI_LWO_DTEX:
|
|
||||||
{
|
|
||||||
pTex = SetupNewTextureLWOB(surf.mDiffuseTextures,
|
|
||||||
head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// specular texture
|
|
||||||
case AI_LWO_STEX:
|
|
||||||
{
|
|
||||||
pTex = SetupNewTextureLWOB(surf.mSpecularTextures,
|
|
||||||
head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// bump texture
|
|
||||||
case AI_LWO_BTEX:
|
|
||||||
{
|
|
||||||
pTex = SetupNewTextureLWOB(surf.mBumpTextures,
|
|
||||||
head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// transparency texture
|
|
||||||
case AI_LWO_TTEX:
|
|
||||||
{
|
|
||||||
pTex = SetupNewTextureLWOB(surf.mOpacityTextures,
|
|
||||||
head.length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// texture path
|
|
||||||
case AI_LWO_TIMG:
|
|
||||||
{
|
|
||||||
if (pTex) {
|
|
||||||
GetS0(pTex->mFileName,head.length);
|
|
||||||
} else {
|
|
||||||
ASSIMP_LOG_WARN("LWOB: Unexpected TIMG chunk");
|
|
||||||
}
|
}
|
||||||
break;
|
// diffuse strength ...
|
||||||
}
|
case AI_LWO_DIFF:
|
||||||
// texture strength
|
{
|
||||||
case AI_LWO_TVAL:
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,DIFF,2);
|
||||||
{
|
surf.mDiffuseValue = GetU2() / 255.0f;
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TVAL,1);
|
break;
|
||||||
if (pTex) {
|
|
||||||
pTex->mStrength = (float)GetU1()/ 255.f;
|
|
||||||
} else {
|
|
||||||
ASSIMP_LOG_ERROR("LWOB: Unexpected TVAL chunk");
|
|
||||||
}
|
}
|
||||||
break;
|
// specular strength ...
|
||||||
}
|
case AI_LWO_SPEC:
|
||||||
// texture flags
|
{
|
||||||
case AI_LWO_TFLG:
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPEC,2);
|
||||||
{
|
surf.mSpecularValue = GetU2() / 255.0f;
|
||||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TFLG,2);
|
break;
|
||||||
|
}
|
||||||
if (nullptr != pTex) {
|
// luminosity ...
|
||||||
const uint16_t s = GetU2();
|
case AI_LWO_LUMI:
|
||||||
if (s & 1)
|
{
|
||||||
pTex->majorAxis = LWO::Texture::AXIS_X;
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,LUMI,2);
|
||||||
else if (s & 2)
|
surf.mLuminosity = GetU2() / 255.0f;
|
||||||
pTex->majorAxis = LWO::Texture::AXIS_Y;
|
break;
|
||||||
else if (s & 4)
|
}
|
||||||
pTex->majorAxis = LWO::Texture::AXIS_Z;
|
// transparency
|
||||||
|
case AI_LWO_TRAN:
|
||||||
if (s & 16) {
|
{
|
||||||
ASSIMP_LOG_WARN("LWOB: Ignoring \'negate\' flag on texture");
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TRAN,2);
|
||||||
|
surf.mTransparency = GetU2() / 255.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// surface flags
|
||||||
|
case AI_LWO_FLAG:
|
||||||
|
{
|
||||||
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,FLAG,2);
|
||||||
|
uint16_t flag = GetU2();
|
||||||
|
if (flag & 0x4 ) surf.mMaximumSmoothAngle = 1.56207f;
|
||||||
|
if (flag & 0x8 ) surf.mColorHighlights = 1.f;
|
||||||
|
if (flag & 0x100) surf.bDoubleSided = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// maximum smoothing angle
|
||||||
|
case AI_LWO_SMAN:
|
||||||
|
{
|
||||||
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SMAN,4);
|
||||||
|
surf.mMaximumSmoothAngle = std::fabs( GetF4() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// glossiness
|
||||||
|
case AI_LWO_GLOS:
|
||||||
|
{
|
||||||
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,GLOS,2);
|
||||||
|
surf.mGlossiness = (float)GetU2();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// color texture
|
||||||
|
case AI_LWO_CTEX:
|
||||||
|
{
|
||||||
|
pTex = SetupNewTextureLWOB(surf.mColorTextures,
|
||||||
|
head.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// diffuse texture
|
||||||
|
case AI_LWO_DTEX:
|
||||||
|
{
|
||||||
|
pTex = SetupNewTextureLWOB(surf.mDiffuseTextures,
|
||||||
|
head.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// specular texture
|
||||||
|
case AI_LWO_STEX:
|
||||||
|
{
|
||||||
|
pTex = SetupNewTextureLWOB(surf.mSpecularTextures,
|
||||||
|
head.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// bump texture
|
||||||
|
case AI_LWO_BTEX:
|
||||||
|
{
|
||||||
|
pTex = SetupNewTextureLWOB(surf.mBumpTextures,
|
||||||
|
head.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// transparency texture
|
||||||
|
case AI_LWO_TTEX:
|
||||||
|
{
|
||||||
|
pTex = SetupNewTextureLWOB(surf.mOpacityTextures,
|
||||||
|
head.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// texture path
|
||||||
|
case AI_LWO_TIMG:
|
||||||
|
{
|
||||||
|
if (pTex) {
|
||||||
|
GetS0(pTex->mFileName,head.length);
|
||||||
|
} else {
|
||||||
|
ASSIMP_LOG_WARN("LWOB: Unexpected TIMG chunk");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
// texture strength
|
||||||
ASSIMP_LOG_WARN("LWOB: Unexpected TFLG chunk");
|
case AI_LWO_TVAL:
|
||||||
|
{
|
||||||
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TVAL,1);
|
||||||
|
if (pTex) {
|
||||||
|
pTex->mStrength = (float)GetU1()/ 255.f;
|
||||||
|
} else {
|
||||||
|
ASSIMP_LOG_ERROR("LWOB: Unexpected TVAL chunk");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// texture flags
|
||||||
|
case AI_LWO_TFLG:
|
||||||
|
{
|
||||||
|
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,TFLG,2);
|
||||||
|
|
||||||
|
if (nullptr != pTex) {
|
||||||
|
const uint16_t s = GetU2();
|
||||||
|
if (s & 1)
|
||||||
|
pTex->majorAxis = LWO::Texture::AXIS_X;
|
||||||
|
else if (s & 2)
|
||||||
|
pTex->majorAxis = LWO::Texture::AXIS_Y;
|
||||||
|
else if (s & 4)
|
||||||
|
pTex->majorAxis = LWO::Texture::AXIS_Z;
|
||||||
|
|
||||||
|
if (s & 16) {
|
||||||
|
ASSIMP_LOG_WARN("LWOB: Ignoring \'negate\' flag on texture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ASSIMP_LOG_WARN("LWOB: Unexpected TFLG chunk");
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mFileBuffer = next;
|
mFileBuffer = next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"LightWave Scene Importer",
|
"LightWave Scene Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -139,10 +139,6 @@ LWSImporter::LWSImporter() :
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
LWSImporter::~LWSImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool LWSImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool LWSImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -174,7 +174,7 @@ struct NodeDesc {
|
||||||
class LWSImporter : public BaseImporter {
|
class LWSImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
LWSImporter();
|
LWSImporter();
|
||||||
~LWSImporter() override;
|
~LWSImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Check whether we can read a specific file
|
// Check whether we can read a specific file
|
||||||
|
|
|
@ -85,7 +85,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
are listed in aiScene->mRootNode->children, but all without meshes
|
are listed in aiScene->mRootNode->children, but all without meshes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Model 3D Importer",
|
"Model 3D Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2022, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -41,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_MD2_IMPORTER
|
||||||
|
|
||||||
/** @file Implementation of the MD2 importer class */
|
/** @file Implementation of the MD2 importer class */
|
||||||
|
@ -65,7 +62,7 @@ using namespace Assimp::MD2;
|
||||||
# define ARRAYSIZE(_array) (int(sizeof(_array) / sizeof(_array[0])))
|
# define ARRAYSIZE(_array) (int(sizeof(_array) / sizeof(_array[0])))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Quake II Mesh Importer",
|
"Quake II Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -79,7 +76,7 @@ static const aiImporterDesc desc = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Helper function to lookup a normal in Quake 2's precalculated table
|
// Helper function to lookup a normal in Quake 2's pre-calculated table
|
||||||
void MD2::LookupNormalIndex(uint8_t iNormalIndex,aiVector3D& vOut)
|
void MD2::LookupNormalIndex(uint8_t iNormalIndex,aiVector3D& vOut)
|
||||||
{
|
{
|
||||||
// make sure the normal index has a valid value
|
// make sure the normal index has a valid value
|
||||||
|
@ -100,10 +97,6 @@ MD2Importer::MD2Importer()
|
||||||
fileSize()
|
fileSize()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
MD2Importer::~MD2Importer() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool MD2Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
bool MD2Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
||||||
|
|
|
@ -63,7 +63,7 @@ using namespace MD2;
|
||||||
class MD2Importer : public BaseImporter {
|
class MD2Importer : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
MD2Importer();
|
MD2Importer();
|
||||||
~MD2Importer() override;
|
~MD2Importer() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -70,7 +70,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Quake III Mesh Importer",
|
"Quake III Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -64,7 +64,7 @@ using namespace Assimp;
|
||||||
// Minimum weight value. Weights inside [-n ... n] are ignored
|
// Minimum weight value. Weights inside [-n ... n] are ignored
|
||||||
#define AI_MD5_WEIGHT_EPSILON Math::getEpsilon<float>()
|
#define AI_MD5_WEIGHT_EPSILON Math::getEpsilon<float>()
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Doom 3 / MD5 Mesh Importer",
|
"Doom 3 / MD5 Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -92,10 +92,6 @@ MD5Importer::MD5Importer() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
MD5Importer::~MD5Importer() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -65,7 +65,7 @@ using namespace Assimp::MD5;
|
||||||
class MD5Importer : public BaseImporter {
|
class MD5Importer : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
MD5Importer();
|
MD5Importer();
|
||||||
~MD5Importer() override;
|
~MD5Importer() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::MDC;
|
using namespace Assimp::MDC;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Return To Castle Wolfenstein Mesh Importer",
|
"Return To Castle Wolfenstein Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -103,10 +103,6 @@ MDCImporter::MDCImporter() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
MDCImporter::~MDCImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool MDCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool MDCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -62,7 +62,7 @@ using namespace MDC;
|
||||||
class MDCImporter : public BaseImporter {
|
class MDCImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
MDCImporter();
|
MDCImporter();
|
||||||
~MDCImporter() override;
|
~MDCImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Quake Mesh / 3D GameStudio Mesh Importer",
|
"Quake Mesh / 3D GameStudio Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -96,10 +96,6 @@ MDLImporter::MDLImporter() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
MDLImporter::~MDLImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool MDLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
|
|
@ -39,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/// @file MDLLoader.h
|
||||||
/** @file MDLLoader.h
|
/// @brief Declaration of the loader for MDL files
|
||||||
* @brief Declaration of the loader for MDL files
|
|
||||||
*/
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef AI_MDLLOADER_H_INCLUDED
|
#ifndef AI_MDLLOADER_H_INCLUDED
|
||||||
#define AI_MDLLOADER_H_INCLUDED
|
#define AI_MDLLOADER_H_INCLUDED
|
||||||
|
@ -83,11 +81,10 @@ using namespace MDL;
|
||||||
* them all with a single 1000-line function-beast. However, it has been
|
* them all with a single 1000-line function-beast. However, it has been
|
||||||
* split into several code paths to make the code easier to read and maintain.
|
* split into several code paths to make the code easier to read and maintain.
|
||||||
*/
|
*/
|
||||||
class MDLImporter : public BaseImporter
|
class MDLImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MDLImporter();
|
MDLImporter();
|
||||||
~MDLImporter() override;
|
~MDLImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
static const aiImporterDesc desc = { "MMD Importer",
|
static constexpr aiImporterDesc desc = { "MMD Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"surfaces supported?",
|
"surfaces supported?",
|
||||||
|
@ -81,10 +81,6 @@ MMDImporter::MMDImporter() :
|
||||||
m_strAbsPath = io.getOsSeparator();
|
m_strAbsPath = io.getOsSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor.
|
|
||||||
MMDImporter::~MMDImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns true, if file is an pmx file.
|
// Returns true, if file is an pmx file.
|
||||||
bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
|
|
|
@ -50,46 +50,34 @@ struct aiMesh;
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
/// \class MMDImporter
|
/// @class MMDImporter
|
||||||
/// \brief Imports MMD a pmx/pmd/vmd file
|
/// @brief Imports MMD a pmx/pmd/vmd file
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
class MMDImporter : public BaseImporter {
|
class MMDImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
/// \brief Default constructor
|
/// @brief Default constructor
|
||||||
MMDImporter();
|
MMDImporter();
|
||||||
|
|
||||||
/// \brief Destructor
|
/// @brief Destructor
|
||||||
~MMDImporter() override;
|
~MMDImporter() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Returns whether the class can handle the format of the given file.
|
/// @brief Returns whether the class can handle the format of the given file.
|
||||||
/// \remark See BaseImporter::CanRead() for details.
|
/// @remark See BaseImporter::CanRead() for details.
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! \brief Appends the supported extension.
|
|
||||||
const aiImporterDesc* GetInfo() const override;
|
const aiImporterDesc* GetInfo() const override;
|
||||||
|
|
||||||
//! \brief File import implementation.
|
|
||||||
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
||||||
|
|
||||||
//! \brief Create the data from imported content.
|
|
||||||
void CreateDataFromImport(const pmx::PmxModel* pModel, aiScene* pScene);
|
void CreateDataFromImport(const pmx::PmxModel* pModel, aiScene* pScene);
|
||||||
|
|
||||||
//! \brief Create the mesh
|
|
||||||
aiMesh* CreateMesh(const pmx::PmxModel* pModel, const int indexStart, const int indexCount);
|
aiMesh* CreateMesh(const pmx::PmxModel* pModel, const int indexStart, const int indexCount);
|
||||||
|
|
||||||
//! \brief Create the material
|
|
||||||
aiMaterial* CreateMaterial(const pmx::PmxMaterial* pMat, const pmx::PmxModel* pModel);
|
aiMaterial* CreateMaterial(const pmx::PmxMaterial* pMat, const pmx::PmxModel* pModel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Data buffer
|
|
||||||
std::vector<char> m_Buffer;
|
std::vector<char> m_Buffer;
|
||||||
//! Absolute pathname of model in file system
|
|
||||||
std::string m_strAbsPath;
|
std::string m_strAbsPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Milkshape 3D Importer",
|
"Milkshape 3D Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -84,9 +84,6 @@ MS3DImporter::MS3DImporter()
|
||||||
: mScene()
|
: mScene()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
MS3DImporter::~MS3DImporter() = default;
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
||||||
|
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <assimp/StreamReader.h>
|
#include <assimp/StreamReader.h>
|
||||||
|
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -58,7 +59,7 @@ namespace Assimp {
|
||||||
class MS3DImporter : public BaseImporter {
|
class MS3DImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
MS3DImporter();
|
MS3DImporter();
|
||||||
~MS3DImporter() override;
|
~MS3DImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Implementation of the NDO importer class.
|
* Implementation of the NDO importer class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_NDO_IMPORTER
|
||||||
|
|
||||||
#include "NDOLoader.h"
|
#include "NDOLoader.h"
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Nendo Mesh Importer",
|
"Nendo Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -69,14 +69,6 @@ static const aiImporterDesc desc = {
|
||||||
"ndo"
|
"ndo"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
NDOImporter::NDOImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
NDOImporter::~NDOImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool NDOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
bool NDOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
||||||
|
|
|
@ -65,8 +65,8 @@ class Importer;
|
||||||
*/
|
*/
|
||||||
class NDOImporter : public BaseImporter {
|
class NDOImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
NDOImporter();
|
NDOImporter() = default;
|
||||||
~NDOImporter() override;
|
~NDOImporter() override = default;
|
||||||
|
|
||||||
//! Represents a single edge
|
//! Represents a single edge
|
||||||
struct Edge {
|
struct Edge {
|
||||||
|
|
|
@ -56,9 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Neutral File Format Importer",
|
"Neutral File Format Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -71,14 +71,6 @@ static const aiImporterDesc desc = {
|
||||||
"enff nff"
|
"enff nff"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
NFFImporter::NFFImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
NFFImporter::~NFFImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool NFFImporter::CanRead(const std::string & pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
bool NFFImporter::CanRead(const std::string & pFile, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
||||||
|
@ -94,7 +86,7 @@ const aiImporterDesc *NFFImporter::GetInfo() const {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define AI_NFF_PARSE_FLOAT(f) \
|
#define AI_NFF_PARSE_FLOAT(f) \
|
||||||
SkipSpaces(&sz); \
|
SkipSpaces(&sz); \
|
||||||
if (!::IsLineEnd(*sz)) sz = fast_atoreal_move<ai_real>(sz, (ai_real &)f);
|
if (!IsLineEnd(*sz)) sz = fast_atoreal_move<ai_real>(sz, (ai_real &)f);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define AI_NFF_PARSE_TRIPLE(v) \
|
#define AI_NFF_PARSE_TRIPLE(v) \
|
||||||
|
@ -338,8 +330,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the numbr of vertices
|
// read the number of vertices
|
||||||
unsigned int num = ::strtoul10(sz, &sz);
|
unsigned int num = strtoul10(sz, &sz);
|
||||||
|
|
||||||
// temporary storage
|
// temporary storage
|
||||||
std::vector<aiColor4D> tempColors;
|
std::vector<aiColor4D> tempColors;
|
||||||
|
@ -365,7 +357,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
// color definition
|
// color definition
|
||||||
if (TokenMatch(sz, "0x", 2)) {
|
if (TokenMatch(sz, "0x", 2)) {
|
||||||
hasColor = true;
|
hasColor = true;
|
||||||
unsigned int numIdx = ::strtoul16(sz, &sz);
|
unsigned int numIdx = strtoul16(sz, &sz);
|
||||||
aiColor4D clr;
|
aiColor4D clr;
|
||||||
clr.a = 1.f;
|
clr.a = 1.f;
|
||||||
|
|
||||||
|
@ -403,15 +395,16 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
AI_NFF2_GET_NEXT_TOKEN();
|
AI_NFF2_GET_NEXT_TOKEN();
|
||||||
if (!num) throw DeadlyImportError("NFF2: There are zero vertices");
|
if (!num)
|
||||||
num = ::strtoul10(sz, &sz);
|
throw DeadlyImportError("NFF2: There are zero vertices");
|
||||||
|
num = strtoul10(sz, &sz);
|
||||||
|
|
||||||
std::vector<unsigned int> tempIdx;
|
std::vector<unsigned int> tempIdx;
|
||||||
tempIdx.reserve(10);
|
tempIdx.reserve(10);
|
||||||
for (unsigned int i = 0; i < num; ++i) {
|
for (unsigned int i = 0; i < num; ++i) {
|
||||||
AI_NFF2_GET_NEXT_TOKEN();
|
AI_NFF2_GET_NEXT_TOKEN();
|
||||||
SkipSpaces(line, &sz);
|
SkipSpaces(line, &sz);
|
||||||
unsigned int numIdx = ::strtoul10(sz, &sz);
|
unsigned int numIdx = strtoul10(sz, &sz);
|
||||||
|
|
||||||
// read all faces indices
|
// read all faces indices
|
||||||
if (numIdx) {
|
if (numIdx) {
|
||||||
|
@ -421,7 +414,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
|
|
||||||
for (unsigned int a = 0; a < numIdx; ++a) {
|
for (unsigned int a = 0; a < numIdx; ++a) {
|
||||||
SkipSpaces(sz, &sz);
|
SkipSpaces(sz, &sz);
|
||||||
unsigned int m = ::strtoul10(sz, &sz);
|
unsigned int m = strtoul10(sz, &sz);
|
||||||
if (m >= (unsigned int)tempPositions.size()) {
|
if (m >= (unsigned int)tempPositions.size()) {
|
||||||
ASSIMP_LOG_ERROR("NFF2: Vertex index overflow");
|
ASSIMP_LOG_ERROR("NFF2: Vertex index overflow");
|
||||||
m = 0;
|
m = 0;
|
||||||
|
@ -446,7 +439,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
if (TokenMatch(sz, "0x", 2)) {
|
if (TokenMatch(sz, "0x", 2)) {
|
||||||
hasColor = true;
|
hasColor = true;
|
||||||
const char *sz2 = sz;
|
const char *sz2 = sz;
|
||||||
numIdx = ::strtoul16(sz, &sz);
|
numIdx = strtoul16(sz, &sz);
|
||||||
const unsigned int diff = (unsigned int)(sz - sz2);
|
const unsigned int diff = (unsigned int)(sz - sz2);
|
||||||
|
|
||||||
// 0xRRGGBB
|
// 0xRRGGBB
|
||||||
|
@ -518,7 +511,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
// Material ID?
|
// Material ID?
|
||||||
else if (!materialTable.empty() && TokenMatch(sz, "matid", 5)) {
|
else if (!materialTable.empty() && TokenMatch(sz, "matid", 5)) {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
matIdx = ::strtoul10(sz, &sz);
|
matIdx = strtoul10(sz, &sz);
|
||||||
if (matIdx >= materialTable.size()) {
|
if (matIdx >= materialTable.size()) {
|
||||||
ASSIMP_LOG_ERROR("NFF2: Material index overflow.");
|
ASSIMP_LOG_ERROR("NFF2: Material index overflow.");
|
||||||
matIdx = 0;
|
matIdx = 0;
|
||||||
|
@ -1165,4 +1158,6 @@ void NFFImporter::InternReadFile(const std::string &pFile,
|
||||||
pScene->mRootNode = root;
|
pScene->mRootNode = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_NFF_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_NFF_IMPORTER
|
||||||
|
|
|
@ -63,8 +63,8 @@ namespace Assimp {
|
||||||
*/
|
*/
|
||||||
class NFFImporter : public BaseImporter {
|
class NFFImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
NFFImporter();
|
NFFImporter() = default;
|
||||||
~NFFImporter() override;
|
~NFFImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Implementation of the OFF importer class
|
* @brief Implementation of the OFF importer class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_OFF_IMPORTER
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
|
@ -56,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/importerdesc.h>
|
#include <assimp/importerdesc.h>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"OFF Importer",
|
"OFF Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -71,99 +70,92 @@ static const aiImporterDesc desc = {
|
||||||
"off"
|
"off"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
OFFImporter::OFFImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
OFFImporter::~OFFImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool OFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const
|
bool OFFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
{
|
static const char *tokens[] = { "off" };
|
||||||
static const char* tokens[] = { "off" };
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens), 3);
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,AI_COUNT_OF(tokens),3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const aiImporterDesc* OFFImporter::GetInfo () const
|
const aiImporterDesc *OFFImporter::GetInfo() const {
|
||||||
{
|
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// skip blank space, lines and comments
|
// skip blank space, lines and comments
|
||||||
static void NextToken(const char **car, const char* end) {
|
static void NextToken(const char **car, const char *end) {
|
||||||
SkipSpacesAndLineEnd(car);
|
|
||||||
while (*car < end && (**car == '#' || **car == '\n' || **car == '\r')) {
|
|
||||||
SkipLine(car);
|
|
||||||
SkipSpacesAndLineEnd(car);
|
SkipSpacesAndLineEnd(car);
|
||||||
}
|
while (*car < end && (**car == '#' || **car == '\n' || **car == '\r')) {
|
||||||
|
SkipLine(car);
|
||||||
|
SkipSpacesAndLineEnd(car);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
|
void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
|
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
throw DeadlyImportError("Failed to open OFF file ", pFile, ".");
|
throw DeadlyImportError("Failed to open OFF file ", pFile, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate storage and copy the contents of the file to a memory buffer
|
// allocate storage and copy the contents of the file to a memory buffer
|
||||||
std::vector<char> mBuffer2;
|
std::vector<char> mBuffer2;
|
||||||
TextFileToBuffer(file.get(),mBuffer2);
|
TextFileToBuffer(file.get(), mBuffer2);
|
||||||
const char* buffer = &mBuffer2[0];
|
const char *buffer = &mBuffer2[0];
|
||||||
|
|
||||||
// Proper OFF header parser. We only implement normal loading for now.
|
// Proper OFF header parser. We only implement normal loading for now.
|
||||||
bool hasTexCoord = false, hasNormals = false, hasColors = false;
|
bool hasTexCoord = false, hasNormals = false, hasColors = false;
|
||||||
bool hasHomogenous = false, hasDimension = false;
|
bool hasHomogenous = false, hasDimension = false;
|
||||||
unsigned int dimensions = 3;
|
unsigned int dimensions = 3;
|
||||||
const char* car = buffer;
|
const char *car = buffer;
|
||||||
const char* end = buffer + mBuffer2.size();
|
const char *end = buffer + mBuffer2.size();
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
|
|
||||||
if (car < end - 2 && car[0] == 'S' && car[1] == 'T') {
|
if (car < end - 2 && car[0] == 'S' && car[1] == 'T') {
|
||||||
hasTexCoord = true; car += 2;
|
hasTexCoord = true;
|
||||||
|
car += 2;
|
||||||
}
|
}
|
||||||
if (car < end - 1 && car[0] == 'C') {
|
if (car < end - 1 && car[0] == 'C') {
|
||||||
hasColors = true; car++;
|
hasColors = true;
|
||||||
|
car++;
|
||||||
}
|
}
|
||||||
if (car < end- 1 && car[0] == 'N') {
|
if (car < end - 1 && car[0] == 'N') {
|
||||||
hasNormals = true; car++;
|
hasNormals = true;
|
||||||
|
car++;
|
||||||
}
|
}
|
||||||
if (car < end - 1 && car[0] == '4') {
|
if (car < end - 1 && car[0] == '4') {
|
||||||
hasHomogenous = true; car++;
|
hasHomogenous = true;
|
||||||
|
car++;
|
||||||
}
|
}
|
||||||
if (car < end - 1 && car[0] == 'n') {
|
if (car < end - 1 && car[0] == 'n') {
|
||||||
hasDimension = true; car++;
|
hasDimension = true;
|
||||||
|
car++;
|
||||||
}
|
}
|
||||||
if (car < end - 3 && car[0] == 'O' && car[1] == 'F' && car[2] == 'F') {
|
if (car < end - 3 && car[0] == 'O' && car[1] == 'F' && car[2] == 'F') {
|
||||||
car += 3;
|
car += 3;
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
} else {
|
} else {
|
||||||
// in case there is no OFF header (which is allowed by the
|
// in case there is no OFF header (which is allowed by the
|
||||||
// specification...), then we might have unintentionally read an
|
// specification...), then we might have unintentionally read an
|
||||||
// additional dimension from the primitive count fields
|
// additional dimension from the primitive count fields
|
||||||
dimensions = 3;
|
dimensions = 3;
|
||||||
hasHomogenous = false;
|
hasHomogenous = false;
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
|
|
||||||
// at this point the next token should be an integer number
|
// at this point the next token should be an integer number
|
||||||
if (car >= end - 1 || *car < '0' || *car > '9') {
|
if (car >= end - 1 || *car < '0' || *car > '9') {
|
||||||
throw DeadlyImportError("OFF: Header is invalid");
|
throw DeadlyImportError("OFF: Header is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasDimension) {
|
if (hasDimension) {
|
||||||
dimensions = strtoul10(car, &car);
|
dimensions = strtoul10(car, &car);
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
}
|
}
|
||||||
if (dimensions > 3) {
|
if (dimensions > 3) {
|
||||||
throw DeadlyImportError
|
throw DeadlyImportError("OFF: Number of vertex coordinates higher than 3 unsupported");
|
||||||
("OFF: Number of vertex coordinates higher than 3 unsupported");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
|
@ -171,7 +163,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
const unsigned int numFaces = strtoul10(car, &car);
|
const unsigned int numFaces = strtoul10(car, &car);
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
strtoul10(car, &car); // skip edge count
|
strtoul10(car, &car); // skip edge count
|
||||||
NextToken(&car, end);
|
NextToken(&car, end);
|
||||||
|
|
||||||
if (!numVertices) {
|
if (!numVertices) {
|
||||||
|
@ -182,13 +174,13 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
}
|
}
|
||||||
|
|
||||||
pScene->mNumMeshes = 1;
|
pScene->mNumMeshes = 1;
|
||||||
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
|
||||||
|
|
||||||
aiMesh* mesh = new aiMesh();
|
aiMesh *mesh = new aiMesh();
|
||||||
pScene->mMeshes[0] = mesh;
|
pScene->mMeshes[0] = mesh;
|
||||||
|
|
||||||
mesh->mNumFaces = numFaces;
|
mesh->mNumFaces = numFaces;
|
||||||
aiFace* faces = new aiFace[mesh->mNumFaces];
|
aiFace *faces = new aiFace[mesh->mNumFaces];
|
||||||
mesh->mFaces = faces;
|
mesh->mFaces = faces;
|
||||||
|
|
||||||
mesh->mNumVertices = numVertices;
|
mesh->mNumVertices = numVertices;
|
||||||
|
@ -206,100 +198,101 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
|
|
||||||
// now read all vertex lines
|
// now read all vertex lines
|
||||||
for (unsigned int i = 0; i < numVertices; ++i) {
|
for (unsigned int i = 0; i < numVertices; ++i) {
|
||||||
if(!GetNextLine(buffer, line)) {
|
if (!GetNextLine(buffer, line)) {
|
||||||
ASSIMP_LOG_ERROR("OFF: The number of verts in the header is incorrect");
|
ASSIMP_LOG_ERROR("OFF: The number of verts in the header is incorrect");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
aiVector3D& v = mesh->mVertices[i];
|
aiVector3D &v = mesh->mVertices[i];
|
||||||
sz = line;
|
sz = line;
|
||||||
|
|
||||||
// helper array to write a for loop over possible dimension values
|
// helper array to write a for loop over possible dimension values
|
||||||
ai_real* vec[3] = {&v.x, &v.y, &v.z};
|
ai_real *vec[3] = { &v.x, &v.y, &v.z };
|
||||||
|
|
||||||
// stop at dimensions: this allows loading 1D or 2D coordinate vertices
|
// stop at dimensions: this allows loading 1D or 2D coordinate vertices
|
||||||
for (unsigned int dim = 0; dim < dimensions; ++dim ) {
|
for (unsigned int dim = 0; dim < dimensions; ++dim) {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz, *vec[dim]);
|
sz = fast_atoreal_move<ai_real>(sz, *vec[dim]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if has homogeneous coordinate, divide others by this one
|
// if has homogeneous coordinate, divide others by this one
|
||||||
if (hasHomogenous) {
|
if (hasHomogenous) {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
ai_real w = 1.;
|
ai_real w = 1.;
|
||||||
sz = fast_atoreal_move<ai_real>(sz, w);
|
sz = fast_atoreal_move<ai_real>(sz, w);
|
||||||
for (unsigned int dim = 0; dim < dimensions; ++dim ) {
|
for (unsigned int dim = 0; dim < dimensions; ++dim) {
|
||||||
*(vec[dim]) /= w;
|
*(vec[dim]) /= w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read optional normals
|
// read optional normals
|
||||||
if (hasNormals) {
|
if (hasNormals) {
|
||||||
aiVector3D& n = mesh->mNormals[i];
|
aiVector3D &n = mesh->mNormals[i];
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)n.x);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)n.x);
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)n.y);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)n.y);
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
fast_atoreal_move<ai_real>(sz,(ai_real&)n.z);
|
fast_atoreal_move<ai_real>(sz, (ai_real &)n.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading colors is a pain because the specification says it can be
|
// reading colors is a pain because the specification says it can be
|
||||||
// integers or floats, and any number of them between 1 and 4 included,
|
// integers or floats, and any number of them between 1 and 4 included,
|
||||||
// until the next comment or end of line
|
// until the next comment or end of line
|
||||||
// in theory should be testing type !
|
// in theory should be testing type !
|
||||||
if (hasColors) {
|
if (hasColors) {
|
||||||
aiColor4D& c = mesh->mColors[0][i];
|
aiColor4D &c = mesh->mColors[0][i];
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.r);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.r);
|
||||||
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.g);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.g);
|
||||||
} else {
|
} else {
|
||||||
c.g = 0.;
|
c.g = 0.;
|
||||||
}
|
}
|
||||||
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.b);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.b);
|
||||||
} else {
|
} else {
|
||||||
c.b = 0.;
|
c.b = 0.;
|
||||||
}
|
}
|
||||||
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)c.a);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)c.a);
|
||||||
} else {
|
} else {
|
||||||
c.a = 1.;
|
c.a = 1.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasTexCoord) {
|
if (hasTexCoord) {
|
||||||
aiVector3D& t = mesh->mTextureCoords[0][i];
|
aiVector3D &t = mesh->mTextureCoords[0][i];
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)t.x);
|
sz = fast_atoreal_move<ai_real>(sz, (ai_real &)t.x);
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
fast_atoreal_move<ai_real>(sz,(ai_real&)t.y);
|
fast_atoreal_move<ai_real>(sz, (ai_real &)t.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load faces with their indices
|
// load faces with their indices
|
||||||
faces = mesh->mFaces;
|
faces = mesh->mFaces;
|
||||||
for (unsigned int i = 0; i < numFaces; ) {
|
for (unsigned int i = 0; i < numFaces;) {
|
||||||
if(!GetNextLine(buffer,line)) {
|
if (!GetNextLine(buffer, line)) {
|
||||||
ASSIMP_LOG_ERROR("OFF: The number of faces in the header is incorrect");
|
ASSIMP_LOG_ERROR("OFF: The number of faces in the header is incorrect");
|
||||||
throw DeadlyImportError("OFF: The number of faces in the header is incorrect");
|
throw DeadlyImportError("OFF: The number of faces in the header is incorrect");
|
||||||
}
|
}
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
sz = line; SkipSpaces(&sz);
|
sz = line;
|
||||||
idx = strtoul10(sz,&sz);
|
SkipSpaces(&sz);
|
||||||
if(!idx || idx > 9) {
|
idx = strtoul10(sz, &sz);
|
||||||
ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
|
if (!idx || idx > 9) {
|
||||||
|
ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
|
||||||
--mesh->mNumFaces;
|
--mesh->mNumFaces;
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
faces->mNumIndices = idx;
|
faces->mNumIndices = idx;
|
||||||
faces->mIndices = new unsigned int[faces->mNumIndices];
|
faces->mIndices = new unsigned int[faces->mNumIndices];
|
||||||
for (unsigned int m = 0; m < faces->mNumIndices;++m) {
|
for (unsigned int m = 0; m < faces->mNumIndices; ++m) {
|
||||||
SkipSpaces(&sz);
|
SkipSpaces(&sz);
|
||||||
idx = strtoul10(sz,&sz);
|
idx = strtoul10(sz, &sz);
|
||||||
if (idx >= numVertices) {
|
if (idx >= numVertices) {
|
||||||
ASSIMP_LOG_ERROR("OFF: Vertex index is out of range");
|
ASSIMP_LOG_ERROR("OFF: Vertex index is out of range");
|
||||||
idx = numVertices - 1;
|
idx = numVertices - 1;
|
||||||
|
@ -314,20 +307,22 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||||
pScene->mRootNode = new aiNode();
|
pScene->mRootNode = new aiNode();
|
||||||
pScene->mRootNode->mName.Set("<OFFRoot>");
|
pScene->mRootNode->mName.Set("<OFFRoot>");
|
||||||
pScene->mRootNode->mNumMeshes = 1;
|
pScene->mRootNode->mNumMeshes = 1;
|
||||||
pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes];
|
pScene->mRootNode->mMeshes = new unsigned int[pScene->mRootNode->mNumMeshes];
|
||||||
pScene->mRootNode->mMeshes[0] = 0;
|
pScene->mRootNode->mMeshes[0] = 0;
|
||||||
|
|
||||||
// generate a default material
|
// generate a default material
|
||||||
pScene->mNumMaterials = 1;
|
pScene->mNumMaterials = 1;
|
||||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial *pcMat = new aiMaterial();
|
||||||
|
|
||||||
aiColor4D clr( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 1.0 ) );
|
aiColor4D clr(ai_real(0.6), ai_real(0.6), ai_real(0.6), ai_real(1.0));
|
||||||
pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
pcMat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
pScene->mMaterials[0] = pcMat;
|
pScene->mMaterials[0] = pcMat;
|
||||||
|
|
||||||
const int twosided = 1;
|
const int twosided = 1;
|
||||||
pcMat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
|
pcMat->AddProperty(&twosided, 1, AI_MATKEY_TWOSIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_OFF_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_OFF_IMPORTER
|
||||||
|
|
|
@ -57,8 +57,8 @@ namespace Assimp {
|
||||||
*/
|
*/
|
||||||
class OFFImporter : public BaseImporter {
|
class OFFImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
OFFImporter();
|
OFFImporter() = default;
|
||||||
~OFFImporter() override;
|
~OFFImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/ObjMaterial.h>
|
#include <assimp/ObjMaterial.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Wavefront Object Importer",
|
"Wavefront Object Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -103,6 +103,11 @@ const aiImporterDesc *ObjFileImporter::GetInfo() const {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Obj-file import implementation
|
// Obj-file import implementation
|
||||||
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
|
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
|
if (m_pRootObject != nullptr) {
|
||||||
|
delete m_pRootObject;
|
||||||
|
m_pRootObject = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Read file into memory
|
// Read file into memory
|
||||||
static constexpr char mode[] = "rb";
|
static constexpr char mode[] = "rb";
|
||||||
auto streamCloser = [&](IOStream *pStream) {
|
auto streamCloser = [&](IOStream *pStream) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Ogre3D Mesh Importer",
|
"Ogre3D Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <openddlparser/OpenDDLParser.h>
|
#include <openddlparser/OpenDDLParser.h>
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Open Game Engine Exchange",
|
"Open Game Engine Exchange",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -66,42 +66,42 @@ static const aiImporterDesc desc = {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Grammar {
|
namespace Grammar {
|
||||||
static const char* MetricType = "Metric";
|
static constexpr char MetricType[] = "Metric";
|
||||||
static const char *Metric_DistanceType = "distance";
|
static constexpr char Metric_DistanceType[] = "distance";
|
||||||
static const char *Metric_AngleType = "angle";
|
static constexpr char Metric_AngleType[] = "angle";
|
||||||
static const char *Metric_TimeType = "time";
|
static constexpr char Metric_TimeType[] = "time";
|
||||||
static const char *Metric_UpType = "up";
|
static constexpr char Metric_UpType[] = "up";
|
||||||
static const char *NameType = "Name";
|
static constexpr char NameType[] = "Name";
|
||||||
static const char *ObjectRefType = "ObjectRef";
|
static constexpr char ObjectRefType[] = "ObjectRef";
|
||||||
static const char *MaterialRefType = "MaterialRef";
|
static constexpr char MaterialRefType[] = "MaterialRef";
|
||||||
static const char *MetricKeyType = "key";
|
static constexpr char MetricKeyType[] = "key";
|
||||||
static const char *GeometryNodeType = "GeometryNode";
|
static constexpr char GeometryNodeType[] = "GeometryNode";
|
||||||
static const char *CameraNodeType = "CameraNode";
|
static constexpr char CameraNodeType[] = "CameraNode";
|
||||||
static const char *LightNodeType = "LightNode";
|
static constexpr char LightNodeType[] = "LightNode";
|
||||||
static const char *GeometryObjectType = "GeometryObject";
|
static constexpr char GeometryObjectType[] = "GeometryObject";
|
||||||
static const char *CameraObjectType = "CameraObject";
|
static constexpr char CameraObjectType[] = "CameraObject";
|
||||||
static const char *LightObjectType = "LightObject";
|
static constexpr char LightObjectType[] = "LightObject";
|
||||||
static const char *TransformType = "Transform";
|
static constexpr char TransformType[] = "Transform";
|
||||||
static const char *MeshType = "Mesh";
|
static constexpr char MeshType[] = "Mesh";
|
||||||
static const char *VertexArrayType = "VertexArray";
|
static constexpr char VertexArrayType[] = "VertexArray";
|
||||||
static const char *IndexArrayType = "IndexArray";
|
static constexpr char IndexArrayType[] = "IndexArray";
|
||||||
static const char *MaterialType = "Material";
|
static constexpr char MaterialType[] = "Material";
|
||||||
static const char *ColorType = "Color";
|
static constexpr char ColorType[] = "Color";
|
||||||
static const char *ParamType = "Param";
|
static constexpr char ParamType[] = "Param";
|
||||||
static const char *TextureType = "Texture";
|
static constexpr char TextureType[] = "Texture";
|
||||||
static const char *AttenType = "Atten";
|
static constexpr char AttenType[] = "Atten";
|
||||||
|
|
||||||
static const char *DiffuseColorToken = "diffuse";
|
static constexpr char DiffuseColorToken[] = "diffuse";
|
||||||
static const char *SpecularColorToken = "specular";
|
static constexpr char SpecularColorToken[] = "specular";
|
||||||
static const char *EmissionColorToken = "emission";
|
static constexpr char EmissionColorToken[] = "emission";
|
||||||
|
|
||||||
static const char *DiffuseTextureToken = "diffuse";
|
static constexpr char DiffuseTextureToken[] = "diffuse";
|
||||||
static const char *DiffuseSpecularTextureToken = "specular";
|
static constexpr char DiffuseSpecularTextureToken[] = "specular";
|
||||||
static const char *SpecularPowerTextureToken = "specular_power";
|
static constexpr char SpecularPowerTextureToken[] = "specular_power";
|
||||||
static const char *EmissionTextureToken = "emission";
|
static constexpr char EmissionTextureToken[] = "emission";
|
||||||
static const char *OpacyTextureToken = "opacity";
|
static constexpr char OpacyTextureToken[] = "opacity";
|
||||||
static const char *TransparencyTextureToken = "transparency";
|
static constexpr char TransparencyTextureToken[] = "transparency";
|
||||||
static const char *NormalTextureToken = "normal";
|
static constexpr char NormalTextureToken[] = "normal";
|
||||||
|
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
NoneType = -1,
|
NoneType = -1,
|
||||||
|
@ -139,7 +139,7 @@ namespace Grammar {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx(-1);
|
int idx = -1;
|
||||||
for (size_t i = 0; i < 4; i++) {
|
for (size_t i = 0; i < 4; i++) {
|
||||||
if (ValidMetricToken[i] == token) {
|
if (ValidMetricToken[i] == token) {
|
||||||
idx = (int)i;
|
idx = (int)i;
|
||||||
|
|
|
@ -53,9 +53,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace ::Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Stanford Polygon Library (PLY) Importer",
|
"Stanford Polygon Library (PLY) Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -71,16 +71,16 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Internal stuff
|
// Internal stuff
|
||||||
namespace {
|
namespace {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Checks that property index is within range
|
// Checks that property index is within range
|
||||||
template <class T>
|
template <class T>
|
||||||
inline const T &GetProperty(const std::vector<T> &props, int idx) {
|
inline const T &GetProperty(const std::vector<T> &props, int idx) {
|
||||||
if (static_cast<size_t>(idx) >= props.size()) {
|
if (static_cast<size_t>(idx) >= props.size()) {
|
||||||
throw DeadlyImportError("Invalid .ply file: Property index is out of range.");
|
throw DeadlyImportError("Invalid .ply file: Property index is out of range.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return props[idx];
|
return props[idx];
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -92,10 +92,6 @@ PLYImporter::PLYImporter() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
PLYImporter::~PLYImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
|
@ -215,7 +211,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
throw DeadlyImportError("Invalid .ply file: Missing format specification");
|
throw DeadlyImportError("Invalid .ply file: Missing format specification");
|
||||||
}
|
}
|
||||||
|
|
||||||
//free the file buffer
|
// free the file buffer
|
||||||
streamedBuffer.close();
|
streamedBuffer.close();
|
||||||
|
|
||||||
if (mGeneratedMesh == nullptr) {
|
if (mGeneratedMesh == nullptr) {
|
||||||
|
@ -376,7 +372,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
|
||||||
haveNormal = true;
|
haveNormal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Colors
|
// Colors
|
||||||
aiColor4D cOut;
|
aiColor4D cOut;
|
||||||
bool haveColor = false;
|
bool haveColor = false;
|
||||||
if (0xFFFFFFFF != aiColors[0]) {
|
if (0xFFFFFFFF != aiColors[0]) {
|
||||||
|
@ -415,7 +411,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
|
||||||
haveColor = true;
|
haveColor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Texture coordinates
|
// Texture coordinates
|
||||||
aiVector3D tOut;
|
aiVector3D tOut;
|
||||||
tOut.z = 0;
|
tOut.z = 0;
|
||||||
bool haveTextureCoords = false;
|
bool haveTextureCoords = false;
|
||||||
|
@ -431,7 +427,7 @@ void PLYImporter::LoadVertex(const PLY::Element *pcElement, const PLY::ElementIn
|
||||||
haveTextureCoords = true;
|
haveTextureCoords = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//create aiMesh if needed
|
// create aiMesh if needed
|
||||||
if (nullptr == mGeneratedMesh) {
|
if (nullptr == mGeneratedMesh) {
|
||||||
mGeneratedMesh = new aiMesh();
|
mGeneratedMesh = new aiMesh();
|
||||||
mGeneratedMesh->mMaterialIndex = 0;
|
mGeneratedMesh->mMaterialIndex = 0;
|
||||||
|
@ -512,8 +508,8 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
|
||||||
bool bIsTriStrip = false;
|
bool bIsTriStrip = false;
|
||||||
|
|
||||||
// index of the material index property
|
// index of the material index property
|
||||||
//unsigned int iMaterialIndex = 0xFFFFFFFF;
|
// unsigned int iMaterialIndex = 0xFFFFFFFF;
|
||||||
//PLY::EDataType eType2 = EDT_Char;
|
// PLY::EDataType eType2 = EDT_Char;
|
||||||
|
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
unsigned int iTextureCoord = 0xFFFFFFFF;
|
unsigned int iTextureCoord = 0xFFFFFFFF;
|
||||||
|
@ -595,7 +591,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
|
||||||
if (0xFFFFFFFF != iTextureCoord) {
|
if (0xFFFFFFFF != iTextureCoord) {
|
||||||
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size();
|
const unsigned int iNum = (unsigned int)GetProperty(instElement->alProperties, iTextureCoord).avList.size();
|
||||||
|
|
||||||
//should be 6 coords
|
// should be 6 coords
|
||||||
std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
||||||
GetProperty(instElement->alProperties, iTextureCoord).avList.begin();
|
GetProperty(instElement->alProperties, iTextureCoord).avList.begin();
|
||||||
|
|
||||||
|
@ -625,7 +621,7 @@ void PLYImporter::LoadFace(const PLY::Element *pcElement, const PLY::ElementInst
|
||||||
// a value of -1 indicates a restart of the strip
|
// a value of -1 indicates a restart of the strip
|
||||||
bool flip = false;
|
bool flip = false;
|
||||||
const std::vector<PLY::PropertyInstance::ValueUnion> &quak = GetProperty(instElement->alProperties, iProperty).avList;
|
const std::vector<PLY::PropertyInstance::ValueUnion> &quak = GetProperty(instElement->alProperties, iProperty).avList;
|
||||||
//pvOut->reserve(pvOut->size() + quak.size() + (quak.size()>>2u)); //Limits memory consumption
|
// pvOut->reserve(pvOut->size() + quak.size() + (quak.size()>>2u)); //Limits memory consumption
|
||||||
|
|
||||||
int aiTable[2] = { -1, -1 };
|
int aiTable[2] = { -1, -1 };
|
||||||
for (std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator a = quak.begin(); a != quak.end(); ++a) {
|
for (std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator a = quak.begin(); a != quak.end(); ++a) {
|
||||||
|
@ -863,7 +859,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
|
||||||
const int two_sided = 1;
|
const int two_sided = 1;
|
||||||
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
||||||
|
|
||||||
//default texture
|
// default texture
|
||||||
if (!defaultTexture.empty()) {
|
if (!defaultTexture.empty()) {
|
||||||
const aiString name(defaultTexture.c_str());
|
const aiString name(defaultTexture.c_str());
|
||||||
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
|
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
|
||||||
|
@ -873,7 +869,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
|
||||||
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set to wireframe, so when using this material info we can switch to points rendering
|
// set to wireframe, so when using this material info we can switch to points rendering
|
||||||
if (pointsOnly) {
|
if (pointsOnly) {
|
||||||
const int wireframe = 1;
|
const int wireframe = 1;
|
||||||
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
||||||
|
@ -890,7 +886,7 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
|
||||||
int iMode = (int)aiShadingMode_Gouraud;
|
int iMode = (int)aiShadingMode_Gouraud;
|
||||||
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
//generate white material most 3D engine just multiply ambient / diffuse color with actual ambient / light color
|
// generate white material most 3D engine just multiply ambient / diffuse color with actual ambient / light color
|
||||||
aiColor3D clr;
|
aiColor3D clr;
|
||||||
clr.b = clr.g = clr.r = 1.0f;
|
clr.b = clr.g = clr.r = 1.0f;
|
||||||
pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
pcHelper->AddProperty<aiColor3D>(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||||
|
@ -906,13 +902,13 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
|
||||||
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
pcHelper->AddProperty(&two_sided, 1, AI_MATKEY_TWOSIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//default texture
|
// default texture
|
||||||
if (!defaultTexture.empty()) {
|
if (!defaultTexture.empty()) {
|
||||||
const aiString name(defaultTexture.c_str());
|
const aiString name(defaultTexture.c_str());
|
||||||
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
|
pcHelper->AddProperty(&name, _AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//set to wireframe, so when using this material info we can switch to points rendering
|
// set to wireframe, so when using this material info we can switch to points rendering
|
||||||
if (pointsOnly) {
|
if (pointsOnly) {
|
||||||
const int wireframe = 1;
|
const int wireframe = 1;
|
||||||
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
pcHelper->AddProperty(&wireframe, 1, AI_MATKEY_ENABLE_WIREFRAME);
|
||||||
|
@ -922,4 +918,6 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial *> *pvOut, std::string &de
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_PLY_IMPORTER
|
||||||
|
|
|
@ -65,7 +65,7 @@ using namespace PLY;
|
||||||
class PLYImporter : public BaseImporter {
|
class PLYImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
PLYImporter();
|
PLYImporter();
|
||||||
~PLYImporter() override;
|
~PLYImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Quake III BSP Importer",
|
"Quake III BSP Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -146,7 +146,11 @@ Q3BSPFileImporter::Q3BSPFileImporter() :
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
Q3BSPFileImporter::~Q3BSPFileImporter() {
|
Q3BSPFileImporter::~Q3BSPFileImporter() {
|
||||||
// Clear face-to-material map
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Q3BSPFileImporter::clear() {
|
||||||
for (FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
|
for (FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
|
||||||
const std::string &matName = it->first;
|
const std::string &matName = it->first;
|
||||||
if (!matName.empty()) {
|
if (!matName.empty()) {
|
||||||
|
@ -173,6 +177,7 @@ const aiImporterDesc *Q3BSPFileImporter::GetInfo() const {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Import method.
|
// Import method.
|
||||||
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene, IOSystem *ioHandler) {
|
void Q3BSPFileImporter::InternReadFile(const std::string &rFile, aiScene *scene, IOSystem *ioHandler) {
|
||||||
|
clear();
|
||||||
ZipArchiveIOSystem Archive(ioHandler, rFile);
|
ZipArchiveIOSystem Archive(ioHandler, rFile);
|
||||||
if (!Archive.isOpen()) {
|
if (!Archive.isOpen()) {
|
||||||
throw DeadlyImportError("Failed to open file ", rFile, ".");
|
throw DeadlyImportError("Failed to open file ", rFile, ".");
|
||||||
|
|
|
@ -81,6 +81,7 @@ protected:
|
||||||
using FaceMapIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator;
|
using FaceMapIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>* >::iterator;
|
||||||
using FaceMapConstIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator;
|
using FaceMapConstIt = std::map<std::string, std::vector<Q3BSP::sQ3BSPFace*>*>::const_iterator;
|
||||||
|
|
||||||
|
void clear();
|
||||||
const aiImporterDesc* GetInfo () const override;
|
const aiImporterDesc* GetInfo () const override;
|
||||||
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
||||||
void separateMapName( const std::string &rImportName, std::string &rArchiveName, std::string &rMapName );
|
void separateMapName( const std::string &rImportName, std::string &rArchiveName, std::string &rMapName );
|
||||||
|
|
|
@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Quick3D Importer",
|
"Quick3D Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -127,7 +127,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
std::vector<Material> materials;
|
std::vector<Material> materials;
|
||||||
try {
|
try {
|
||||||
materials.reserve(numMats);
|
materials.reserve(numMats);
|
||||||
} catch(const std::bad_alloc&) {
|
} catch (const std::bad_alloc &) {
|
||||||
ASSIMP_LOG_ERROR("Invalid alloc for materials.");
|
ASSIMP_LOG_ERROR("Invalid alloc for materials.");
|
||||||
throw DeadlyImportError("Invalid Quick3D-file, material allocation failed.");
|
throw DeadlyImportError("Invalid Quick3D-file, material allocation failed.");
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
std::vector<Mesh> meshes;
|
std::vector<Mesh> meshes;
|
||||||
try {
|
try {
|
||||||
meshes.reserve(numMeshes);
|
meshes.reserve(numMeshes);
|
||||||
} catch(const std::bad_alloc&) {
|
} catch (const std::bad_alloc &) {
|
||||||
ASSIMP_LOG_ERROR("Invalid alloc for meshes.");
|
ASSIMP_LOG_ERROR("Invalid alloc for meshes.");
|
||||||
throw DeadlyImportError("Invalid Quick3D-file, mesh allocation failed.");
|
throw DeadlyImportError("Invalid Quick3D-file, mesh allocation failed.");
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,6 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
if (minor > '0' && major == '3')
|
if (minor > '0' && major == '3')
|
||||||
stream.IncPtr(mesh.faces.size());
|
stream.IncPtr(mesh.faces.size());
|
||||||
}
|
}
|
||||||
// stream.IncPtr(4); // unknown value here
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// materials chunk
|
// materials chunk
|
||||||
|
@ -275,8 +274,6 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
// read the transparency
|
// read the transparency
|
||||||
mat.transparency = stream.GetF4();
|
mat.transparency = stream.GetF4();
|
||||||
|
|
||||||
// unknown value here
|
|
||||||
// stream.IncPtr(4);
|
|
||||||
// FIX: it could be the texture index ...
|
// FIX: it could be the texture index ...
|
||||||
mat.texIdx = (unsigned int)stream.GetI4();
|
mat.texIdx = (unsigned int)stream.GetI4();
|
||||||
}
|
}
|
||||||
|
@ -425,7 +422,8 @@ outer:
|
||||||
pScene->mMeshes = new aiMesh *[pScene->mNumMaterials];
|
pScene->mMeshes = new aiMesh *[pScene->mNumMaterials];
|
||||||
|
|
||||||
for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) {
|
for (unsigned int i = 0, real = 0; i < (unsigned int)materials.size(); ++i) {
|
||||||
if (fidx[i].empty()) continue;
|
if (fidx[i].empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
// Allocate a mesh and a material
|
// Allocate a mesh and a material
|
||||||
aiMesh *mesh = pScene->mMeshes[real] = new aiMesh();
|
aiMesh *mesh = pScene->mMeshes[real] = new aiMesh();
|
||||||
|
@ -548,14 +546,9 @@ outer:
|
||||||
// Now we need to attach the meshes to the root node of the scene
|
// Now we need to attach the meshes to the root node of the scene
|
||||||
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
||||||
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
|
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
|
||||||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||||
pScene->mRootNode->mMeshes[i] = i;
|
pScene->mRootNode->mMeshes[i] = i;
|
||||||
|
}
|
||||||
/*pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
|
||||||
1.f, 0.f, 0.f, 0.f,
|
|
||||||
0.f, -1.f,0.f, 0.f,
|
|
||||||
0.f, 0.f, 1.f, 0.f,
|
|
||||||
0.f, 0.f, 0.f, 1.f);*/
|
|
||||||
|
|
||||||
// Add cameras and light sources to the scene root node
|
// Add cameras and light sources to the scene root node
|
||||||
pScene->mRootNode->mNumChildren = pScene->mNumLights + pScene->mNumCameras;
|
pScene->mRootNode->mNumChildren = pScene->mNumLights + pScene->mNumCameras;
|
||||||
|
@ -577,4 +570,6 @@ outer:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_Q3D_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_Q3D_IMPORTER
|
||||||
|
|
|
@ -55,9 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Raw Importer",
|
"Raw Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -70,14 +70,6 @@ static const aiImporterDesc desc = {
|
||||||
"raw"
|
"raw"
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
RAWImporter::RAWImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
RAWImporter::~RAWImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool RAWImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
bool RAWImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
||||||
|
@ -295,4 +287,6 @@ void RAWImporter::InternReadFile(const std::string &pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_RAW_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_RAW_IMPORTER
|
||||||
|
|
|
@ -57,8 +57,8 @@ namespace Assimp {
|
||||||
*/
|
*/
|
||||||
class RAWImporter : public BaseImporter {
|
class RAWImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
RAWImporter();
|
RAWImporter() = default;
|
||||||
~RAWImporter() override;
|
~RAWImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -69,9 +69,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Silo SIB Importer",
|
"Silo SIB Importer",
|
||||||
"Richard Mitton (http://www.codersnotes.com/about)",
|
"Richard Mitton (http://www.codersnotes.com/about)",
|
||||||
"",
|
"",
|
||||||
|
@ -94,7 +94,7 @@ enum {
|
||||||
N
|
N
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::pair<uint32_t, uint32_t> SIBPair;
|
using SIBPair = std::pair<uint32_t, uint32_t>;
|
||||||
|
|
||||||
struct SIBEdge {
|
struct SIBEdge {
|
||||||
uint32_t faceA, faceB;
|
uint32_t faceA, faceB;
|
||||||
|
@ -199,15 +199,6 @@ static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
SIBImporter::SIBImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
SIBImporter::~SIBImporter() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
bool SIBImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
bool SIBImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
|
||||||
|
@ -882,4 +873,6 @@ void SIBImporter::InternReadFile(const std::string &pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_SIB_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_SIB_IMPORTER
|
||||||
|
|
|
@ -57,8 +57,8 @@ namespace Assimp {
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API SIBImporter : public BaseImporter {
|
class ASSIMP_API SIBImporter : public BaseImporter {
|
||||||
public:
|
public:
|
||||||
SIBImporter();
|
SIBImporter() = default;
|
||||||
~SIBImporter() override;
|
~SIBImporter() override = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -152,7 +152,7 @@ inline void DecompressVertex(aiVector3D &v, int32_t in) {
|
||||||
|
|
||||||
} // end namespace Unreal
|
} // end namespace Unreal
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"Unreal Mesh Importer",
|
"Unreal Mesh Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -62,11 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace glTF;
|
using namespace glTF;
|
||||||
|
|
||||||
//
|
static constexpr aiImporterDesc desc = {
|
||||||
// glTFImporter
|
|
||||||
//
|
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
|
||||||
"glTF Importer",
|
"glTF Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct Tangent {
|
||||||
// glTF2Importer
|
// glTF2Importer
|
||||||
//
|
//
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static constexpr aiImporterDesc desc = {
|
||||||
"glTF2 Importer",
|
"glTF2 Importer",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -63,6 +63,7 @@ struct aiImporterDesc;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
class Importer;
|
class Importer;
|
||||||
class IOSystem;
|
class IOSystem;
|
||||||
class BaseProcess;
|
class BaseProcess;
|
||||||
|
@ -73,6 +74,9 @@ class IOStream;
|
||||||
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
|
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
|
||||||
(string[1] << 16) + (string[2] << 8) + string[3]))
|
(string[1] << 16) + (string[2] << 8) + string[3]))
|
||||||
|
|
||||||
|
using UByteBuffer = std::vector<uint8_t>;
|
||||||
|
using ByteBuffer = std::vector<int8_t>;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
|
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
|
||||||
* for all importer worker classes.
|
* for all importer worker classes.
|
||||||
|
|
|
@ -70,7 +70,6 @@ namespace Assimp {
|
||||||
|
|
||||||
static const unsigned int BufferSize = 4096;
|
static const unsigned int BufferSize = 4096;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
AI_FORCE_INLINE bool IsUpper(char_t in) {
|
AI_FORCE_INLINE bool IsUpper(char_t in) {
|
||||||
|
|
Loading…
Reference in New Issue