git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@99 67173fc5-114c-0410-ac8e-9d2fd5bffc1f

pull/1/head
aramis_acg 2008-08-08 18:29:05 +00:00
parent f5be0b0475
commit 333f0c805e
3 changed files with 63 additions and 55 deletions

View File

@ -39,19 +39,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
/** @file Implementation of the Plain-C API */ /** @file Implementation of the Plain-C API */
// CRT headers
#include <map> #include <map>
// public ASSIMP headers
#include "../include/assimp.h" #include "../include/assimp.h"
#include "../include/assimp.hpp" #include "../include/assimp.hpp"
#include "../include/DefaultLogger.h"
#include "../include/aiAssert.h" #include "../include/aiAssert.h"
using namespace Assimp;
// boost headers
#define AI_C_THREADSAFE
#if (defined AI_C_THREADSAFE) #if (defined AI_C_THREADSAFE)
# include <boost/thread/thread.hpp> # include <boost/thread/thread.hpp>
# include <boost/thread/mutex.hpp> # include <boost/thread/mutex.hpp>
#endif #endif
using namespace Assimp;
/** Stores the importer objects for all active import processes */ /** Stores the importer objects for all active import processes */
typedef std::map< const aiScene*, Assimp::Importer* > ImporterMap; typedef std::map< const aiScene*, Assimp::Importer* > ImporterMap;
@ -111,7 +117,11 @@ void aiReleaseImport( const aiScene* pScene)
ImporterMap::iterator it = gActiveImports.find( pScene); ImporterMap::iterator it = gActiveImports.find( pScene);
// it should be there... else the user is playing fools with us // it should be there... else the user is playing fools with us
if( it == gActiveImports.end()) if( it == gActiveImports.end())
{
DefaultLogger::get()->error("Unable to find the Importer instance for this scene. "
"Are you sure it has been created by aiImportFile(ex)(...)?");
return; return;
}
// kill the importer, the data dies with it // kill the importer, the data dies with it
delete it->second; delete it->second;
@ -172,4 +182,25 @@ void aiGetExtensionList(aiString* szOut)
szOut->Set ( szTemp ); szOut->Set ( szTemp );
delete pcTemp; delete pcTemp;
} }
// ------------------------------------------------------------------------------------------------
void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in);
{
// lock the mutex
#if (defined AI_C_THREADSAFE)
boost::mutex::scoped_lock lock(gMutex);
#endif
// find the importer associated with this data
ImporterMap::iterator it = gActiveImports.find( pIn);
// it should be there... else the user is playing fools with us
if( it == gActiveImports.end())
{
DefaultLogger::get()->error("Unable to find the Importer instance for this scene. "
"Are you sure it has been created by aiImportFile(ex)(...)?");
return 0;
}
// get memory statistics
it->second->GetMemoryRequirements(*in);
}

View File

