- 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
This commit is contained in:
aramis_acg
2009-03-05 22:32:13 +00:00
parent caaf02b0e4
commit 4bbc03332b
237 changed files with 33463 additions and 2245 deletions

View File

@@ -344,18 +344,19 @@ MD3Importer::~MD3Importer()
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool MD3Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
bool MD3Importer::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
{
// simple check of file extension is enough for the moment
std::string::size_type pos = pFile.find_last_of('.');
// no file extension - can't read
if( pos == std::string::npos)
return false;
std::string extension = pFile.substr( pos);
for( std::string::iterator it = extension.begin(); it != extension.end(); ++it)
*it = tolower( *it);
const std::string extension = GetExtension(pFile);
if (extension == "md3")
return true;
return ( extension == ".md3");
// if check for extension is not enough, check for the magic tokens
if (!extension.length() || checkSig) {
uint32_t tokens[1];
tokens[0] = AI_MD3_MAGIC_NUMBER_LE;
return CheckMagicToken(pIOHandler,pFile,tokens,1);
}
return false;
}
// ------------------------------------------------------------------------------------------------
@@ -436,6 +437,9 @@ void MD3Importer::SetupProperties(const Importer* pImp)
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC,""));
// AI_CONFIG_FAVOUR_SPEED
configSpeedFlag = (0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0));
}
// ------------------------------------------------------------------------------------------------
@@ -458,10 +462,7 @@ void MD3Importer::ReadSkin(Q3Shader::SkinData& fill) const
void MD3Importer::ReadShader(Q3Shader::ShaderData& fill) const
{
// Determine Q3 model name from given path
std::string::size_type s = path.find_last_of('\\',path.length()-2);
if (s == std::string::npos)
s = path.find_last_of('/',path.length()-2);
std::string::size_type s = path.find_last_of("\\/",path.length()-2);
const std::string model_file = path.substr(s+1,path.length()-(s+2));
// If no specific dir or file is given, use our default search behaviour
@@ -486,6 +487,24 @@ void MD3Importer::ReadShader(Q3Shader::ShaderData& fill) const
}
}
// ------------------------------------------------------------------------------------------------
// Tiny helper to remove a single node from its parent' list
void RemoveSingleNodeFromList(aiNode* nd)
{
if (!nd || nd->mNumChildren || !nd->mParent)return;
aiNode* par = nd->mParent;
for (unsigned int i = 0; i < par->mNumChildren;++i) {
if (par->mChildren[i] == nd) {
--par->mNumChildren;
for (;i < par->mNumChildren;++i) {
par->mChildren[i] = par->mChildren[i+1];
}
delete nd;
break;
}
}
}
// ------------------------------------------------------------------------------------------------
// Read a multi-part Q3 player model
bool MD3Importer::ReadMultipartFile()
@@ -520,32 +539,32 @@ bool MD3Importer::ReadMultipartFile()
// now read these three files
BatchLoader batch(mIOHandler);
batch.AddLoadRequest(lower,0,&props);
batch.AddLoadRequest(upper,0,&props);
batch.AddLoadRequest(head,0,&props);
unsigned int _lower = batch.AddLoadRequest(lower,0,&props);
unsigned int _upper = batch.AddLoadRequest(upper,0,&props);
unsigned int _head = batch.AddLoadRequest(head,0,&props);
batch.LoadAll();
// now construct a dummy scene to place these three parts in
aiScene* master = new aiScene();
aiNode* nd = master->mRootNode = new aiNode();
nd->mName.Set("<M3D_Player>");
nd->mName.Set("<MD3_Player>");
// ... and get them. We need all of them.
scene_lower = batch.GetImport(lower);
scene_lower = batch.GetImport(_lower);
if (!scene_lower) {
DefaultLogger::get()->error("M3D: Failed to read multipart model, lower.md3 fails to load");
failure = "lower";
goto error_cleanup;
}
scene_upper = batch.GetImport(upper);
scene_upper = batch.GetImport(_upper);
if (!scene_upper) {
DefaultLogger::get()->error("M3D: Failed to read multipart model, upper.md3 fails to load");
failure = "upper";
goto error_cleanup;
}
scene_head = batch.GetImport(head);
scene_head = batch.GetImport(_head);
if (!scene_head) {
DefaultLogger::get()->error("M3D: Failed to read multipart model, head.md3 fails to load");
failure = "head";
@@ -555,6 +574,7 @@ bool MD3Importer::ReadMultipartFile()
// build attachment infos. search for typical Q3 tags
// original root
scene_lower->mRootNode->mName.Set("lower");
attach.push_back(AttachmentInfo(scene_lower, nd));
// tag_torso
@@ -563,6 +583,7 @@ bool MD3Importer::ReadMultipartFile()
DefaultLogger::get()->error("M3D: Failed to find attachment tag for multipart model: tag_torso expected");
goto error_cleanup;
}
scene_upper->mRootNode->mName.Set("upper");
attach.push_back(AttachmentInfo(scene_upper,tag_torso));
// tag_head
@@ -571,13 +592,21 @@ bool MD3Importer::ReadMultipartFile()
DefaultLogger::get()->error("M3D: Failed to find attachment tag for multipart model: tag_head expected");
goto error_cleanup;
}
scene_head->mRootNode->mName.Set("head");
attach.push_back(AttachmentInfo(scene_head,tag_head));
// Remove tag_head and tag_torso from all other model parts ...
// this ensures (together with AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY)
// that tag_torso/tag_head is also the name of the (unique) output node
RemoveSingleNodeFromList (scene_upper->mRootNode->FindNode("tag_torso"));
RemoveSingleNodeFromList (scene_head-> mRootNode->FindNode("tag_head" ));
// and merge the scenes
SceneCombiner::MergeScenes(&mScene,master, attach,
AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES |
AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES |
AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS);
AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES |
AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES |
AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS |
(!configSpeedFlag ? AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY : 0));
return true;