2008-05-09 17:24:28 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
2008-05-22 10:20:31 +00:00
|
|
|
Open Asset Import Library (ASSIMP)
|
2008-05-09 17:24:28 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2010-04-10 15:30:22 +00:00
|
|
|
Copyright (c) 2006-2010, ASSIMP Development Team
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the ASSIMP team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the ASSIMP Development Team.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
/** @file BaseImporter.cpp
|
|
|
|
* @brief Implementation of BaseImporter
|
|
|
|
*/
|
2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
#include "AssimpPCH.h"
|
2008-05-05 12:36:31 +00:00
|
|
|
#include "BaseImporter.h"
|
2009-04-10 21:59:22 +00:00
|
|
|
#include "FileSystemFilter.h"
|
2008-06-15 10:27:08 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
using namespace Assimp;
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Constructor to be privately used by Importer
|
|
|
|
BaseImporter::BaseImporter()
|
|
|
|
{
|
|
|
|
// nothing to do here
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Destructor, private as well
|
|
|
|
BaseImporter::~BaseImporter()
|
|
|
|
{
|
|
|
|
// nothing to do here
|
|
|
|
}
|
|
|
|
|
2010-03-18 17:00:12 +00:00
|
|
|
template <typename T>
|
|
|
|
struct tinyguard
|
|
|
|
{
|
|
|
|
tinyguard(T* obj) : obj(obj), mdismiss() {}
|
|
|
|
~tinyguard () throw() {if (!mdismiss) {delete obj;} obj = NULL;}
|
|
|
|
|
|
|
|
void dismiss() {
|
|
|
|
mdismiss=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator T*() {
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* obj;
|
|
|
|
bool mdismiss;
|
|
|
|
};
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Imports the given file and returns the imported data.
|
|
|
|
aiScene* BaseImporter::ReadFile( const std::string& pFile, IOSystem* pIOHandler)
|
|
|
|
{
|
2009-04-10 21:59:22 +00:00
|
|
|
// Construct a file system filter to improve our success ratio reading external files
|
|
|
|
FileSystemFilter filter(pFile,pIOHandler);
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// create a scene object to hold the data
|
2010-03-18 17:00:12 +00:00
|
|
|
tinyguard<aiScene> sc(new aiScene());
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// dispatch importing
|
|
|
|
try
|
|
|
|
{
|
2010-03-18 17:00:12 +00:00
|
|
|
InternReadFile( pFile, sc, &filter);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2010-03-18 17:00:12 +00:00
|
|
|
} catch( const std::exception& err ) {
|
|
|
|
// extract error description
|
|
|
|
mErrorText = err.what();
|
2008-05-09 17:24:28 +00:00
|
|
|
DefaultLogger::get()->error(mErrorText);
|
2010-03-18 17:00:12 +00:00
|
|
|
return NULL;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// return what we gathered from the import.
|
2010-03-18 17:00:12 +00:00
|
|
|
sc.dismiss();
|
|
|
|
return sc;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-06-15 10:27:08 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-08-08 18:34:14 +00:00
|
|
|
void BaseImporter::SetupProperties(const Importer* pImp)
|
2008-06-15 10:27:08 +00:00
|
|
|
{
|
2008-08-08 18:34:14 +00:00
|
|
|
// the default implementation does nothing
|
2008-06-15 10:27:08 +00:00
|
|
|
}
|
2008-08-08 18:34:14 +00:00
|
|
|
|
2008-10-24 20:37:54 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
/*static*/ bool BaseImporter::SearchFileHeaderForToken(IOSystem* pIOHandler,
|
2008-10-24 20:37:54 +00:00
|
|
|
const std::string& pFile,
|
|
|
|
const char** tokens,
|
|
|
|
unsigned int numTokens,
|
|
|
|
unsigned int searchBytes /* = 200 */)
|
|
|
|
{
|
2009-04-27 19:58:34 +00:00
|
|
|
ai_assert(NULL != tokens && 0 != numTokens && 0 != searchBytes);
|
|
|
|
if (!pIOHandler)
|
|
|
|
return false;
|
2008-10-24 20:37:54 +00:00
|
|
|
|
|
|
|
boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
2009-04-27 19:58:34 +00:00
|
|
|
if (pStream.get() ) {
|
2008-10-24 20:37:54 +00:00
|
|
|
// read 200 characters from the file
|
2008-11-16 21:56:45 +00:00
|
|
|
boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
2008-10-24 20:37:54 +00:00
|
|
|
char* buffer = _buffer.get();
|
|
|
|
|
|
|
|
unsigned int read = (unsigned int)pStream->Read(buffer,1,searchBytes);
|
|
|
|
if (!read)return false;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < read;++i)
|
|
|
|
buffer[i] = ::tolower(buffer[i]);
|
|
|
|
|
|
|
|
// It is not a proper handling of unicode files here ...
|
|
|
|
// ehm ... but it works in most cases.
|
|
|
|
char* cur = buffer,*cur2 = buffer,*end = &buffer[read];
|
2009-04-27 19:58:34 +00:00
|
|
|
while (cur != end) {
|
|
|
|
if (*cur)
|
|
|
|
*cur2++ = *cur;
|
2008-10-24 20:37:54 +00:00
|
|
|
++cur;
|
|
|
|
}
|
|
|
|
*cur2 = '\0';
|
|
|
|
|
2009-04-27 19:58:34 +00:00
|
|
|
for (unsigned int i = 0; i < numTokens;++i) {
|
2008-10-24 20:37:54 +00:00
|
|
|
ai_assert(NULL != tokens[i]);
|
2009-04-27 19:58:34 +00:00
|
|
|
|
|
|
|
if (::strstr(buffer,tokens[i])) {
|
2009-01-10 17:58:06 +00:00
|
|
|
DefaultLogger::get()->debug(std::string("Found positive match for header keyword: ") + tokens[i]);
|
|
|
|
return true;
|
|
|
|
}
|
2008-10-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Simple check for file extension
|
|
|
|
/*static*/ bool BaseImporter::SimpleExtensionCheck (const std::string& pFile,
|
|
|
|
const char* ext0,
|
|
|
|
const char* ext1,
|
|
|
|
const char* ext2)
|
|
|
|
{
|
|
|
|
std::string::size_type pos = pFile.find_last_of('.');
|
|
|
|
|
|
|
|
// no file extension - can't read
|
|
|
|
if( pos == std::string::npos)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const char* ext_real = & pFile[ pos+1 ];
|
|
|
|
if( !ASSIMP_stricmp(ext_real,ext0) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// check for other, optional, file extensions
|
|
|
|
if (ext1 && !ASSIMP_stricmp(ext_real,ext1))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (ext2 && !ASSIMP_stricmp(ext_real,ext2))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Get file extension from path
|
|
|
|
/*static*/ std::string BaseImporter::GetExtension (const std::string& pFile)
|
|
|
|
{
|
|
|
|
std::string::size_type pos = pFile.find_last_of('.');
|
|
|
|
|
|
|
|
// no file extension at all
|
|
|
|
if( pos == std::string::npos)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
std::string ret = pFile.substr(pos+1);
|
|
|
|
std::transform(ret.begin(),ret.end(),ret.begin(),::tolower); // thanks to Andy Maloney for the hint
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Check for magic bytes at the beginning of the file.
|
|
|
|
/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
|
|
|
|
const void* _magic, unsigned int num, unsigned int offset, unsigned int size)
|
|
|
|
{
|
2009-04-27 19:58:34 +00:00
|
|
|
ai_assert(size <= 16 && _magic);
|
|
|
|
|
2009-08-21 22:49:58 +00:00
|
|
|
if (!pIOHandler) {
|
2009-04-27 19:58:34 +00:00
|
|
|
return false;
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
2010-02-06 23:52:41 +00:00
|
|
|
union {
|
|
|
|
const char* magic;
|
|
|
|
const uint16_t* magic_u16;
|
|
|
|
const uint32_t* magic_u32;
|
|
|
|
};
|
|
|
|
magic = reinterpret_cast<const char*>(_magic);
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
2009-04-27 19:58:34 +00:00
|
|
|
if (pStream.get() ) {
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
// skip to offset
|
|
|
|
pStream->Seek(offset,aiOrigin_SET);
|
|
|
|
|
|
|
|
// read 'size' characters from the file
|
2010-02-06 23:52:41 +00:00
|
|
|
union {
|
|
|
|
char data[16];
|
|
|
|
uint16_t data_u16[8];
|
|
|
|
uint32_t data_u32[4];
|
|
|
|
};
|
2009-08-21 22:49:58 +00:00
|
|
|
if(size != pStream->Read(data,1,size)) {
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return false;
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < num; ++i) {
|
|
|
|
// also check against big endian versions of tokens with size 2,4
|
|
|
|
// that's just for convinience, the chance that we cause conflicts
|
|
|
|
// is quite low and it can save some lines and prevent nasty bugs
|
|
|
|
if (2 == size) {
|
2010-02-06 23:52:41 +00:00
|
|
|
uint16_t rev = *magic_u16;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
ByteSwap::Swap(&rev);
|
2010-02-06 23:52:41 +00:00
|
|
|
if (data_u16[0] == *magic_u16 || data_u16[0] == rev) {
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return true;
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
}
|
|
|
|
else if (4 == size) {
|
2010-02-06 23:52:41 +00:00
|
|
|
uint32_t rev = *magic_u32;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
ByteSwap::Swap(&rev);
|
2010-02-06 23:52:41 +00:00
|
|
|
if (data_u32[0] == *magic_u32 || data_u32[0] == rev) {
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return true;
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// any length ... just compare
|
2009-08-21 22:49:58 +00:00
|
|
|
if(!memcmp(magic,data,size)) {
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return true;
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
}
|
|
|
|
magic += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-13 22:31:15 +00:00
|
|
|
|
2009-08-21 22:49:58 +00:00
|
|
|
#include "../contrib/ConvertUTF/ConvertUTF.h"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void ReportResult(ConversionResult res)
|
|
|
|
{
|
|
|
|
if(res == sourceExhausted) {
|
2010-02-06 23:52:41 +00:00
|
|
|
DefaultLogger::get()->error("Source ends with incomplete character sequence, transformation to UTF-8 fails");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
|
|
|
else if(res == sourceIllegal) {
|
2010-02-06 23:52:41 +00:00
|
|
|
DefaultLogger::get()->error("Source contains illegal character sequence, transformation to UTF-8 fails");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Convert to UTF8 data
|
|
|
|
void BaseImporter::ConvertToUTF8(std::vector<char>& data)
|
|
|
|
{
|
|
|
|
ConversionResult result;
|
|
|
|
if(data.size() < 8) {
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("File is too small");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UTF 8 with BOM
|
|
|
|
if((uint8_t)data[0] == 0xEF && (uint8_t)data[1] == 0xBB && (uint8_t)data[2] == 0xBF) {
|
|
|
|
DefaultLogger::get()->debug("Found UTF-8 BOM ...");
|
|
|
|
|
|
|
|
std::copy(data.begin()+3,data.end(),data.begin());
|
|
|
|
data.resize(data.size()-3);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UTF 32 BE with BOM
|
|
|
|
if(*((uint32_t*)&data.front()) == 0xFFFE0000) {
|
|
|
|
|
|
|
|
// swap the endianess ..
|
|
|
|
for(uint32_t* p = (uint32_t*)&data.front(), *end = (uint32_t*)&data.back(); p <= end; ++p) {
|
|
|
|
AI_SWAP4P(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UTF 32 LE with BOM
|
|
|
|
if(*((uint32_t*)&data.front()) == 0x0000FFFE) {
|
|
|
|
DefaultLogger::get()->debug("Found UTF-32 BOM ...");
|
|
|
|
|
|
|
|
const uint32_t* sstart = (uint32_t*)&data.front()+1, *send = (uint32_t*)&data.back()+1;
|
|
|
|
char* dstart,*dend;
|
|
|
|
std::vector<char> output;
|
|
|
|
do {
|
|
|
|
output.resize(output.size()?output.size()*3/2:data.size()/2);
|
|
|
|
dstart = &output.front(),dend = &output.back()+1;
|
|
|
|
|
|
|
|
result = ConvertUTF32toUTF8((const UTF32**)&sstart,(const UTF32*)send,(UTF8**)&dstart,(UTF8*)dend,lenientConversion);
|
|
|
|
} while(result == targetExhausted);
|
|
|
|
|
|
|
|
ReportResult(result);
|
|
|
|
|
|
|
|
// copy to output buffer.
|
|
|
|
const size_t outlen = (size_t)(dstart-&output.front());
|
|
|
|
data.assign(output.begin(),output.begin()+outlen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UTF 16 BE with BOM
|
|
|
|
if(*((uint16_t*)&data.front()) == 0xFFFE) {
|
|
|
|
|
|
|
|
// swap the endianess ..
|
|
|
|
for(uint16_t* p = (uint16_t*)&data.front(), *end = (uint16_t*)&data.back(); p <= end; ++p) {
|
|
|
|
ByteSwap::Swap2(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// UTF 16 LE with BOM
|
|
|
|
if(*((uint16_t*)&data.front()) == 0xFEFF) {
|
|
|
|
DefaultLogger::get()->debug("Found UTF-16 BOM ...");
|
|
|
|
|
|
|
|
const uint16_t* sstart = (uint16_t*)&data.front()+1, *send = (uint16_t*)&data.back()+1;
|
|
|
|
char* dstart,*dend;
|
|
|
|
std::vector<char> output;
|
|
|
|
do {
|
|
|
|
output.resize(output.size()?output.size()*3/2:data.size()*3/4);
|
|
|
|
dstart = &output.front(),dend = &output.back()+1;
|
|
|
|
|
|
|
|
result = ConvertUTF16toUTF8((const UTF16**)&sstart,(const UTF16*)send,(UTF8**)&dstart,(UTF8*)dend,lenientConversion);
|
|
|
|
} while(result == targetExhausted);
|
|
|
|
|
|
|
|
ReportResult(result);
|
|
|
|
|
|
|
|
// copy to output buffer.
|
|
|
|
const size_t outlen = (size_t)(dstart-&output.front());
|
|
|
|
data.assign(output.begin(),output.begin()+outlen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void BaseImporter::TextFileToBuffer(IOStream* stream,
|
|
|
|
std::vector<char>& data)
|
|
|
|
{
|
|
|
|
ai_assert(NULL != stream);
|
|
|
|
|
|
|
|
const size_t fileSize = stream->FileSize();
|
|
|
|
if(!fileSize) {
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("File is empty");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data.reserve(fileSize+1);
|
|
|
|
data.resize(fileSize);
|
|
|
|
if(fileSize != stream->Read( &data[0], 1, fileSize)) {
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("File read error");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConvertToUTF8(data);
|
|
|
|
|
|
|
|
// append a binary zero to simplify string parsing
|
|
|
|
data.push_back(0);
|
|
|
|
}
|
|
|
|
|
2008-10-27 00:36:26 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-08-18 16:17:27 +00:00
|
|
|
namespace Assimp
|
2008-10-27 00:36:26 +00:00
|
|
|
{
|
2009-08-18 16:17:27 +00:00
|
|
|
// Represents an import request
|
|
|
|
struct LoadRequest
|
2009-02-12 22:14:35 +00:00
|
|
|
{
|
2009-08-18 16:17:27 +00:00
|
|
|
LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id)
|
|
|
|
: file(_file), flags(_flags), refCnt(1),scene(NULL), loaded(false), id(_id)
|
|
|
|
{
|
|
|
|
if (_map)
|
|
|
|
map = *_map;
|
|
|
|
}
|
2008-10-27 00:36:26 +00:00
|
|
|
|
2009-08-18 16:17:27 +00:00
|
|
|
const std::string file;
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int refCnt;
|
|
|
|
aiScene* scene;
|
|
|
|
bool loaded;
|
|
|
|
BatchLoader::PropertyMap map;
|
|
|
|
unsigned int id;
|
2008-10-27 00:36:26 +00:00
|
|
|
|
2009-08-18 16:17:27 +00:00
|
|
|
bool operator== (const std::string& f) {
|
|
|
|
return file == f;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2008-10-27 00:36:26 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// BatchLoader::pimpl data structure
|
2009-01-12 22:06:54 +00:00
|
|
|
struct Assimp::BatchData
|
2008-10-27 00:36:26 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
BatchData()
|
|
|
|
: next_id(0xffff)
|
|
|
|
{}
|
|
|
|
|
2008-10-27 00:36:26 +00:00
|
|
|
// IO system to be used for all imports
|
|
|
|
IOSystem* pIOSystem;
|
|
|
|
|
|
|
|
// Importer used to load all meshes
|
|
|
|
Importer* pImporter;
|
|
|
|
|
|
|
|
// List of all imports
|
|
|
|
std::list<LoadRequest> requests;
|
2008-11-26 13:17:39 +00:00
|
|
|
|
|
|
|
// Base path
|
|
|
|
std::string pathBase;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
// Id for next item
|
|
|
|
unsigned int next_id;
|
2008-10-27 00:36:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
BatchLoader::BatchLoader(IOSystem* pIO)
|
|
|
|
{
|
|
|
|
ai_assert(NULL != pIO);
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
data = new BatchData();
|
2008-10-27 00:36:26 +00:00
|
|
|
data->pIOSystem = pIO;
|
2009-04-10 21:59:22 +00:00
|
|
|
|
2008-10-27 00:36:26 +00:00
|
|
|
data->pImporter = new Importer();
|
2009-04-10 21:59:22 +00:00
|
|
|
data->pImporter->SetIOHandler(data->pIOSystem);
|
2008-10-27 00:36:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
BatchLoader::~BatchLoader()
|
|
|
|
{
|
|
|
|
// delete all scenes wthat have not been polled by the user
|
2009-04-10 21:59:22 +00:00
|
|
|
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {
|
|
|
|
|
2008-10-27 00:36:26 +00:00
|
|
|
delete (*it).scene;
|
|
|
|
}
|
2009-04-10 21:59:22 +00:00
|
|
|
data->pImporter->SetIOHandler(NULL); /* get pointer back into our posession */
|
2008-10-27 00:36:26 +00:00
|
|
|
delete data->pImporter;
|
|
|
|
delete data;
|
|
|
|
}
|
|
|
|
|
2008-11-26 13:17:39 +00:00
|
|
|
|
2008-10-27 00:36:26 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
unsigned int BatchLoader::AddLoadRequest (const std::string& file,
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int steps /*= 0*/, const PropertyMap* map /*= NULL*/)
|
2008-10-27 00:36:26 +00:00
|
|
|
{
|
2008-11-26 13:17:39 +00:00
|
|
|
ai_assert(!file.empty());
|
|
|
|
|
|
|
|
// check whether we have this loading request already
|
|
|
|
std::list<LoadRequest>::iterator it;
|
2009-04-10 21:59:22 +00:00
|
|
|
for (it = data->requests.begin();it != data->requests.end(); ++it) {
|
|
|
|
|
2008-11-26 13:17:39 +00:00
|
|
|
// Call IOSystem's path comparison function here
|
2009-04-10 21:59:22 +00:00
|
|
|
if (data->pIOSystem->ComparePaths((*it).file,file)) {
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
if (map) {
|
|
|
|
if (!((*it).map == *map))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (!(*it).map.empty())
|
|
|
|
continue;
|
|
|
|
|
2008-11-26 13:17:39 +00:00
|
|
|
(*it).refCnt++;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return (*it).id;
|
2008-11-26 13:17:39 +00:00
|
|
|
}
|
2008-10-27 00:36:26 +00:00
|
|
|
}
|
2008-11-26 13:17:39 +00:00
|
|
|
|
|
|
|
// no, we don't have it. So add it to the queue ...
|
2009-04-10 21:59:22 +00:00
|
|
|
data->requests.push_back(LoadRequest(file,steps,map,data->next_id));
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return data->next_id++;
|
2008-10-27 00:36:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
aiScene* BatchLoader::GetImport (unsigned int which)
|
2008-10-27 00:36:26 +00:00
|
|
|
{
|
2009-04-10 21:59:22 +00:00
|
|
|
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {
|
|
|
|
|
|
|
|
if ((*it).id == which && (*it).loaded) {
|
|
|
|
|
2008-11-26 13:17:39 +00:00
|
|
|
aiScene* sc = (*it).scene;
|
2009-04-10 21:59:22 +00:00
|
|
|
if (!(--(*it).refCnt)) {
|
2008-11-26 13:17:39 +00:00
|
|
|
data->requests.erase(it);
|
|
|
|
}
|
|
|
|
return sc;
|
2008-10-27 00:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void BatchLoader::LoadAll()
|
|
|
|
{
|
|
|
|
// no threaded implementation for the moment
|
2009-04-10 21:59:22 +00:00
|
|
|
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {
|
2008-10-31 19:32:00 +00:00
|
|
|
// force validation in debug builds
|
|
|
|
unsigned int pp = (*it).flags;
|
2008-10-27 00:36:26 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
pp |= aiProcess_ValidateDataStructure;
|
|
|
|
#endif
|
2008-10-31 19:32:00 +00:00
|
|
|
// setup config properties if necessary
|
2009-04-24 20:53:24 +00:00
|
|
|
data->pImporter->pimpl->mFloatProperties = (*it).map.floats;
|
|
|
|
data->pImporter->pimpl->mIntProperties = (*it).map.ints;
|
|
|
|
data->pImporter->pimpl->mStringProperties = (*it).map.strings;
|
2008-10-27 00:36:26 +00:00
|
|
|
|
2008-11-26 13:17:39 +00:00
|
|
|
if (!DefaultLogger::isNullLogger())
|
|
|
|
{
|
|
|
|
DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%");
|
|
|
|
DefaultLogger::get()->info("File: " + (*it).file);
|
|
|
|
}
|
2008-10-27 00:36:26 +00:00
|
|
|
data->pImporter->ReadFile((*it).file,pp);
|
|
|
|
(*it).scene = const_cast<aiScene*>(data->pImporter->GetOrphanedScene());
|
|
|
|
(*it).loaded = true;
|
2008-11-26 13:17:39 +00:00
|
|
|
|
|
|
|
DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");
|
2008-10-27 00:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-13 22:31:15 +00:00
|
|
|
|