@ -69,7 +69,7 @@ void MD2::LookupNormalIndex(uint8_t iNormalIndex,aiVector3D& vOut)
// make sure the normal index has a valid value // make sure the normal index has a valid value
if (iNormalIndex >= ARRAYSIZE(g_avNormals)) if (iNormalIndex >= ARRAYSIZE(g_avNormals))
{ {
DefaultLogger::get()->warn("Index overflow in MDL7 normal vector list (the " DefaultLogger::get()->warn("Index overflow in Quake II normal vector list (the "
" LUT has only 162 entries). "); " LUT has only 162 entries). ");
iNormalIndex = ARRAYSIZE(g_avNormals) - 1; iNormalIndex = ARRAYSIZE(g_avNormals) - 1;
@ -113,6 +113,30 @@ bool MD2Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
// Validate the file header // Validate the file header
void MD2Importer::ValidateHeader( ) void MD2Importer::ValidateHeader( )
{ {
// check magic number
if (this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
{
delete[] this->mBuffer;
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
char szBuffer[5];
szBuffer[0] = ((char*)&this->m_pcHeader->magic)[0];
szBuffer[1] = ((char*)&this->m_pcHeader->magic)[1];
szBuffer[2] = ((char*)&this->m_pcHeader->magic)[2];
szBuffer[3] = ((char*)&this->m_pcHeader->magic)[3];
szBuffer[4] = '\0';
throw new ImportErrorException("Invalid MD2 magic word: should be IDP2, the "
"magic word found is " + std::string(szBuffer));
}
// check file format version
if (this->m_pcHeader->version != 8)
{
DefaultLogger::get()->warn( "Unsupported md2 file version. Continuing happily ...");
}
/* to be validated: /* to be validated:
int32_t offsetSkins; int32_t offsetSkins;
int32_t offsetTexCoords; int32_t offsetTexCoords;
@ -129,6 +153,7 @@ void MD2Importer::ValidateHeader( )
this->m_pcHeader->offsetEnd > this->fileSize) this->m_pcHeader->offsetEnd > this->fileSize)
{ {
throw new ImportErrorException("Invalid MD2 header: some offsets are outside the file"); throw new ImportErrorException("Invalid MD2 header: some offsets are outside the file");
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
} }
if (this->m_pcHeader->numSkins > AI_MD2_MAX_SKINS) if (this->m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
@ -166,19 +191,6 @@ void MD2Importer::InternReadFile(
file->Read( (void*)mBuffer, 1, fileSize); file->Read( (void*)mBuffer, 1, fileSize);
this->m_pcHeader = (const MD2::Header*)this->mBuffer; this->m_pcHeader = (const MD2::Header*)this->mBuffer;
// check magic number
if (this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
{
throw new ImportErrorException( "Invalid md2 file: Magic bytes not found");
}
// check file format version
if (this->m_pcHeader->version != 8)
{
DefaultLogger::get()->warn( "Unsupported md2 file version. Continuing happily ...");
}
this->ValidateHeader(); this->ValidateHeader();
// check some values whether they are valid // check some values whether they are valid

View File

@ -50,12 +50,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "Licensed under a 3-clause BSD license" VALUE "Comments", "Licensed under a 3-clause BSD license"
VALUE "CompanyName", "ASSIMP Development Team" VALUE "CompanyName", "ASSIMP Development Team"
VALUE "FileDescription", "Open Asset Import Library " VALUE "FileDescription", "Open Asset Import Library"
VALUE "FileVersion", "1, 0, 0, 0" VALUE "FileVersion", "1, 0, 0, 0"
VALUE "InternalName", "assimp" VALUE "InternalName", "assimp"
VALUE "LegalCopyright", "Copyright (C) 2008" VALUE "LegalCopyright", "Copyright (C) 2008"
VALUE "OriginalFilename", "assimpNN.dll" VALUE "OriginalFilename", "assimpNN.dll"
VALUE "ProductName", "Open Asset Import Library " VALUE "ProductName", "Open Asset Import Library"
VALUE "ProductVersion", "1, 0, 0, 0" VALUE "ProductVersion", "1, 0, 0, 0"
END END
END END
@ -65,41 +65,6 @@ BEGIN
END END
END END
#else
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x7L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040704b0"
BEGIN
VALUE "Comments", "Licensed under a 3-clause BSD license"
VALUE "CompanyName", "ASSIMP Development Team"
VALUE "FileDescription", "ASSIMP-JNI bridge module"
VALUE "FileVersion", "1, 0, 0, 0"
VALUE "InternalName", "jassimp"
VALUE "LegalCopyright", "Copyright (C) 2008"
VALUE "OriginalFilename", "jAssimpNN.dll"
VALUE "ProductName", "ASSIMP-JNI bridge module"
VALUE "ProductVersion", "1, 0, 0, 0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x407, 1200
END
END
#endif // !!ASSIMP_JNI_EXPORT #endif // !!ASSIMP_JNI_EXPORT