Merge branch 'master' into x3d_pugi_migration_artenuvielle
commit
a82dc887fc
|
@ -511,7 +511,7 @@ bool AMFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.empty() || pCheckSig) {
|
if (extension.empty() || pCheckSig) {
|
||||||
const char *tokens[] = { "<amf" };
|
static const char * const tokens[] = { "<amf" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool ASEImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!extension.length() || cs) && pIOHandler) {
|
if ((!extension.length() || cs) && pIOHandler) {
|
||||||
const char *tokens[] = { "*3dsmax_asciiexport" };
|
static const char * const tokens[] = { "*3dsmax_asciiexport" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -100,7 +100,7 @@ bool BVHLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool cs)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((!extension.length() || cs) && pIOHandler) {
|
if ((!extension.length() || cs) && pIOHandler) {
|
||||||
const char *tokens[] = { "HIERARCHY" };
|
static const char * const tokens[] = { "HIERARCHY" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -113,8 +113,8 @@ BlenderImporter::~BlenderImporter() {
|
||||||
delete modifier_cache;
|
delete modifier_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *Tokens[] = { "BLENDER" };
|
static const char * const Tokens[] = { "BLENDER" };
|
||||||
static const char *TokensForSearch[] = { "blender" };
|
static const char * const TokensForSearch[] = { "blender" };
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
|
|
@ -110,7 +110,7 @@ bool COBImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((!extension.length() || checkSig) && pIOHandler) {
|
else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||||
const char *tokens[] = { "Caligary" };
|
static const char * const tokens[] = { "Caligary" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -99,7 +99,7 @@ bool CSMImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((checkSig || !extension.length()) && pIOHandler) {
|
if ((checkSig || !extension.length()) && pIOHandler) {
|
||||||
const char* tokens[] = {"$Filename"};
|
static const char * const tokens[] = {"$Filename"};
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -140,7 +140,7 @@ bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool
|
||||||
if (nullptr == pIOHandler) {
|
if (nullptr == pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static const char* tokens[] = {
|
static const char * const tokens[] = {
|
||||||
"<collada"
|
"<collada"
|
||||||
};
|
};
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
|
|
|
@ -130,8 +130,8 @@ bool DXFImporter::CanRead( const std::string& filename, IOSystem* pIOHandler, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( extension.empty() || checkSig ) {
|
if ( extension.empty() || checkSig ) {
|
||||||
const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
static const char * const pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
||||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
|
return SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -108,7 +108,7 @@ bool FBXImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
|
|
||||||
else if ((!extension.length() || checkSig) && pIOHandler) {
|
else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||||
// at least ASCII-FBX files usually have a 'FBX' somewhere in their head
|
// at least ASCII-FBX files usually have a 'FBX' somewhere in their head
|
||||||
const char *tokens[] = { "fbx" };
|
static const char * const tokens[] = { "fbx" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -137,9 +137,8 @@ bool IFCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
// note: this is the common identification for STEP-encoded files, so
|
// note: this is the common identification for STEP-encoded files, so
|
||||||
// it is only unambiguous as long as we don't support any further
|
// it is only unambiguous as long as we don't support any further
|
||||||
// file formats with STEP as their encoding.
|
// file formats with STEP as their encoding.
|
||||||
const char *tokens[] = { "ISO-10303-21" };
|
static const char * const tokens[] = { "ISO-10303-21" };
|
||||||
const bool found(SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1));
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ bool IRRImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
if (nullptr == pIOHandler) {
|
if (nullptr == pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char *tokens[] = { "irr_scene" };
|
static const char * const tokens[] = { "irr_scene" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool IRRMeshImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bo
|
||||||
* must return true here.
|
* must return true here.
|
||||||
*/
|
*/
|
||||||
if (!pIOHandler) return true;
|
if (!pIOHandler) return true;
|
||||||
const char *tokens[] = { "irrmesh" };
|
static const char * const tokens[] = { "irrmesh" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -109,7 +109,7 @@ bool MD5Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
if (!pIOHandler) {
|
if (!pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char *tokens[] = { "MD5Version" };
|
static const char * const tokens[] = { "MD5Version" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -696,14 +696,16 @@ struct GroupFrame
|
||||||
//! 0 = simple frame, !0 = group frame
|
//! 0 = simple frame, !0 = group frame
|
||||||
int32_t type;
|
int32_t type;
|
||||||
|
|
||||||
|
int32_t numframes;
|
||||||
|
|
||||||
//! Minimum vertex for all single frames
|
//! Minimum vertex for all single frames
|
||||||
Vertex min;
|
Vertex min;
|
||||||
|
|
||||||
//! Maximum vertex for all single frames
|
//! Maximum vertex for all single frames
|
||||||
Vertex max;
|
Vertex max;
|
||||||
|
|
||||||
//! Time for all single frames
|
//! List of times for all single frames
|
||||||
float *time;
|
float *times;
|
||||||
|
|
||||||
//! List of single frames
|
//! List of single frames
|
||||||
SimpleFrame *frames;
|
SimpleFrame *frames;
|
||||||
|
|
|
@ -439,8 +439,9 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
pcFirstFrame = (MDL::SimpleFrame *)&pcFrames->frame;
|
pcFirstFrame = (MDL::SimpleFrame *)&pcFrames->frame;
|
||||||
} else {
|
} else {
|
||||||
// get the first frame in the group
|
// get the first frame in the group
|
||||||
BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)pcFrames;
|
BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)szCurrent;
|
||||||
pcFirstFrame = &(pcFrames2->frames[0]);
|
pcFirstFrame = (MDL::SimpleFrame *)( szCurrent + sizeof(MDL::GroupFrame::type) + sizeof(MDL::GroupFrame::numframes)
|
||||||
|
+ sizeof(MDL::GroupFrame::min) + sizeof(MDL::GroupFrame::max) + sizeof(*MDL::GroupFrame::times) * pcFrames2->numframes );
|
||||||
}
|
}
|
||||||
BE_NCONST MDL::Vertex *pcVertices = (BE_NCONST MDL::Vertex *)((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
|
BE_NCONST MDL::Vertex *pcVertices = (BE_NCONST MDL::Vertex *)((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
|
||||||
VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts));
|
VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts));
|
||||||
|
|
|
@ -94,8 +94,8 @@ bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||||
return SimpleExtensionCheck(pFile, "pmx");
|
return SimpleExtensionCheck(pFile, "pmx");
|
||||||
} else {
|
} else {
|
||||||
// Check file Header
|
// Check file Header
|
||||||
static const char *pTokens[] = { "PMX " };
|
static const char * const pTokens[] = { "PMX " };
|
||||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool MS3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
if (!pIOHandler) {
|
if (!pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char* tokens[] = {"MS3D000000"};
|
static const char * const tokens[] = {"MS3D000000"};
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -91,7 +91,7 @@ bool NDOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ((checkSig || !extension.length()) && pIOHandler) {
|
if ((checkSig || !extension.length()) && pIOHandler) {
|
||||||
const char* tokens[] = {"nendo"};
|
static const char * const tokens[] = {"nendo"};
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1,5);
|
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1,5);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -92,7 +92,7 @@ bool OFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
else if (!extension.length() || checkSig)
|
else if (!extension.length() || checkSig)
|
||||||
{
|
{
|
||||||
if (!pIOHandler)return true;
|
if (!pIOHandler)return true;
|
||||||
const char* tokens[] = {"off"};
|
static const char * const tokens[] = {"off"};
|
||||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1,3);
|
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1,3);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -61,7 +61,8 @@ static const std::string EmissiveTexture1 = "map_emissive";
|
||||||
static const std::string EmissiveTexture2 = "map_Ke";
|
static const std::string EmissiveTexture2 = "map_Ke";
|
||||||
static const std::string BumpTexture1 = "map_bump";
|
static const std::string BumpTexture1 = "map_bump";
|
||||||
static const std::string BumpTexture2 = "bump";
|
static const std::string BumpTexture2 = "bump";
|
||||||
static const std::string NormalTexture = "map_Kn";
|
static const std::string NormalTextureV1 = "map_Kn";
|
||||||
|
static const std::string NormalTextureV2 = "norm";
|
||||||
static const std::string ReflectionTexture = "refl";
|
static const std::string ReflectionTexture = "refl";
|
||||||
static const std::string DisplacementTexture1 = "map_disp";
|
static const std::string DisplacementTexture1 = "map_disp";
|
||||||
static const std::string DisplacementTexture2 = "disp";
|
static const std::string DisplacementTexture2 = "disp";
|
||||||
|
@ -232,6 +233,12 @@ void ObjFileMtlImporter::getIlluminationModel(int &illum_model) {
|
||||||
// Loads a single float value.
|
// Loads a single float value.
|
||||||
void ObjFileMtlImporter::getFloatValue(ai_real &value) {
|
void ObjFileMtlImporter::getFloatValue(ai_real &value) {
|
||||||
m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
|
m_DataIt = CopyNextWord<DataArrayIt>(m_DataIt, m_DataItEnd, &m_buffer[0], BUFFERSIZE);
|
||||||
|
size_t len = std::strlen(&m_buffer[0]);
|
||||||
|
if (0 == len) {
|
||||||
|
value = 0.0f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
value = (ai_real)fast_atof(&m_buffer[0]);
|
value = (ai_real)fast_atof(&m_buffer[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +322,7 @@ void ObjFileMtlImporter::getTexture() {
|
||||||
// Bump texture
|
// Bump texture
|
||||||
out = &m_pModel->m_pCurrentMaterial->textureBump;
|
out = &m_pModel->m_pCurrentMaterial->textureBump;
|
||||||
clampIndex = ObjFile::Material::TextureBumpType;
|
clampIndex = ObjFile::Material::TextureBumpType;
|
||||||
} else if (!ASSIMP_strincmp(pPtr, NormalTexture.c_str(), static_cast<unsigned int>(NormalTexture.size()))) {
|
} else if (!ASSIMP_strincmp(pPtr, NormalTextureV1.c_str(), static_cast<unsigned int>(NormalTextureV1.size())) || !ASSIMP_strincmp(pPtr, NormalTextureV2.c_str(), static_cast<unsigned int>(NormalTextureV2.size()))) {
|
||||||
// Normal map
|
// Normal map
|
||||||
out = &m_pModel->m_pCurrentMaterial->textureNormal;
|
out = &m_pModel->m_pCurrentMaterial->textureNormal;
|
||||||
clampIndex = ObjFile::Material::TextureNormalType;
|
clampIndex = ObjFile::Material::TextureNormalType;
|
||||||
|
|
|
@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <assimp/DefaultIOSystem.h>
|
#include <assimp/DefaultIOSystem.h>
|
||||||
#include <assimp/ParsingUtils.h>
|
#include <assimp/ParsingUtils.h>
|
||||||
#include <assimp/material.h>
|
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -56,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
|
constexpr char ObjFileParser::DEFAULT_MATERIAL[];
|
||||||
|
|
||||||
ObjFileParser::ObjFileParser() :
|
ObjFileParser::ObjFileParser() :
|
||||||
m_DataIt(),
|
m_DataIt(),
|
||||||
|
|
|
@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define OBJ_FILEPARSER_H_INC
|
#define OBJ_FILEPARSER_H_INC
|
||||||
|
|
||||||
#include <assimp/IOStreamBuffer.h>
|
#include <assimp/IOStreamBuffer.h>
|
||||||
|
#include <assimp/material.h>
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
#include <assimp/vector2.h>
|
#include <assimp/vector2.h>
|
||||||
#include <assimp/vector3.h>
|
#include <assimp/vector3.h>
|
||||||
|
@ -140,7 +141,7 @@ private:
|
||||||
// because the class contains pointer to allocated memory
|
// because the class contains pointer to allocated memory
|
||||||
|
|
||||||
/// Default material name
|
/// Default material name
|
||||||
static const std::string DEFAULT_MATERIAL;
|
static constexpr char DEFAULT_MATERIAL[] = AI_DEFAULT_MATERIAL_NAME;
|
||||||
//! Iterator to current position in buffer
|
//! Iterator to current position in buffer
|
||||||
DataArrayIt m_DataIt;
|
DataArrayIt m_DataIt;
|
||||||
//! Iterator to end position of buffer
|
//! Iterator to end position of buffer
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2021, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -51,57 +51,62 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
/** @brief Returns true, if the last entry of the buffer is reached.
|
/**
|
||||||
* @param it Iterator of current position.
|
* @brief Returns true, if the last entry of the buffer is reached.
|
||||||
* @param end Iterator with end of buffer.
|
* @param[in] it Iterator of current position.
|
||||||
|
* @param[in] end Iterator with end of buffer.
|
||||||
* @return true, if the end of the buffer is reached.
|
* @return true, if the end of the buffer is reached.
|
||||||
*/
|
*/
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
inline bool isEndOfBuffer(char_t it, char_t end) {
|
inline bool isEndOfBuffer(char_t it, char_t end) {
|
||||||
if (it == end) {
|
if (it == end) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
--end;
|
|
||||||
}
|
}
|
||||||
|
--end;
|
||||||
|
|
||||||
return (it == end);
|
return (it == end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Returns next word separated by a space
|
/**
|
||||||
* @param pBuffer Pointer to data buffer
|
* @brief Returns next word separated by a space
|
||||||
* @param pEnd Pointer to end of buffer
|
* @param[in] pBuffer Pointer to data buffer
|
||||||
|
* @param[in] pEnd Pointer to end of buffer
|
||||||
* @return Pointer to next space
|
* @return Pointer to next space
|
||||||
*/
|
*/
|
||||||
template <class Char_T>
|
template <class Char_T>
|
||||||
inline Char_T getNextWord(Char_T pBuffer, Char_T pEnd) {
|
inline Char_T getNextWord(Char_T pBuffer, Char_T pEnd) {
|
||||||
while (!isEndOfBuffer(pBuffer, pEnd)) {
|
while (!isEndOfBuffer(pBuffer, pEnd)) {
|
||||||
if (!IsSpaceOrNewLine(*pBuffer) || IsLineEnd(*pBuffer)) {
|
if (!IsSpaceOrNewLine(*pBuffer) || IsLineEnd(*pBuffer)) {
|
||||||
//if ( *pBuffer != '\\' )
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pBuffer++;
|
++pBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBuffer;
|
return pBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Returns pointer a next token
|
/**
|
||||||
* @param pBuffer Pointer to data buffer
|
* @brief Returns pointer a next token
|
||||||
* @param pEnd Pointer to end of buffer
|
* @param[in] pBuffer Pointer to data buffer
|
||||||
|
* @param[in] pEnd Pointer to end of buffer
|
||||||
* @return Pointer to next token
|
* @return Pointer to next token
|
||||||
*/
|
*/
|
||||||
template <class Char_T>
|
template <class Char_T>
|
||||||
inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd) {
|
inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd) {
|
||||||
while (!isEndOfBuffer(pBuffer, pEnd)) {
|
while (!isEndOfBuffer(pBuffer, pEnd)) {
|
||||||
if (IsSpaceOrNewLine(*pBuffer))
|
if (IsSpaceOrNewLine(*pBuffer)) {
|
||||||
break;
|
break;
|
||||||
pBuffer++;
|
}
|
||||||
|
++pBuffer;
|
||||||
}
|
}
|
||||||
return getNextWord(pBuffer, pEnd);
|
return getNextWord(pBuffer, pEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Skips a line
|
/**
|
||||||
* @param it Iterator set to current position
|
* @brief Skips a line
|
||||||
* @param end Iterator set to end of scratch buffer for readout
|
* @param[in] it Iterator set to current position
|
||||||
* @param uiLine Current line number in format
|
* @param[in] end Iterator set to end of scratch buffer for readout
|
||||||
|
* @param[out] uiLine Current line number in format
|
||||||
* @return Current-iterator with new position
|
* @return Current-iterator with new position
|
||||||
*/
|
*/
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
|
@ -122,11 +127,12 @@ inline char_t skipLine(char_t it, char_t end, unsigned int &uiLine) {
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Get a name from the current line. Preserve space in the middle,
|
/**
|
||||||
|
* @brief Get a name from the current line. Preserve space in the middle,
|
||||||
* but trim it at the end.
|
* but trim it at the end.
|
||||||
* @param it set to current position
|
* @param[in] it set to current position
|
||||||
* @param end set to end of scratch buffer for readout
|
* @param[in] end set to end of scratch buffer for readout
|
||||||
* @param name Separated name
|
* @param[out] name Separated name
|
||||||
* @return Current-iterator with new position
|
* @return Current-iterator with new position
|
||||||
*/
|
*/
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
|
@ -150,15 +156,16 @@ inline char_t getName(char_t it, char_t end, std::string &name) {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
std::string strName(pStart, &(*it));
|
std::string strName(pStart, &(*it));
|
||||||
if (strName.empty())
|
if (!strName.empty()) {
|
||||||
return it;
|
|
||||||
else
|
|
||||||
name = strName;
|
name = strName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Get a name from the current line. Do not preserve space
|
/**
|
||||||
|
* @brief Get a name from the current line. Do not preserve space
|
||||||
* in the middle, but trim it at the end.
|
* in the middle, but trim it at the end.
|
||||||
* @param it set to current position
|
* @param it set to current position
|
||||||
* @param end set to end of scratch buffer for readout
|
* @param end set to end of scratch buffer for readout
|
||||||
|
@ -188,19 +195,19 @@ inline char_t getNameNoSpace(char_t it, char_t end, std::string &name) {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
std::string strName(pStart, &(*it));
|
std::string strName(pStart, &(*it));
|
||||||
if (strName.empty())
|
if (!strName.empty()) {
|
||||||
return it;
|
|
||||||
else
|
|
||||||
name = strName;
|
name = strName;
|
||||||
|
}
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Get next word from given line
|
/**
|
||||||
* @param it set to current position
|
* @brief Get next word from given line
|
||||||
* @param end set to end of scratch buffer for readout
|
* @param[in] it set to current position
|
||||||
* @param pBuffer Buffer for next word
|
* @param[in] end set to end of scratch buffer for readout
|
||||||
* @param length Buffer length
|
* @param[in] pBuffer Buffer for next word
|
||||||
|
* @param[in] length Buffer length
|
||||||
* @return Current-iterator with new position
|
* @return Current-iterator with new position
|
||||||
*/
|
*/
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
|
@ -209,19 +216,21 @@ inline char_t CopyNextWord(char_t it, char_t end, char *pBuffer, size_t length)
|
||||||
it = getNextWord<char_t>(it, end);
|
it = getNextWord<char_t>(it, end);
|
||||||
while (!IsSpaceOrNewLine(*it) && !isEndOfBuffer(it, end)) {
|
while (!IsSpaceOrNewLine(*it) && !isEndOfBuffer(it, end)) {
|
||||||
pBuffer[index] = *it;
|
pBuffer[index] = *it;
|
||||||
index++;
|
++index;
|
||||||
if (index == length - 1)
|
if (index == length - 1) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
pBuffer[index] = '\0';
|
pBuffer[index] = '\0';
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Get next float from given line
|
/**
|
||||||
* @param it set to current position
|
* @brief Get next float from given line
|
||||||
* @param end set to end of scratch buffer for readout
|
* @param[in] it set to current position
|
||||||
* @param value Separated float value.
|
* @param[in] end set to end of scratch buffer for readout
|
||||||
|
* @param[out] value Separated float value.
|
||||||
* @return Current-iterator with new position
|
* @return Current-iterator with new position
|
||||||
*/
|
*/
|
||||||
template <class char_t>
|
template <class char_t>
|
||||||
|
@ -234,21 +243,33 @@ inline char_t getFloat(char_t it, char_t end, ai_real &value) {
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Will remove white-spaces for a string.
|
||||||
|
* @param[in] str The string to clean
|
||||||
|
* @return The trimmed string.
|
||||||
|
*/
|
||||||
template <class string_type>
|
template <class string_type>
|
||||||
string_type trim_whitespaces(string_type str) {
|
inline string_type trim_whitespaces(string_type str) {
|
||||||
while (!str.empty() && IsSpace(str[0]))
|
while (!str.empty() && IsSpace(str[0])) {
|
||||||
str.erase(0);
|
str.erase(0);
|
||||||
while (!str.empty() && IsSpace(str[str.length() - 1]))
|
}
|
||||||
|
while (!str.empty() && IsSpace(str[str.length() - 1])) {
|
||||||
str.erase(str.length() - 1);
|
str.erase(str.length() - 1);
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks for a line-end.
|
||||||
|
* @param[in] it Current iterator in string.
|
||||||
|
* @param[in] end End of the string.
|
||||||
|
* @return The trimmed string.
|
||||||
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
bool hasLineEnd(T it, T end) {
|
bool hasLineEnd(T it, T end) {
|
||||||
bool hasLineEnd(false);
|
bool hasLineEnd = false;
|
||||||
while (!isEndOfBuffer(it, end)) {
|
while (!isEndOfBuffer(it, end)) {
|
||||||
it++;
|
++it;
|
||||||
if (IsLineEnd(it)) {
|
if (IsLineEnd(it)) {
|
||||||
hasLineEnd = true;
|
hasLineEnd = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -79,7 +79,7 @@ bool OgreImporter::CanRead(const std::string &pFile, Assimp::IOSystem *pIOHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EndsWith(pFile, ".mesh.xml", false)) {
|
if (EndsWith(pFile, ".mesh.xml", false)) {
|
||||||
const char *tokens[] = { "<mesh>" };
|
static const char * const tokens[] = { "<mesh>" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,8 +295,8 @@ bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, boo
|
||||||
if (!checkSig) {
|
if (!checkSig) {
|
||||||
canRead = SimpleExtensionCheck(file, "ogex");
|
canRead = SimpleExtensionCheck(file, "ogex");
|
||||||
} else {
|
} else {
|
||||||
static const char *token[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" };
|
static const char * const token[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" };
|
||||||
canRead = BaseImporter::SearchFileHeaderForToken(pIOHandler, file, token, 4);
|
canRead = SearchFileHeaderForToken(pIOHandler, file, token, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return canRead;
|
return canRead;
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
if (!pIOHandler) {
|
if (!pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static const char *tokens[] = {
|
static const char * const tokens[] = {
|
||||||
"ply"
|
"ply"
|
||||||
};
|
};
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
|
|
|
@ -92,7 +92,7 @@ bool Q3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
else if (!extension.length() || checkSig) {
|
else if (!extension.length() || checkSig) {
|
||||||
if (!pIOHandler)
|
if (!pIOHandler)
|
||||||
return true;
|
return true;
|
||||||
const char *tokens[] = { "quick3Do", "quick3Ds" };
|
static const char * const tokens[] = { "quick3Do", "quick3Ds" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -151,7 +151,7 @@ bool STLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
if (!pIOHandler) {
|
if (!pIOHandler) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char *tokens[] = { "STL", "solid" };
|
static const char * const tokens[] = { "STL", "solid" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, b
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *tokens[] = { "terragen" };
|
static const char * const tokens[] = { "terragen" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||||
|
|
||||||
if (extension == "xml" || checkSig) {
|
if (extension == "xml" || checkSig) {
|
||||||
ai_assert(pIOHandler != nullptr);
|
ai_assert(pIOHandler != nullptr);
|
||||||
const char *tokens[] = { "<world>", "<World>", "<WORLD>" };
|
static const char * const tokens[] = { "<world>", "<World>", "<WORLD>" };
|
||||||
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3);
|
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
/*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem *pIOHandler,
|
/*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem *pIOHandler,
|
||||||
const std::string &pFile,
|
const std::string &pFile,
|
||||||
const char **tokens,
|
const char * const *tokens,
|
||||||
unsigned int numTokens,
|
unsigned int numTokens,
|
||||||
unsigned int searchBytes /* = 200 */,
|
unsigned int searchBytes /* = 200 */,
|
||||||
bool tokensSol /* false */,
|
bool tokensSol /* false */,
|
||||||
|
|
|
@ -46,6 +46,7 @@ directly (unless you are adding new loaders), instead use the
|
||||||
corresponding preprocessor flag to selectively disable formats.
|
corresponding preprocessor flag to selectively disable formats.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assimp/anim.h>
|
||||||
#include <assimp/BaseImporter.h>
|
#include <assimp/BaseImporter.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
|
@ -89,7 +89,7 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) {
|
||||||
// Indeed embed
|
// Indeed embed
|
||||||
if (addTexture(pScene, path.data)) {
|
if (addTexture(pScene, path.data)) {
|
||||||
auto embeddedTextureId = pScene->mNumTextures - 1u;
|
auto embeddedTextureId = pScene->mNumTextures - 1u;
|
||||||
::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId);
|
path.length = ::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId);
|
||||||
material->AddProperty(&path, AI_MATKEY_TEXTURE(tt, texId));
|
material->AddProperty(&path, AI_MATKEY_TEXTURE(tt, texId));
|
||||||
embeddedTexturesCount++;
|
embeddedTexturesCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ public: // static utilities
|
||||||
static bool SearchFileHeaderForToken(
|
static bool SearchFileHeaderForToken(
|
||||||
IOSystem *pIOSystem,
|
IOSystem *pIOSystem,
|
||||||
const std::string &file,
|
const std::string &file,
|
||||||
const char **tokens,
|
const char * const *tokens,
|
||||||
unsigned int numTokens,
|
unsigned int numTokens,
|
||||||
unsigned int searchBytes = 200,
|
unsigned int searchBytes = 200,
|
||||||
bool tokensSol = false,
|
bool tokensSol = false,
|
||||||
|
|
Loading…
Reference in New Issue