Merge branch 'master' into jc3-dnase
This commit is contained in:
@@ -69,7 +69,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
|
||||
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
|
||||
std::string s = mScene->mMaterials[i].mName;
|
||||
for (std::string::iterator it = s.begin(); it != s.end(); ++it) {
|
||||
*it = static_cast<char>(::tolower(*it));
|
||||
*it = static_cast<char>(::tolower(static_cast<unsigned char>(*it)));
|
||||
}
|
||||
|
||||
if (std::string::npos == s.find("default")) continue;
|
||||
|
||||
@@ -143,7 +143,13 @@ void Discreet3DSImporter::SetupProperties(const Importer * /*pImp*/) {
|
||||
// Imports the given file into the given scene structure.
|
||||
void Discreet3DSImporter::InternReadFile(const std::string &pFile,
|
||||
aiScene *pScene, IOSystem *pIOHandler) {
|
||||
StreamReaderLE theStream(pIOHandler->Open(pFile, "rb"));
|
||||
|
||||
auto theFile = pIOHandler->Open(pFile, "rb");
|
||||
if (!theFile) {
|
||||
throw DeadlyImportError("3DS: Could not open ", pFile);
|
||||
}
|
||||
|
||||
StreamReaderLE theStream(theFile);
|
||||
|
||||
// We should have at least one chunk
|
||||
if (theStream.GetRemainingSize() < 16) {
|
||||
|
||||
@@ -205,7 +205,7 @@ void AMFImporter::ParseHelper_FixTruncatedFloatString(const char *pInStr, std::s
|
||||
}
|
||||
|
||||
static bool ParseHelper_Decode_Base64_IsBase64(const char pChar) {
|
||||
return (isalnum(pChar) || (pChar == '+') || (pChar == '/'));
|
||||
return (isalnum((unsigned char)pChar) || (pChar == '+') || (pChar == '/'));
|
||||
}
|
||||
|
||||
void AMFImporter::ParseHelper_Decode_Base64(const std::string &pInputBase64, std::vector<uint8_t> &pOutputData) const {
|
||||
@@ -268,7 +268,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) {
|
||||
mXmlParser = new XmlParser();
|
||||
if (!mXmlParser->parse(file.get())) {
|
||||
delete mXmlParser;
|
||||
throw DeadlyImportError("Failed to create XML reader for file" + pFile + ".");
|
||||
mXmlParser = nullptr;
|
||||
throw DeadlyImportError("Failed to create XML reader for file ", pFile, ".");
|
||||
}
|
||||
|
||||
// Start reading, search for root tag <amf>
|
||||
|
||||
@@ -498,6 +498,12 @@ void Parser::ParseLV1MaterialListBlock() {
|
||||
ParseLV2MaterialBlock(sMat);
|
||||
continue;
|
||||
}
|
||||
if( iDepth == 1 ){
|
||||
// CRUDE HACK: support missing brace after "Ascii Scene Exporter v2.51"
|
||||
LogWarning("Missing closing brace in material list");
|
||||
--filePtr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
AI_ASE_HANDLE_TOP_LEVEL_SECTION();
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ void AssbinImporter::ReadBinaryScene(IOStream *stream, aiScene *scene) {
|
||||
void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||
IOStream *stream = pIOHandler->Open(pFile, "rb");
|
||||
if (nullptr == stream) {
|
||||
return;
|
||||
throw DeadlyImportError("ASSBIN: Could not open ", pFile);
|
||||
}
|
||||
|
||||
// signature
|
||||
|
||||
@@ -359,7 +359,7 @@ void BVHLoader::ReadMotion(aiScene * /*pScene*/) {
|
||||
std::string BVHLoader::GetNextToken() {
|
||||
// skip any preceding whitespace
|
||||
while (mReader != mBuffer.end()) {
|
||||
if (!isspace(*mReader))
|
||||
if (!isspace((unsigned char)*mReader))
|
||||
break;
|
||||
|
||||
// count lines
|
||||
@@ -372,7 +372,7 @@ std::string BVHLoader::GetNextToken() {
|
||||
// collect all chars till the next whitespace. BVH is easy in respect to that.
|
||||
std::string token;
|
||||
while (mReader != mBuffer.end()) {
|
||||
if (isspace(*mReader))
|
||||
if (isspace((unsigned char)*mReader))
|
||||
break;
|
||||
|
||||
token.push_back(*mReader);
|
||||
|
||||
@@ -420,9 +420,9 @@ void BlenderImporter::ResolveImage(aiMaterial *out, const Material *mat, const M
|
||||
--s;
|
||||
}
|
||||
|
||||
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower(s[1]);
|
||||
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower(s[2]);
|
||||
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower(s[3]);
|
||||
curTex->achFormatHint[0] = s + 1 > e ? '\0' : (char)::tolower((unsigned char)s[1]);
|
||||
curTex->achFormatHint[1] = s + 2 > e ? '\0' : (char)::tolower((unsigned char)s[2]);
|
||||
curTex->achFormatHint[2] = s + 3 > e ? '\0' : (char)::tolower((unsigned char)s[3]);
|
||||
curTex->achFormatHint[3] = '\0';
|
||||
|
||||
// tex->mHeight = 0;
|
||||
|
||||
@@ -137,7 +137,13 @@ void COBImporter::SetupProperties(const Importer * /*pImp*/) {
|
||||
// Imports the given file into the given scene structure.
|
||||
void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||
COB::Scene scene;
|
||||
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE(pIOHandler->Open(pFile, "rb")));
|
||||
|
||||
auto file = pIOHandler->Open(pFile, "rb");
|
||||
if (!file) {
|
||||
ThrowException("Could not open " + pFile);
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE(file));
|
||||
|
||||
// check header
|
||||
char head[32];
|
||||
|
||||
@@ -234,7 +234,7 @@ void ColladaParser::UriDecodePath(aiString &ss) {
|
||||
#if defined(_MSC_VER)
|
||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||
#else
|
||||
if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
|
||||
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
|
||||
#endif
|
||||
--ss.length;
|
||||
::memmove(ss.data, ss.data + 1, ss.length);
|
||||
|
||||
@@ -82,7 +82,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||
|
||||
// lower-case shading because Blender (for example) writes "Phong"
|
||||
for (size_t i = 0; i < shading.length(); ++i) {
|
||||
shading[i] = static_cast<char>(tolower(shading[i]));
|
||||
shading[i] = static_cast<char>(tolower(static_cast<unsigned char>(shading[i])));
|
||||
}
|
||||
std::string templateName;
|
||||
if(shading == "phong") {
|
||||
|
||||
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "AssetLib/HMP/HMPLoader.h"
|
||||
#include "AssetLib/MD2/MD2FileData.h"
|
||||
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
@@ -151,12 +152,7 @@ void HMPImporter::InternReadFile(const std::string &pFile,
|
||||
InternReadFile_HMP7();
|
||||
} else {
|
||||
// Print the magic word to the logger
|
||||
char szBuffer[5];
|
||||
szBuffer[0] = ((char *)&iMagic)[0];
|
||||
szBuffer[1] = ((char *)&iMagic)[1];
|
||||
szBuffer[2] = ((char *)&iMagic)[2];
|
||||
szBuffer[3] = ((char *)&iMagic)[3];
|
||||
szBuffer[4] = '\0';
|
||||
std::string szBuffer = ai_str_toprintable((const char *)&iMagic, sizeof(iMagic));
|
||||
|
||||
delete[] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
|
||||
@@ -859,13 +859,13 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
|
||||
// Check whether we can read from the file
|
||||
if (file.get() == nullptr) {
|
||||
throw DeadlyImportError("Failed to open IRR file " + pFile);
|
||||
throw DeadlyImportError("Failed to open IRR file ", pFile);
|
||||
}
|
||||
|
||||
// Construct the irrXML parser
|
||||
XmlParser st;
|
||||
if (!st.parse( file.get() )) {
|
||||
return;
|
||||
throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
|
||||
}
|
||||
pugi::xml_node rootElement = st.getRootNode();
|
||||
|
||||
|
||||
@@ -135,12 +135,12 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
||||
|
||||
// Check whether we can read from the file
|
||||
if (file.get() == NULL)
|
||||
throw DeadlyImportError("Failed to open IRRMESH file " + pFile);
|
||||
throw DeadlyImportError("Failed to open IRRMESH file ", pFile);
|
||||
|
||||
// Construct the irrXML parser
|
||||
XmlParser parser;
|
||||
if (!parser.parse( file.get() )) {
|
||||
return;
|
||||
throw DeadlyImportError("XML parse error while loading IRRMESH file ", pFile);
|
||||
}
|
||||
XmlNode root = parser.getRootNode();
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
|
||||
*/
|
||||
std::unique_ptr<IOStream> pStream(pIOHandler->Open(pFile, "rb"));
|
||||
unsigned char data[4];
|
||||
if (4 != pStream->Read(data, 1, 4)) {
|
||||
if (!pStream || 4 != pStream->Read(data, 1, 4)) {
|
||||
return false;
|
||||
}
|
||||
return !memcmp(data, "3DMO", 4) /* bin */
|
||||
|
||||
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -148,46 +149,39 @@ void MD2Importer::ValidateHeader( )
|
||||
if (m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
|
||||
m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
|
||||
{
|
||||
char szBuffer[5];
|
||||
szBuffer[0] = ((char*)&m_pcHeader->magic)[0];
|
||||
szBuffer[1] = ((char*)&m_pcHeader->magic)[1];
|
||||
szBuffer[2] = ((char*)&m_pcHeader->magic)[2];
|
||||
szBuffer[3] = ((char*)&m_pcHeader->magic)[3];
|
||||
szBuffer[4] = '\0';
|
||||
|
||||
throw DeadlyImportError("Invalid MD2 magic word: should be IDP2, the "
|
||||
"magic word found is " + std::string(szBuffer));
|
||||
throw DeadlyImportError("Invalid MD2 magic word: expected IDP2, found ",
|
||||
ai_str_toprintable((char *)&m_pcHeader->magic, 4));
|
||||
}
|
||||
|
||||
// check file format version
|
||||
if (m_pcHeader->version != 8)
|
||||
ASSIMP_LOG_WARN( "Unsupported md2 file version. Continuing happily ...");
|
||||
ASSIMP_LOG_WARN( "Unsupported MD2 file version. Continuing happily ...");
|
||||
|
||||
// check some values whether they are valid
|
||||
if (0 == m_pcHeader->numFrames)
|
||||
throw DeadlyImportError( "Invalid md2 file: NUM_FRAMES is 0");
|
||||
throw DeadlyImportError( "Invalid MD2 file: NUM_FRAMES is 0");
|
||||
|
||||
if (m_pcHeader->offsetEnd > (uint32_t)fileSize)
|
||||
throw DeadlyImportError( "Invalid md2 file: File is too small");
|
||||
throw DeadlyImportError( "Invalid MD2 file: File is too small");
|
||||
|
||||
if (m_pcHeader->numSkins > AI_MAX_ALLOC(MD2::Skin)) {
|
||||
throw DeadlyImportError("Invalid MD2 header: too many skins, would overflow");
|
||||
throw DeadlyImportError("Invalid MD2 header: Too many skins, would overflow");
|
||||
}
|
||||
|
||||
if (m_pcHeader->numVertices > AI_MAX_ALLOC(MD2::Vertex)) {
|
||||
throw DeadlyImportError("Invalid MD2 header: too many vertices, would overflow");
|
||||
throw DeadlyImportError("Invalid MD2 header: Too many vertices, would overflow");
|
||||
}
|
||||
|
||||
if (m_pcHeader->numTexCoords > AI_MAX_ALLOC(MD2::TexCoord)) {
|
||||
throw DeadlyImportError("Invalid MD2 header: too many texcoords, would overflow");
|
||||
throw DeadlyImportError("Invalid MD2 header: Too many texcoords, would overflow");
|
||||
}
|
||||
|
||||
if (m_pcHeader->numTriangles > AI_MAX_ALLOC(MD2::Triangle)) {
|
||||
throw DeadlyImportError("Invalid MD2 header: too many triangles, would overflow");
|
||||
throw DeadlyImportError("Invalid MD2 header: Too many triangles, would overflow");
|
||||
}
|
||||
|
||||
if (m_pcHeader->numFrames > AI_MAX_ALLOC(MD2::Frame)) {
|
||||
throw DeadlyImportError("Invalid MD2 header: too many frames, would overflow");
|
||||
throw DeadlyImportError("Invalid MD2 header: Too many frames, would overflow");
|
||||
}
|
||||
|
||||
// -1 because Frame already contains one
|
||||
@@ -199,7 +193,7 @@ void MD2Importer::ValidateHeader( )
|
||||
m_pcHeader->offsetFrames + m_pcHeader->numFrames * frameSize >= fileSize ||
|
||||
m_pcHeader->offsetEnd > fileSize)
|
||||
{
|
||||
throw DeadlyImportError("Invalid MD2 header: some offsets are outside the file");
|
||||
throw DeadlyImportError("Invalid MD2 header: Some offsets are outside the file");
|
||||
}
|
||||
|
||||
if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
|
||||
@@ -210,7 +204,7 @@ void MD2Importer::ValidateHeader( )
|
||||
ASSIMP_LOG_WARN("The model contains more vertices than Quake 2 supports");
|
||||
|
||||
if (m_pcHeader->numFrames <= configFrameID )
|
||||
throw DeadlyImportError("The requested frame is not existing the file");
|
||||
throw DeadlyImportError("MD2: The requested frame (", configFrameID, ") does not exist in the file");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -702,7 +702,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
}
|
||||
filename = mFile.substr(s), path = mFile.substr(0, s);
|
||||
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
|
||||
*it = static_cast<char>(tolower(*it));
|
||||
*it = static_cast<char>(tolower(static_cast<unsigned char>(*it)));
|
||||
}
|
||||
|
||||
// Load multi-part model file, if necessary
|
||||
|
||||
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -143,16 +144,8 @@ void MDCImporter::ValidateHeader() {
|
||||
|
||||
if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
|
||||
pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
|
||||
char szBuffer[5];
|
||||
szBuffer[0] = ((char *)&pcHeader->ulIdent)[0];
|
||||
szBuffer[1] = ((char *)&pcHeader->ulIdent)[1];
|
||||
szBuffer[2] = ((char *)&pcHeader->ulIdent)[2];
|
||||
szBuffer[3] = ((char *)&pcHeader->ulIdent)[3];
|
||||
szBuffer[4] = '\0';
|
||||
|
||||
throw DeadlyImportError("Invalid MDC magic word: should be IDPC, the "
|
||||
"magic word found is " +
|
||||
std::string(szBuffer));
|
||||
throw DeadlyImportError("Invalid MDC magic word: expected IDPC, found ",
|
||||
ai_str_toprintable((char *)&pcHeader->ulIdent, 4));
|
||||
}
|
||||
|
||||
if (pcHeader->ulVersion != AI_MDC_VERSION) {
|
||||
@@ -465,6 +458,13 @@ void MDCImporter::InternReadFile(
|
||||
pcMat->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
}
|
||||
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(
|
||||
1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.f, 1.f, 0.f,
|
||||
0.f, -1.f, 0.f, 0.f,
|
||||
0.f, 0.f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_MDC_IMPORTER
|
||||
|
||||
@@ -252,7 +252,7 @@ void MDLImporter::InternReadFile(const std::string &pFile,
|
||||
} else {
|
||||
// print the magic word to the log file
|
||||
throw DeadlyImportError("Unknown MDL subformat ", pFile,
|
||||
". Magic word (", std::string((char *)&iMagicWord, 4), ") is not known");
|
||||
". Magic word (", ai_str_toprintable((const char *)&iMagicWord, sizeof(iMagicWord)), ") is not known");
|
||||
}
|
||||
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
|
||||
@@ -478,8 +478,7 @@ namespace pmx
|
||||
|
||||
void PmxSoftBody::Read(std::istream * /*stream*/, PmxSetting * /*setting*/)
|
||||
{
|
||||
std::cerr << "Not Implemented Exception" << std::endl;
|
||||
throw DeadlyImportError("MMD: Not Implemented Exception");
|
||||
throw DeadlyImportError("MMD: Soft Body support is not implemented.");
|
||||
}
|
||||
|
||||
void PmxModel::Init()
|
||||
@@ -516,15 +515,13 @@ namespace pmx
|
||||
char magic[4];
|
||||
stream->read((char*) magic, sizeof(char) * 4);
|
||||
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
|
||||
{
|
||||
std::cerr << "invalid magic number." << std::endl;
|
||||
throw DeadlyImportError("MMD: invalid magic number.");
|
||||
{
|
||||
throw DeadlyImportError("MMD: Invalid magic number.");
|
||||
}
|
||||
stream->read((char*) &version, sizeof(float));
|
||||
if (version != 2.0f && version != 2.1f)
|
||||
{
|
||||
std::cerr << "this is not ver2.0 or ver2.1 but " << version << "." << std::endl;
|
||||
throw DeadlyImportError("MMD: this is not ver2.0 or ver2.1 but ", ai_to_string(version));
|
||||
throw DeadlyImportError("MMD: Unsupported version (must be 2.0 or 2.1): ", ai_to_string(version));
|
||||
}
|
||||
this->setting.Read(stream);
|
||||
|
||||
|
||||
@@ -215,7 +215,12 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints, ai
|
||||
void MS3DImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
||||
|
||||
auto file = pIOHandler->Open(pFile, "rb");
|
||||
if (!file)
|
||||
throw DeadlyImportError("MS3D: Could not open ", pFile);
|
||||
|
||||
StreamReaderLE stream(file);
|
||||
|
||||
// CanRead() should have done this already
|
||||
char head[10];
|
||||
|
||||
@@ -116,7 +116,13 @@ void NDOImporter::SetupProperties(const Importer* /*pImp*/)
|
||||
void NDOImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
StreamReaderBE reader(pIOHandler->Open( pFile, "rb"));
|
||||
|
||||
auto file = pIOHandler->Open( pFile, "rb");
|
||||
if (!file) {
|
||||
throw DeadlyImportError("Nendo: Could not open ", pFile);
|
||||
}
|
||||
|
||||
StreamReaderBE reader(file);
|
||||
|
||||
// first 9 bytes are nendo file format ("nendo 1.n")
|
||||
const char* head = (const char*)reader.GetPtr();
|
||||
|
||||
@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
@@ -223,6 +224,18 @@ static void propId2StdString(Property *prop, std::string &name, std::string &key
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
static void logDDLParserMessage (LogSeverity severity, const std::string &rawmsg) {
|
||||
std::string msg = ai_str_toprintable(rawmsg);
|
||||
switch (severity) {
|
||||
case ddl_debug_msg: ASSIMP_LOG_DEBUG(msg); break;
|
||||
case ddl_info_msg: ASSIMP_LOG_INFO(msg); break;
|
||||
case ddl_warn_msg: ASSIMP_LOG_WARN(msg); break;
|
||||
case ddl_error_msg: ASSIMP_LOG_ERROR(msg); break;
|
||||
default: ASSIMP_LOG_VERBOSE_DEBUG(msg); break;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
OpenGEXImporter::VertexContainer::VertexContainer() :
|
||||
m_numColors(0), m_colors(nullptr), m_numUVComps(), m_textureCoords() {
|
||||
@@ -306,6 +319,7 @@ void OpenGEXImporter::InternReadFile(const std::string &filename, aiScene *pScen
|
||||
pIOHandler->Close(file);
|
||||
|
||||
OpenDDLParser myParser;
|
||||
myParser.setLogCallback(&logDDLParserMessage);
|
||||
myParser.setBuffer(&buffer[0], buffer.size());
|
||||
bool success(myParser.parse());
|
||||
if (success) {
|
||||
|
||||
@@ -172,7 +172,7 @@ void PLYImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
(headerCheck[1] != 'L' && headerCheck[1] != 'l') ||
|
||||
(headerCheck[2] != 'Y' && headerCheck[2] != 'y')) {
|
||||
streamedBuffer.close();
|
||||
throw DeadlyImportError("Invalid .ply file: Magic number \'ply\' is no there");
|
||||
throw DeadlyImportError("Invalid .ply file: Incorrect magic number (expected 'ply' or 'PLY').");
|
||||
}
|
||||
|
||||
std::vector<char> mBuffer2;
|
||||
|
||||
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// internal headers
|
||||
#include "Q3DLoader.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
@@ -106,7 +107,12 @@ const aiImporterDesc *Q3DImporter::GetInfo() const {
|
||||
// Imports the given file into the given scene structure.
|
||||
void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||
aiScene *pScene, IOSystem *pIOHandler) {
|
||||
StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
|
||||
|
||||
auto file = pIOHandler->Open(pFile, "rb");
|
||||
if (!file)
|
||||
throw DeadlyImportError("Quick3D: Could not open ", pFile);
|
||||
|
||||
StreamReaderLE stream(file);
|
||||
|
||||
// The header is 22 bytes large
|
||||
if (stream.GetRemainingSize() < 22)
|
||||
@@ -115,7 +121,7 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||
// Check the file's signature
|
||||
if (ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Do", 8) &&
|
||||
ASSIMP_strincmp((const char *)stream.GetPtr(), "quick3Ds", 8)) {
|
||||
throw DeadlyImportError("Not a Quick3D file. Signature string is: ", std::string((const char *)stream.GetPtr(), 8));
|
||||
throw DeadlyImportError("Not a Quick3D file. Signature string is: ", ai_str_toprintable((const char *)stream.GetPtr(), 8));
|
||||
}
|
||||
|
||||
// Print the file format version
|
||||
|
||||
@@ -68,6 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -166,14 +167,14 @@ static aiColor3D ReadColor(StreamReaderLE *stream) {
|
||||
}
|
||||
|
||||
static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) {
|
||||
char temp[5] = {
|
||||
char temp[4] = {
|
||||
static_cast<char>((chunk.Tag >> 24) & 0xff),
|
||||
static_cast<char>((chunk.Tag >> 16) & 0xff),
|
||||
static_cast<char>((chunk.Tag >> 8) & 0xff),
|
||||
static_cast<char>(chunk.Tag & 0xff), '\0'
|
||||
static_cast<char>(chunk.Tag & 0xff)
|
||||
};
|
||||
|
||||
ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '", temp, "' chunk."));
|
||||
ASSIMP_LOG_WARN((Formatter::format(), "SIB: Skipping unknown '", ai_str_toprintable(temp, 4), "' chunk."));
|
||||
}
|
||||
|
||||
// Reads a UTF-16LE string and returns it at UTF-8.
|
||||
@@ -804,7 +805,12 @@ static void ReadScene(SIB *sib, StreamReaderLE *stream) {
|
||||
// Imports the given file into the given scene structure.
|
||||
void SIBImporter::InternReadFile(const std::string &pFile,
|
||||
aiScene *pScene, IOSystem *pIOHandler) {
|
||||
StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
|
||||
|
||||
auto file = pIOHandler->Open(pFile, "rb");
|
||||
if (!file)
|
||||
throw DeadlyImportError("SIB: Could not open ", pFile);
|
||||
|
||||
StreamReaderLE stream(file);
|
||||
|
||||
// We should have at least one chunk
|
||||
if (stream.GetRemainingSize() < 16)
|
||||
|
||||
@@ -667,8 +667,8 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
||||
|
||||
// convert to lower case for easier comparison
|
||||
for ( unsigned int c = 0; c < sz.length(); ++c ) {
|
||||
if ( isalpha( sz[ c ] ) ) {
|
||||
sz[ c ] = (char) tolower( sz[ c ] );
|
||||
if ( isalpha( (unsigned char) sz[ c ] ) ) {
|
||||
sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1245,13 +1245,13 @@ unsigned int XFileParser::ReadInt() {
|
||||
}
|
||||
|
||||
// at least one digit expected
|
||||
if (!isdigit(*mP))
|
||||
if (!isdigit((unsigned char)*mP))
|
||||
ThrowException("Number expected.");
|
||||
|
||||
// read digits
|
||||
unsigned int number = 0;
|
||||
while (mP < mEnd) {
|
||||
if (!isdigit(*mP))
|
||||
if (!isdigit((unsigned char)*mP))
|
||||
break;
|
||||
number = number * 10 + (*mP - 48);
|
||||
mP++;
|
||||
|
||||
@@ -200,7 +200,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
// parse the XML file
|
||||
mXmlParser = new XmlParser;
|
||||
if (!mXmlParser->parse(stream.get())) {
|
||||
return;
|
||||
throw DeadlyImportError("XML parse error while loading XGL file ", pFile);
|
||||
}
|
||||
|
||||
TempScope scope;
|
||||
|
||||
Reference in New Issue
Block a user