add support for compressed, drop support for shortened

pull/327/head
Gargaj 2014-08-07 08:05:07 +02:00
parent fb546b694e
commit 061911bdbf
1 changed files with 25 additions and 1 deletions

View File

@ -51,6 +51,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// internal headers // internal headers
#include "AssbinLoader.h" #include "AssbinLoader.h"
#include "assbin_chunks.h" #include "assbin_chunks.h"
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h>
#else
# include "../contrib/zlib/zlib.h"
#include "MemoryIOWrapper.h"
#endif
using namespace Assimp; using namespace Assimp;
@ -563,13 +569,31 @@ void AssbinImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
shortened = Read<uint16_t>(stream) > 0; shortened = Read<uint16_t>(stream) > 0;
compressed = Read<uint16_t>(stream) > 0; compressed = Read<uint16_t>(stream) > 0;
if (shortened)
throw DeadlyImportError( "Shortened binaries are not supported!" );
stream->Seek( 256, aiOrigin_CUR ); // original filename stream->Seek( 256, aiOrigin_CUR ); // original filename
stream->Seek( 128, aiOrigin_CUR ); // options stream->Seek( 128, aiOrigin_CUR ); // options
stream->Seek( 64, aiOrigin_CUR ); // padding stream->Seek( 64, aiOrigin_CUR ); // padding
if (compressed) if (compressed)
{ {
// TODO uLongf uncompressedSize = Read<uint32_t>(stream);
uLongf compressedSize = stream->FileSize() - stream->Tell();
unsigned char * compressedData = new unsigned char[ compressedSize ];
stream->Read( compressedData, 1, compressedSize );
unsigned char * uncompressedData = new unsigned char[ uncompressedSize ];
uncompress( uncompressedData, &uncompressedSize, compressedData, compressedSize );
MemoryIOStream io( uncompressedData, uncompressedSize );
ReadBinaryScene(&io,pScene);
delete[] uncompressedData;
delete[] compressedData;
} }
else else
{ {