From 5470f5fb2806377fcd8abefd45cdf7315b7f5e61 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Sat, 27 Jul 2013 10:34:48 +0900 Subject: [PATCH 001/104] add AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION for not transforming position of vertices --- code/ColladaLoader.cpp | 31 ++++++++++++++++--------------- code/ColladaLoader.h | 1 + include/assimp/config.h | 4 +++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 662f31532..a97ea2c6a 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -73,7 +73,7 @@ static const aiImporterDesc desc = { // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ColladaLoader::ColladaLoader() -: noSkeletonMesh() +: noSkeletonMesh(), ignoreUpDirection(false) {} // ------------------------------------------------------------------------------------------------ @@ -108,6 +108,7 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo void ColladaLoader::SetupProperties(const Importer* pImp) { noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0; + ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0; } @@ -160,21 +161,21 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I 0, parser.mUnitSize, 0, 0, 0, 0, parser.mUnitSize, 0, 0, 0, 0, 1); - + if( !ignoreUpDirection ) { // Convert to Y_UP, if different orientation - if( parser.mUpDirection == ColladaParser::UP_X) - pScene->mRootNode->mTransformation *= aiMatrix4x4( - 0, -1, 0, 0, - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - else if( parser.mUpDirection == ColladaParser::UP_Z) - pScene->mRootNode->mTransformation *= aiMatrix4x4( - 1, 0, 0, 0, - 0, 0, 1, 0, - 0, -1, 0, 0, - 0, 0, 0, 1); - + if( parser.mUpDirection == ColladaParser::UP_X) + pScene->mRootNode->mTransformation *= aiMatrix4x4( + 0, -1, 0, 0, + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + else if( parser.mUpDirection == ColladaParser::UP_Z) + pScene->mRootNode->mTransformation *= aiMatrix4x4( + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 0, + 0, 0, 0, 1); + } // store all meshes StoreSceneMeshes( pScene); diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index 850bce780..953bd20b8 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -234,6 +234,7 @@ protected: std::vector mAnims; bool noSkeletonMesh; + bool ignoreUpDirection; }; } // end of namespace Assimp diff --git a/include/assimp/config.h b/include/assimp/config.h index c1694c94c..8683cc385 100644 --- a/include/assimp/config.h +++ b/include/assimp/config.h @@ -841,4 +841,6 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" -#endif // !! AI_CONFIG_H_INC \ No newline at end of file +#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" + +#endif // !! AI_CONFIG_H_INC From 3c02d24bf0b4595fd6340c5f0f0ae410baf7b667 Mon Sep 17 00:00:00 2001 From: Faule Socke Date: Sun, 28 Jul 2013 01:57:31 +0200 Subject: [PATCH 002/104] Fixed a bug returning not all material properties when accessing them. Also fixed another bug occouring when no normals are provided in sample.py (lists do not have a any() method). --- port/PyAssimp/pyassimp/core.py | 21 +++++++++++++++++++-- port/PyAssimp/scripts/sample.py | 5 +++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 22670431d..3638a1373 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -336,6 +336,23 @@ def _finalize_mesh(mesh, target): faces = numpy.array([f.indices for f in target.faces], dtype=numpy.int32) setattr(target, 'faces', faces) + +class PropertyGetter(dict): + def __getitem__(self, key, semantic = 0): + return dict.__getitem__(self, (key, semantic)) + + def keys(self): + for k in dict.keys(self): + yield k[0] + + def __iter__(self): + return self.keys() + + def items(self): + for k, v in dict.items(self): + yield k[0], v + + def _get_properties(properties, length): """ Convenience Function to get the material properties as a dict @@ -346,7 +363,7 @@ def _get_properties(properties, length): for p in [properties[i] for i in range(length)]: #the name p = p.contents - key = str(p.mKey.data.decode("utf-8")).split('.')[1] + key = (str(p.mKey.data.decode("utf-8")).split('.')[1], p.mSemantic) #the data from ctypes import POINTER, cast, c_int, c_float, sizeof @@ -366,7 +383,7 @@ def _get_properties(properties, length): result[key] = value - return result + return PropertyGetter(result) def decompose_matrix(matrix): if not isinstance(matrix, structs.Matrix4x4): diff --git a/port/PyAssimp/scripts/sample.py b/port/PyAssimp/scripts/sample.py index b7b08748f..92ce881af 100755 --- a/port/PyAssimp/scripts/sample.py +++ b/port/PyAssimp/scripts/sample.py @@ -10,6 +10,7 @@ import logging logging.basicConfig(level=logging.INFO) import pyassimp +import pyassimp.postprocess def recur_node(node,level = 0): print(" " + "\t" * level + "- " + str(node)) @@ -19,7 +20,7 @@ def recur_node(node,level = 0): def main(filename=None): - scene = pyassimp.load(filename) + scene = pyassimp.load(filename, pyassimp.postprocess.aiProcess_Triangulate) #the model we load print("MODEL:" + filename) @@ -42,7 +43,7 @@ def main(filename=None): print(" material id:" + str(mesh.materialindex+1)) print(" vertices:" + str(len(mesh.vertices))) print(" first 3 verts:\n" + str(mesh.vertices[:3])) - if mesh.normals.any(): + if mesh.normals: print(" first 3 normals:\n" + str(mesh.normals[:3])) else: print(" no normals") From 43ff04a53be4d4d373395979c74a31abafd748c8 Mon Sep 17 00:00:00 2001 From: Faule Socke Date: Sun, 28 Jul 2013 22:22:49 +0200 Subject: [PATCH 003/104] Fixed a bug in the bugfix -.- --- port/PyAssimp/pyassimp/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 3638a1373..cd88d026f 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -338,7 +338,11 @@ def _finalize_mesh(mesh, target): class PropertyGetter(dict): - def __getitem__(self, key, semantic = 0): + def __getitem__(self, key): + semantic = 0 + if isinstance(key, tuple): + key, semantic = key + return dict.__getitem__(self, (key, semantic)) def keys(self): From 945231ba94e24acaa34eef4f34a06fe44722b3ea Mon Sep 17 00:00:00 2001 From: Faule Socke Date: Mon, 29 Jul 2013 01:24:22 +0200 Subject: [PATCH 004/104] Now actually fixed the bug with the normals. pyassimp returned a list instead of a numpy array when the normals were empty. This also applies to texture coordinates and other stuff which is explicitly converted in _finalize_mesh. --- port/PyAssimp/pyassimp/core.py | 16 ++++++++-------- port/PyAssimp/scripts/sample.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index cd88d026f..ab1e913cd 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -58,14 +58,14 @@ def make_tuple(ai_obj, type = None): return res def call_init(obj, caller = None): - # init children - if helper.hasattr_silent(obj, '_init'): - obj._init(parent = caller) + # init children + if helper.hasattr_silent(obj, '_init'): + obj._init(parent = caller) - # pointers - elif helper.hasattr_silent(obj, 'contents'): - if helper.hasattr_silent(obj.contents, '_init'): - obj.contents._init(target = obj, parent = caller) + # pointers + elif helper.hasattr_silent(obj, 'contents'): + if helper.hasattr_silent(obj.contents, '_init'): + obj.contents._init(target = obj, parent = caller) @@ -313,7 +313,7 @@ def _finalize_mesh(mesh, target): data = numpy.array([make_tuple(getattr(mesh, name)[i]) for i in range(nb_vertices)], dtype=numpy.float32) setattr(target, name[1:].lower(), data) else: - setattr(target, name[1:].lower(), []) + setattr(target, name[1:].lower(), numpy.array([], dtype="float32")) def fillarray(name): mAttr = getattr(mesh, name) diff --git a/port/PyAssimp/scripts/sample.py b/port/PyAssimp/scripts/sample.py index 92ce881af..5153a9bab 100755 --- a/port/PyAssimp/scripts/sample.py +++ b/port/PyAssimp/scripts/sample.py @@ -43,7 +43,7 @@ def main(filename=None): print(" material id:" + str(mesh.materialindex+1)) print(" vertices:" + str(len(mesh.vertices))) print(" first 3 verts:\n" + str(mesh.vertices[:3])) - if mesh.normals: + if mesh.normals.any(): print(" first 3 normals:\n" + str(mesh.normals[:3])) else: print(" no normals") From 4ccb16fe01674b5bbe1129948d2e71aa6b6db97d Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Wed, 31 Jul 2013 20:15:59 +0900 Subject: [PATCH 005/104] add binary exporter to STLExporter --- code/Exporter.cpp | 4 +++ code/STLExporter.cpp | 69 +++++++++++++++++++++++++++++++++++++++----- code/STLExporter.h | 3 +- 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 3b2badab7..405fa2e29 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -73,6 +73,7 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out); void ExportSceneCollada(const char*,IOSystem*, const aiScene*); void ExportSceneObj(const char*,IOSystem*, const aiScene*); void ExportSceneSTL(const char*,IOSystem*, const aiScene*); +void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*); void ExportScenePly(const char*,IOSystem*, const aiScene*); void ExportScene3DS(const char*, IOSystem*, const aiScene*) {} @@ -93,6 +94,9 @@ Exporter::ExportFormatEntry gExporters[] = Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL, aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices ), + Exporter::ExportFormatEntry( "stlb", "Stereolithography(binary)", "stlb" , &ExportSceneSTLBinary, + aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices + ), #endif #ifndef ASSIMP_BUILD_NO_PLY_EXPORTER diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index 521f28ae3..249f0f6f8 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -63,12 +63,25 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } +void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +{ + // invoke the exporter + STLExporter exporter(pFile, pScene, true); + + // we're still here - export successfully completed. Write the file. + boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .stl file: " + std::string(pFile)); + } + + outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); +} } // end of namespace Assimp // ------------------------------------------------------------------------------------------------ -STLExporter :: STLExporter(const char* _filename, const aiScene* pScene) +STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool binary) : filename(_filename) , pScene(pScene) , endl("\n") @@ -76,14 +89,31 @@ STLExporter :: STLExporter(const char* _filename, const aiScene* pScene) // make sure that all formatting happens using the standard, C locale and not the user's current locale const std::locale& l = std::locale("C"); mOutput.imbue(l); - - const std::string& name = "AssimpScene"; + if (binary) { + char buf[80]; + for(int i = 0; i < 80; ++i) buf[i] = 0; + buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p'; + buf[6] = 'S'; buf[7] = 'c'; buf[8] = 'e'; buf[9] = 'n'; buf[10] = 'e'; + mOutput.write(buf, 80); + unsigned int meshnum = 0; + for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { + for (unsigned int j = 0; j < pScene->mMeshes[i]->mNumFaces; ++j) { + meshnum++; + } + } + mOutput.write((char *)&meshnum, 4); + for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { + WriteMeshBinary(pScene->mMeshes[i]); + } + } else { + const std::string& name = "AssimpScene"; - mOutput << "solid " << name << endl; - for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { - WriteMesh(pScene->mMeshes[i]); + mOutput << "solid " << name << endl; + for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { + WriteMesh(pScene->mMeshes[i]); + } + mOutput << "endsolid " << name << endl; } - mOutput << "endsolid " << name << endl; } // ------------------------------------------------------------------------------------------------ @@ -113,4 +143,29 @@ void STLExporter :: WriteMesh(const aiMesh* m) } } +void STLExporter :: WriteMeshBinary(const aiMesh* m) +{ + for (unsigned int i = 0; i < m->mNumFaces; ++i) { + const aiFace& f = m->mFaces[i]; + // we need per-face normals. We specified aiProcess_GenNormals as pre-requisite for this exporter, + // but nonetheless we have to expect per-vertex normals. + aiVector3D nor; + if (m->mNormals) { + for(unsigned int a = 0; a < f.mNumIndices; ++a) { + nor += m->mNormals[f.mIndices[a]]; + } + nor.Normalize(); + } + float nx = nor.x, ny = nor.y, nz = nor.z; + mOutput.write((char *)&nx, 4); mOutput.write((char *)&ny, 4); mOutput.write((char *)&nz, 4); + for(unsigned int a = 0; a < f.mNumIndices; ++a) { + const aiVector3D& v = m->mVertices[f.mIndices[a]]; + float vx = v.x, vy = v.y, vz = v.z; + mOutput.write((char *)&vx, 4); mOutput.write((char *)&vy, 4); mOutput.write((char *)&vz, 4); + } + char dummy[2]; + mOutput.write(dummy, 2); + } +} + #endif diff --git a/code/STLExporter.h b/code/STLExporter.h index d64fe92e6..0ed60d812 100644 --- a/code/STLExporter.h +++ b/code/STLExporter.h @@ -59,7 +59,7 @@ class STLExporter { public: /// Constructor for a specific scene to export - STLExporter(const char* filename, const aiScene* pScene); + STLExporter(const char* filename, const aiScene* pScene, bool binary = false); public: @@ -69,6 +69,7 @@ public: private: void WriteMesh(const aiMesh* m); + void WriteMeshBinary(const aiMesh* m); private: From d99d4dadd3b329cc541160d56aa4dff4bbdc0c8d Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sun, 4 Aug 2013 01:34:38 +0200 Subject: [PATCH 006/104] Update Readme with info on my C4D branch. --- Readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Readme.md b/Readme.md index 112d389e8..8b476c6cf 100644 --- a/Readme.md +++ b/Readme.md @@ -46,6 +46,10 @@ The library provides importers for a lot of file formats, including: - NDO - Ogre XML - Q3D + +Additionally, the following formats are also supported, but not part of the core library as they depend on proprietary libraries. + +- C4D (https://github.com/acgessler/assimp-cinema4d) Exporters include: From 0d57e659cbaba6c5e6dd47748be0502f090c4f94 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Sun, 4 Aug 2013 10:10:21 -0400 Subject: [PATCH 007/104] Added AI_WONT_RETURN_SUFFIX mainly for Clang's static analyzer. --- include/assimp/defs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/assimp/defs.h b/include/assimp/defs.h index 1b777a5f2..aeae0778f 100644 --- a/include/assimp/defs.h +++ b/include/assimp/defs.h @@ -162,6 +162,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # define AI_FORCE_INLINE inline #endif // (defined _MSC_VER) +#ifdef __clang__ +# define AI_WONT_RETURN_SUFFIX __attribute__((analyzer_noreturn)) +#else +# define AI_WONT_RETURN_SUFFIX +#endif // (defined __clang__) + #ifdef __cplusplus /* No explicit 'struct' and 'enum' tags for C++, this keeps showing up * in doxydocs. From 32b694d4f63a10e6368d444e8eace7dde6d9f1df Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Sun, 4 Aug 2013 10:10:41 -0400 Subject: [PATCH 008/104] Added AI_WONT_RETURN_SUFFIX to ReportError(). --- code/ValidateDataStructure.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ValidateDataStructure.h b/code/ValidateDataStructure.h index e33bb5b82..4a3ec86d2 100644 --- a/code/ValidateDataStructure.h +++ b/code/ValidateDataStructure.h @@ -82,7 +82,7 @@ protected: /** Report a validation error. This will throw an exception, * control won't return. * @param msg Format string for sprintf().*/ - AI_WONT_RETURN void ReportError(const char* msg,...); + AI_WONT_RETURN void ReportError(const char* msg,...) AI_WONT_RETURN_SUFFIX; // ------------------------------------------------------------------- From ace5b763c3aef3cfbfcb8e364fb329b3e705661b Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Sun, 4 Aug 2013 10:11:02 -0400 Subject: [PATCH 009/104] Added AI_WONT_RETURN and AI_WONT_RETURN_SUFFIX to DOMError. --- code/FBXDocumentUtil.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/FBXDocumentUtil.h b/code/FBXDocumentUtil.h index 7ff71937c..6f150b6d5 100644 --- a/code/FBXDocumentUtil.h +++ b/code/FBXDocumentUtil.h @@ -50,8 +50,8 @@ namespace Util { /* DOM/Parse error reporting - does not return */ -void DOMError(const std::string& message, const Token& token); -void DOMError(const std::string& message, const Element* element = NULL); +AI_WONT_RETURN void DOMError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN void DOMError(const std::string& message, const Element* element = NULL) AI_WONT_RETURN_SUFFIX; // does return void DOMWarning(const std::string& message, const Token& token); From 04b0ea3f9a43dd3d7760d91422592abb97628d66 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Mon, 5 Aug 2013 00:02:27 -0400 Subject: [PATCH 010/104] Initialized stride variable to prevent compiler warnings about potential use of unassigned variable. --- code/FBXParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBXParser.cpp b/code/FBXParser.cpp index 7b32e1df5..af0e929bf 100644 --- a/code/FBXParser.cpp +++ b/code/FBXParser.cpp @@ -512,7 +512,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha ai_assert(data + comp_len == end); // determine the length of the uncompressed data by looking at the type signature - uint32_t stride; + uint32_t stride = 0; switch(type) { case 'f': From 6920c433fde33fcb0bedbb0aba7e7ce58e1bcede Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 7 Aug 2013 14:29:17 +0200 Subject: [PATCH 011/104] add missing include to fast_atof.h --- code/fast_atof.h | 1 + 1 file changed, 1 insertion(+) diff --git a/code/fast_atof.h b/code/fast_atof.h index 68a120c1f..a10ee9666 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -16,6 +16,7 @@ #define __FAST_A_TO_F_H_INCLUDED__ #include +#include namespace Assimp { From 8d80f5639684a4b6cf4d44b4560ac31b9ba85137 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 7 Aug 2013 14:59:16 +0200 Subject: [PATCH 012/104] fix include/ define in PostStepRegistry allow to build without any post processing steps: * typo in ASSIMP_BUILD_DEBONE_PROCESS -> ASSIMP_BUILD_NO_DEBONE_PROCESS * needs to include ProcessHelper.h itself --- code/PostStepRegistry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/PostStepRegistry.cpp b/code/PostStepRegistry.cpp index 0e3de18a0..3fdbeb257 100644 --- a/code/PostStepRegistry.cpp +++ b/code/PostStepRegistry.cpp @@ -47,6 +47,7 @@ corresponding preprocessor flag to selectively disable steps. */ #include "AssimpPCH.h" +#include "ProcessHelper.h" #ifndef ASSIMP_BUILD_NO_CALCTANGENTS_PROCESS # include "CalcTangentsProcess.h" @@ -215,7 +216,7 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out) #if (!defined ASSIMP_BUILD_NO_FLIPWINDINGORDER_PROCESS) out.push_back( new FlipWindingOrderProcess()); #endif -#if (!defined ASSIMP_BUILD_DEBONE_PROCESS) +#if (!defined ASSIMP_BUILD_NO_DEBONE_PROCESS) out.push_back( new DeboneProcess()); #endif #if (!defined ASSIMP_BUILD_NO_LIMITBONEWEIGHTS_PROCESS) From c8428fa67a4c77fc1aec6f5fde7b95da4aca557d Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Wed, 7 Aug 2013 18:43:29 -0400 Subject: [PATCH 013/104] Added value range assertions to prevent static analysis false-positives on Clang. --- code/FBXConverter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 3a21a89ee..3ad6790f7 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -547,6 +547,10 @@ private: default: ai_assert(false); } + + ai_assert((order[0] >= 0) && (order[0] <= 2)); + ai_assert((order[1] >= 0) && (order[1] <= 2)); + ai_assert((order[2] >= 0) && (order[2] <= 2)); if(!is_id[order[0]]) { out = temp[order[0]]; From 60a65aaaebdb81ebb82e2500be4cc6562cd24b67 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Fri, 9 Aug 2013 17:54:28 +0900 Subject: [PATCH 014/104] add AI_SWAP4 for big endian architecture --- code/STLExporter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index 249f0f6f8..e3df2fbff 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -90,8 +90,7 @@ STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool bi const std::locale& l = std::locale("C"); mOutput.imbue(l); if (binary) { - char buf[80]; - for(int i = 0; i < 80; ++i) buf[i] = 0; + char buf[80] = {0} ; buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p'; buf[6] = 'S'; buf[7] = 'c'; buf[8] = 'e'; buf[9] = 'n'; buf[10] = 'e'; mOutput.write(buf, 80); @@ -101,6 +100,7 @@ STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool bi meshnum++; } } + AI_SWAP4(meshnum); mOutput.write((char *)&meshnum, 4); for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { WriteMeshBinary(pScene->mMeshes[i]); @@ -157,13 +157,15 @@ void STLExporter :: WriteMeshBinary(const aiMesh* m) nor.Normalize(); } float nx = nor.x, ny = nor.y, nz = nor.z; + AI_SWAP4(nx); AI_SWAP4(ny); AI_SWAP4(nz); mOutput.write((char *)&nx, 4); mOutput.write((char *)&ny, 4); mOutput.write((char *)&nz, 4); for(unsigned int a = 0; a < f.mNumIndices; ++a) { const aiVector3D& v = m->mVertices[f.mIndices[a]]; float vx = v.x, vy = v.y, vz = v.z; + AI_SWAP4(vx); AI_SWAP4(vy); AI_SWAP4(vz); mOutput.write((char *)&vx, 4); mOutput.write((char *)&vy, 4); mOutput.write((char *)&vz, 4); } - char dummy[2]; + char dummy[2] = {0}; mOutput.write(dummy, 2); } } From a90e208e6d15966e88baf284bb4c0fe3495662d3 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Fri, 9 Aug 2013 19:10:56 -0400 Subject: [PATCH 015/104] Fixed parameter type mismatch in StreamReader. --- code/StreamReader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/StreamReader.h b/code/StreamReader.h index 8d40922e0..8301d1b27 100644 --- a/code/StreamReader.h +++ b/code/StreamReader.h @@ -193,7 +193,7 @@ public: // --------------------------------------------------------------------- /** Increase the file pointer (relative seeking) */ - void IncPtr(int plus) { + void IncPtr(size_t plus) { current += plus; if (current > limit) { throw DeadlyImportError("End of file or read limit was reached"); From 9b591fadb870dbd7b09a0858d4976ff7cda9ae3d Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Fri, 9 Aug 2013 19:52:15 -0400 Subject: [PATCH 016/104] Fixes for uninitialized variable warnings. --- code/FBXBinaryTokenizer.cpp | 3 ++- code/FBXConverter.cpp | 2 +- code/MaterialSystem.cpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp index c7fdb8374..b5f151c15 100644 --- a/code/FBXBinaryTokenizer.cpp +++ b/code/FBXBinaryTokenizer.cpp @@ -232,7 +232,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, // compute length based on type and check against the stored value if(encoding == 0) { - uint32_t stride; + uint32_t stride = 0; switch(type) { case 'f': @@ -248,6 +248,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, default: ai_assert(false); }; + ai_assert(stride > 0); if(length * stride != comp_len) { TokenizeError("cannot ReadData, calculated data stride differs from what the file claims",input, cursor); } diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 3ad6790f7..342c5f144 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1848,7 +1848,7 @@ private: }} #endif - const AnimationCurveNode* curve_node; + const AnimationCurveNode* curve_node = NULL; BOOST_FOREACH(const AnimationCurveNode* node, curves) { ai_assert(node); diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index 36100ec48..50c403fe1 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -102,7 +102,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat, } // data is given in floats, simply copy it - unsigned int iWrite; + unsigned int iWrite = 0; if( aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) { iWrite = prop->mDataLength / sizeof(float); if (pMax) { @@ -175,7 +175,7 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat, } // data is given in ints, simply copy it - unsigned int iWrite; + unsigned int iWrite = 0; if( aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) { iWrite = prop->mDataLength / sizeof(int32_t); if (pMax) { From a2fb2dfb280c21d893f48a3b57b2c3f803100227 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Mon, 12 Aug 2013 23:42:30 +0200 Subject: [PATCH 017/104] Exporter: if the scene data was converted to verbose format to meet the requirements of a preprocessing step, we should un-verbosify it again before the actual exporter is run. --- code/Exporter.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 3b2badab7..b6d15e25f 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -60,6 +60,7 @@ Here we implement only the C++ interface (Assimp::Exporter). #include "BaseProcess.h" #include "Importer.h" // need this for GetPostProcessingStepInstanceList() +#include "JoinVerticesProcess.h" #include "MakeVerboseFormat.h" #include "ConvertToLHProcess.h" @@ -86,7 +87,7 @@ Exporter::ExportFormatEntry gExporters[] = #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, - aiProcess_GenNormals | aiProcess_PreTransformVertices), + aiProcess_GenNormals /*| aiProcess_PreTransformVertices */), #endif #ifndef ASSIMP_BUILD_NO_STL_EXPORTER @@ -260,6 +261,7 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const // If the input scene is not in verbose format, but there is at least postprocessing step that relies on it, // we need to run the MakeVerboseFormat step first. + bool must_join_again = false; if (scenecopy->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) { bool verbosify = false; @@ -277,6 +279,10 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const MakeVerboseFormatProcess proc; proc.Execute(scenecopy.get()); + + if(!(exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) { + must_join_again = true; + } } } @@ -321,6 +327,11 @@ aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const privOut->mPPStepsApplied |= pp; } + if(must_join_again) { + JoinVerticesProcess proc; + proc.Execute(scenecopy.get()); + } + exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get()); } catch (DeadlyExportError& err) { From fe248c89ecd2383c977558579af3fc6ea524e1c8 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Mon, 12 Aug 2013 23:42:46 +0200 Subject: [PATCH 018/104] Exporter.hpp: predeclare IOSystem --- include/assimp/Exporter.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 30db01508..20cd7dc6e 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { class ExporterPimpl; + class IOSystem; // ---------------------------------------------------------------------------------- From 1c7cad00ce0e93f17f66cec1526eadd719e901c1 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 13 Aug 2013 23:37:08 +0200 Subject: [PATCH 019/104] update : add initial code convention file. Signed-off-by: Kim Kulling --- CodeConventions.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CodeConventions.txt diff --git a/CodeConventions.txt b/CodeConventions.txt new file mode 100644 index 000000000..dcbe17ed6 --- /dev/null +++ b/CodeConventions.txt @@ -0,0 +1,14 @@ + =============================================== + The Asset-Importer-Library Coding conventions + =============================================== + + If you want to participate to the Asset-Importer_Library please have a look + onto these coding conventions and try to follow them. They are more or less + some kind of guide line to help others coming into the code and help all + the Asset-Importer-Library users. + + Tab width + =========== + The tab width shall be 4 spaces. + + \ No newline at end of file From a6ddce7758119c51e9c26232af002cbb1bec14c4 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:11:23 -0400 Subject: [PATCH 020/104] Added name member to Collada::Mesh. --- code/ColladaHelper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index f9bd4fb5a..956665198 100644 --- a/code/ColladaHelper.h +++ b/code/ColladaHelper.h @@ -321,6 +321,8 @@ struct Mesh for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i) mNumUVComponents[i] = 2; } + + std::string mName; // just to check if there's some sophisticated addressing involved... // which we don't support, and therefore should warn about. From a540c6255c55fd2192367f9408d597d1b0a86dc2 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:12:58 -0400 Subject: [PATCH 021/104] Added parsing of Collada mesh names. --- code/ColladaParser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 442896a39..767347695 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -1492,6 +1492,13 @@ void ColladaParser::ReadGeometryLibrary() // create a mesh and store it in the library under its ID Mesh* mesh = new Mesh; mMeshLibrary[id] = mesh; + + // read the mesh name if it exists + const int nameIndex = TestAttribute("name"); + if(nameIndex != -1) + { + mesh->mName = mReader->getAttributeValue(nameIndex); + } // read on from there ReadGeometry( mesh); From 57e34cc90a84b3179e67d4e41839771b5fb086c3 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:14:19 -0400 Subject: [PATCH 022/104] Added loading of mesh name from Collada mesh to aiMesh struct. --- code/ColladaLoader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index a97ea2c6a..c40d3b8f2 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -541,6 +541,8 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: const Collada::Controller* pSrcController, size_t pStartVertex, size_t pStartFace) { aiMesh* dstMesh = new aiMesh; + + dstMesh->mName = pSrcMesh->mName; // count the vertices addressed by its faces const size_t numVertices = std::accumulate( pSrcMesh->mFaceSize.begin() + pStartFace, From d23430c4bdc740e6682e7efc793b80f10a3040e6 Mon Sep 17 00:00:00 2001 From: Sherief Farouk Date: Thu, 15 Aug 2013 00:21:00 -0400 Subject: [PATCH 023/104] Collada mesh name is copied from id only if there was no name attribute in the node. --- code/ColladaLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index c40d3b8f2..7e4704b8f 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -521,7 +521,10 @@ void ColladaLoader::BuildMeshesForNode( const ColladaParser& pParser, const Coll // assign the material index dstMesh->mMaterialIndex = matIdx; - dstMesh->mName = mid.mMeshOrController; + if(dstMesh->mName.length == 0) + { + dstMesh->mName = mid.mMeshOrController; + } } } } From d62c929b7a22261f7c1471d037f39afec0442c85 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 15 Aug 2013 20:51:34 +0200 Subject: [PATCH 024/104] bugfix : fix compiler warning. Signed-off-by: Kim Kulling --- contrib/poly2tri/poly2tri/common/shapes.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/poly2tri/poly2tri/common/shapes.cc b/contrib/poly2tri/poly2tri/common/shapes.cc index f5fe29669..4080445a7 100644 --- a/contrib/poly2tri/poly2tri/common/shapes.cc +++ b/contrib/poly2tri/poly2tri/common/shapes.cc @@ -164,6 +164,8 @@ int Triangle::Index(const Point* p) return 2; } assert(0); + + return 0; } int Triangle::EdgeIndex(const Point* p1, const Point* p2) @@ -223,6 +225,8 @@ Point* Triangle::PointCW(Point& point) return points_[1]; } assert(0); + + return 0; } // The point counter-clockwise to given point @@ -236,6 +240,8 @@ Point* Triangle::PointCCW(Point& point) return points_[0]; } assert(0); + + return 0; } // The neighbor clockwise to given point From 6eaff77a7c606f090aadb67e597dc151bb473b56 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 15 Aug 2013 20:57:54 +0200 Subject: [PATCH 025/104] bugfix : fix pedantic vs2012 warnings. Signed-off-by: Kim Kulling --- code/BlobIOSystem.h | 6 +++--- code/Exporter.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/BlobIOSystem.h b/code/BlobIOSystem.h index c98aa9008..cd48b8826 100644 --- a/code/BlobIOSystem.h +++ b/code/BlobIOSystem.h @@ -88,9 +88,9 @@ public: // ------------------------------------------------------------------- - virtual size_t Read(void* pvBuffer, - size_t pSize, - size_t pCount) + virtual size_t Read( void *, + size_t, + size_t ) { return 0; } diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 5e9a86410..4e40a704a 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -202,7 +202,7 @@ bool Exporter :: IsDefaultIOHandler() const // ------------------------------------------------------------------------------------------------ -const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing ) +const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int ) { if (pimpl->blob) { delete pimpl->blob; From 7db5dcb357e0d37efdfa95215d49568404a103bf Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 16 Aug 2013 18:10:19 -0700 Subject: [PATCH 026/104] Improve STL representation detection Previously, the STL loader relied on a string check at the start of the buffer to determine if the STL file was of ASCII representation. This led to certain false-positives for binary STL files with the magic string present in their header. This patch addresses the issue by adding a proper binary check to the representation detection. --- code/STLLoader.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 8bfde9656..fff58d04a 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; +namespace { static const aiImporterDesc desc = { "Stereolithography (STL) Importer", "", @@ -64,6 +65,34 @@ static const aiImporterDesc desc = { "stl" }; +// A valid binary STL buffer should consist of the following elements, in order: +// 1) 80 byte header +// 2) 4 byte face count +// 3) 50 bytes per face +bool IsBinarySTL(const char* buffer, unsigned int fileSize) { + if (fileSize < 84) + return false; + + const uint32_t faceCount = *reinterpret_cast(buffer + 80); + const uint32_t expectedBinaryFileSize = faceCount * 50 + 84; + + return expectedBinaryFileSize == fileSize; +} + +// An ascii STL buffer will begin with "solid NAME", where NAME is optional. +// Note: The "solid NAME" check is necessary, but not sufficient, to determine +// if the buffer is ASCII; a binary header could also begin with "solid NAME". +bool IsAsciiSTL(const char* buffer, unsigned int fileSize) { + if (IsBinarySTL(buffer, fileSize)) + return false; + + if (fileSize < 5) + return false; + + return strncmp(buffer, "solid", 5) == 0; +} +} // namespace + // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer STLImporter::STLImporter() @@ -136,12 +165,13 @@ void STLImporter::InternReadFile( const std::string& pFile, bool bMatClr = false; - // check whether the file starts with 'solid' - - // in this case we can simply assume it IS a text file. finished. - if (!::strncmp(mBuffer,"solid",5)) { + if (IsBinarySTL(mBuffer, fileSize)) { + bMatClr = LoadBinaryFile(); + } else if (IsAsciiSTL(mBuffer, fileSize)) { LoadASCIIFile(); + } else { + throw DeadlyImportError( "Failed to determine STL storage representation for " + pFile + "."); } - else bMatClr = LoadBinaryFile(); // now copy faces pMesh->mFaces = new aiFace[pMesh->mNumFaces]; From 9f2336e5d42bba086e6835b12a38b0062bcddd1c Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 20 Aug 2013 20:02:07 -0700 Subject: [PATCH 027/104] Fix Android compilation with STLport Satisfy STLport's runtime_error constructor with an explicit string argument. --- contrib/poly2tri/poly2tri/common/shapes.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/poly2tri/poly2tri/common/shapes.h b/contrib/poly2tri/poly2tri/common/shapes.h index d63f6a5be..4f691838f 100644 --- a/contrib/poly2tri/poly2tri/common/shapes.h +++ b/contrib/poly2tri/poly2tri/common/shapes.h @@ -38,6 +38,7 @@ #include #include #include +#include namespace p2t { @@ -137,8 +138,8 @@ struct Edge { p = &p2; } else if (p1.x == p2.x) { // Repeat points - // ASSIMP_CHANGE (aramis_acg) - throw std::runtime_error("repeat points"); + // ASSIMP_CHANGE (aramis_acg) + throw std::runtime_error(std::string("repeat points")); //assert(false); } } From f25b84c9a58a9cb709d3b57360243af1c103213f Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 21 Aug 2013 12:23:52 +0200 Subject: [PATCH 028/104] Update Readme.md --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index 8b476c6cf..4f5ab1d7f 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,6 @@ Its abbreviated name under which it is commonly known is __assimp__. This is the development trunk of assimp containing the latest features and bugfixes. For productive use though, we recommend one of the stable releases available from [assimp.sf.net](http://assimp.sf.net) or from *nix package repositories. According to [Travis-CI] (https://travis-ci.org/), the current build status of the trunk is [![Build Status](https://travis-ci.org/assimp/assimp.png)](https://travis-ci.org/assimp/assimp) - #### 1.1 Supported file formats #### The library provides importers for a lot of file formats, including: From 27727f692b82ca09551788810a8bc420299c6c88 Mon Sep 17 00:00:00 2001 From: "Alexander C. Gessler" Date: Tue, 27 Aug 2013 20:17:30 +0000 Subject: [PATCH 029/104] add missing header to lexical_cast replacement --- code/BoostWorkaround/boost/lexical_cast.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/BoostWorkaround/boost/lexical_cast.hpp b/code/BoostWorkaround/boost/lexical_cast.hpp index 3f055f35f..7724e4607 100644 --- a/code/BoostWorkaround/boost/lexical_cast.hpp +++ b/code/BoostWorkaround/boost/lexical_cast.hpp @@ -3,6 +3,8 @@ #ifndef __AI_BOOST_WORKAROUND_LEXICAL_CAST #define __AI_BOOST_WORKAROUND_LEXICAL_CAST +#include + namespace boost { From 169e5b9f35acd505ae2e664ca363a84d6bb7794a Mon Sep 17 00:00:00 2001 From: abma Date: Thu, 29 Aug 2013 06:31:10 +0200 Subject: [PATCH 030/104] fix error "Chunk is too large" with gcc >=4.7.0 / mingw64 --- include/assimp/Compiler/pushpack1.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/assimp/Compiler/pushpack1.h b/include/assimp/Compiler/pushpack1.h index 14edc5cd4..71e6089bd 100644 --- a/include/assimp/Compiler/pushpack1.h +++ b/include/assimp/Compiler/pushpack1.h @@ -25,7 +25,7 @@ # pragma pack(push,1) # define PACK_STRUCT #elif defined( __GNUC__ ) -# define PACK_STRUCT __attribute__((packed)) +# define PACK_STRUCT __attribute__((gcc_struct, __packed__)) #else # error Compiler not supported #endif From 0edb78d940463675f25d84bc8c007806f56890c6 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Mon, 2 Sep 2013 21:32:20 +0200 Subject: [PATCH 031/104] Add aiFreeScene() API for symmetry with aiCopyScene. --- code/AssimpCExport.cpp | 11 +++++++++++ include/assimp/cexport.h | 12 +++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/code/AssimpCExport.cpp b/code/AssimpCExport.cpp index 469842482..9483eb2d3 100644 --- a/code/AssimpCExport.cpp +++ b/code/AssimpCExport.cpp @@ -64,6 +64,7 @@ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex return Exporter().GetExportFormatDescription(pIndex); } + // ------------------------------------------------------------------------------------------------ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) { @@ -74,6 +75,16 @@ ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) SceneCombiner::CopyScene(pOut,pIn,true); } + +// ------------------------------------------------------------------------------------------------ +ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn) +{ + // note: aiReleaseImport() is also able to delete scene copies, but in addition + // it also handles scenes with import metadata. + delete pIn; +} + + // ------------------------------------------------------------------------------------------------ ASSIMP_API aiReturn aiExportScene( const aiScene* pScene, const char* pFormatId, const char* pFileName, unsigned int pPreprocessing ) { diff --git a/include/assimp/cexport.h b/include/assimp/cexport.h index b044dfd25..14b9be189 100644 --- a/include/assimp/cexport.h +++ b/include/assimp/cexport.h @@ -95,16 +95,22 @@ ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size // -------------------------------------------------------------------------------- -/** Create a modifyable copy of a scene. +/** Create a modifiable copy of a scene. * This is useful to import files via Assimp, change their topology and * export them again. Since the scene returned by the various importer functions - * is const, a modifyable copy is needed. + * is const, a modifiable copy is needed. * @param pIn Valid scene to be copied - * @param pOut Receives a modifyable copy of the scene. + * @param pOut Receives a modifyable copy of the scene. Use aiFreeScene() to + * delete it again. */ ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, C_STRUCT aiScene** pOut); + +// -------------------------------------------------------------------------------- +/** Frees a scene copy created using aiCopyScene() */ +ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn); + // -------------------------------------------------------------------------------- /** Exports the given scene to a chosen file format and writes the result file(s) to disk. * @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. From fd0b3490d1d8a53249f3a8cf19e8fde809e17df8 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Mon, 2 Sep 2013 21:33:43 +0200 Subject: [PATCH 032/104] Clarify exporter doc: how to get a modifiable copy of a previously imported scene. --- include/assimp/Exporter.hpp | 8 ++++++-- include/assimp/cexport.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 30db01508..407fae4e3 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -167,7 +167,9 @@ public: * @return the exported data or NULL in case of error. * @note If the Exporter instance did already hold a blob from * a previous call to #ExportToBlob, it will be disposed. - * Any IO handlers set via #SetIOHandler are ignored here.*/ + * Any IO handlers set via #SetIOHandler are ignored here. + * @note Use aiCopyScene() to get a modifiable copy of a previously + * imported scene. */ const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u ); inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u ); @@ -196,7 +198,9 @@ public: * is triangulation - whilst you can enforce it by specifying * the #aiProcess_Triangulate flag, most export formats support only * triangulate data so they would run the step even if it wasn't requested. - * @return AI_SUCCESS if everything was fine. */ + * @return AI_SUCCESS if everything was fine. + * @note Use aiCopyScene() to get a modifiable copy of a previously + * imported scene.*/ aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u); inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u); diff --git a/include/assimp/cexport.h b/include/assimp/cexport.h index 14b9be189..797d5db1a 100644 --- a/include/assimp/cexport.h +++ b/include/assimp/cexport.h @@ -144,6 +144,8 @@ ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn); * the #aiProcess_Triangulate flag, most export formats support only * triangulate data so they would run the step anyway. * @return a status code indicating the result of the export +* @note Use aiCopyScene() to get a modifiable copy of a previously +* imported scene. */ ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, const char* pFormatId, @@ -163,6 +165,8 @@ ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, * @param pPreprocessing Please see the documentation for #aiExportScene * @return a status code indicating the result of the export * @note Include for the definition of #aiFileIO. +* @note Use aiCopyScene() to get a modifiable copy of a previously +* imported scene. */ ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, const char* pFormatId, From d45689a2c163306cc7f86fee99ece9ed2eac51d3 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 13:52:49 +0200 Subject: [PATCH 033/104] CMake for assimp_view: copy dlls from assimp build over to output folder. --- tools/assimp_view/CMakeLists.txt | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index e3f15e9d8..dc7ae543a 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -1,18 +1,16 @@ FIND_PACKAGE(DirectX REQUIRED) -# Make sure the compiler can find include files from our Hello library. -include_directories ( + +INCLUDE_DIRECTORIES ( ${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/code ${DirectX_INCLUDE_DIR} ) -# Make sure the linker can find the Hello library once it is built. -link_directories (${Assimp_BINARY_DIR} ${AssetImporter_BINARY_DIR}/lib) +# Make sure the linker can find the Assimp library once it is built. +LINK_DIRECTORIES (${Assimp_BINARY_DIR} ${AssetImporter_BINARY_DIR}/lib) -# Add executable called "helloDemo" that is built from the source files -# "demo.cxx" and "demo_b.cxx". The extensions are automatically found. -add_executable( assimp_viewer WIN32 +ADD_EXECUTABLE( assimp_viewer WIN32 AnimEvaluator.cpp Background.cpp Display.cpp @@ -46,12 +44,17 @@ add_executable( assimp_viewer WIN32 SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) IF( WIN32 ) - ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) + ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) ENDIF( WIN32 ) -# Link the executable to the Hello library. -target_link_libraries ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) +# +ADD_CUSTOM_COMMAND(TARGET assimp_viewer + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) + +# Link the executable to the assimp + dx libs. +TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) INSTALL( TARGETS assimp_viewer DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev From 995978b16338e83a86441bf892324e9c38af22b7 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 13:55:02 +0200 Subject: [PATCH 034/104] CMake for assimp_cmd: also copy over assimp output binary as PRE_BUILD event. --- tools/assimp_cmd/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index 9d1a291d2..ec31e76b0 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -19,6 +19,11 @@ ADD_EXECUTABLE( assimp_cmd SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) +# +ADD_CUSTOM_COMMAND(TARGET assimp_cmd + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) + TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES}) SET_TARGET_PROPERTIES( assimp_cmd PROPERTIES OUTPUT_NAME assimp From f8f7e2468c6544b244b54c5c3255525d17f24821 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 14:10:26 +0200 Subject: [PATCH 035/104] CMake: use copy_if_different instead of copy and only run PRE_BUILD on Windows as it is not required on *nix anyway. --- tools/assimp_cmd/CMakeLists.txt | 9 +++++---- tools/assimp_view/CMakeLists.txt | 9 ++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index ec31e76b0..8581eba09 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -19,10 +19,11 @@ ADD_EXECUTABLE( assimp_cmd SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) -# -ADD_CUSTOM_COMMAND(TARGET assimp_cmd - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) +IF( WIN32 ) + ADD_CUSTOM_COMMAND(TARGET assimp_cmd + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) +ENDIF( WIN32 ) TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES}) SET_TARGET_PROPERTIES( assimp_cmd PROPERTIES diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index dc7ae543a..4673cfeb4 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -43,15 +43,14 @@ ADD_EXECUTABLE( assimp_viewer WIN32 SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) -IF( WIN32 ) - ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) - ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) -ENDIF( WIN32 ) +ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) +ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) + # ADD_CUSTOM_COMMAND(TARGET assimp_viewer PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) # Link the executable to the assimp + dx libs. TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) From e9ffabbfeeac863923994bbf957cd0946f674d09 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 14:27:24 +0200 Subject: [PATCH 036/104] LWO: ignore chunks of length zero. --- code/LWOLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index 5898eb8f6..0d03575ae 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -1296,6 +1296,11 @@ void LWOImporter::LoadLWO2File() uint8_t* const next = mFileBuffer+head->length; unsigned int iUnnamed = 0; + if(!head->length) { + mFileBuffer = next; + continue; + } + switch (head->type) { // new layer From ab2e81d004608d40b97e4d6283fadd22a0742dcd Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 14:27:56 +0200 Subject: [PATCH 037/104] LWO: take last CLIP with the requested index (CLIPs ordered by ordinal string) --- code/LWOMaterial.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 0e8c5ecbd..a9ee1e3d7 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -167,19 +167,21 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex // The older LWOB format does not use indirect references to clips. // The file name of a texture is directly specified in the tex chunk. if (mIsLWO2) { - // find the corresponding clip - ClipList::iterator clip = mClips.begin(); + // find the corresponding clip (take the last one if multiple + // share the same index) + ClipList::iterator end = mClips.end(), candidate = end; temp = (*it).mClipIdx; - for (ClipList::iterator end = mClips.end(); clip != end; ++clip) { - if ((*clip).idx == temp) - break; + for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) { + if ((*clip).idx == temp) { + candidate = clip; + } } - if (mClips.end() == clip) { + if (candidate == end) { DefaultLogger::get()->error("LWO2: Clip index is out of bounds"); temp = 0; - // fixme: appearently some LWO files shipping with Doom3 don't + // fixme: apparently some LWO files shipping with Doom3 don't // have clips at all ... check whether that's true or whether // it's a bug in the loader. @@ -188,16 +190,16 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex //continue; } else { - if (Clip::UNSUPPORTED == (*clip).type) { + if (Clip::UNSUPPORTED == (*candidate).type) { DefaultLogger::get()->error("LWO2: Clip type is not supported"); continue; } - AdjustTexturePath((*clip).path); - s.Set((*clip).path); + AdjustTexturePath((*candidate).path); + s.Set((*candidate).path); // Additional image settings int flags = 0; - if ((*clip).negate) { + if ((*candidate).negate) { flags |= aiTextureFlags_Invert; } pcMat->AddProperty(&flags,1,AI_MATKEY_TEXFLAGS(type,cur)); From de03173e6d21ac8fb7ee6d6243d7c8f9e3a511ad Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 14:37:49 +0200 Subject: [PATCH 038/104] CMake: simplify. --- tools/assimp_cmd/CMakeLists.txt | 2 +- tools/assimp_view/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index 8581eba09..e6f34fefb 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -22,7 +22,7 @@ SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) IF( WIN32 ) ADD_CUSTOM_COMMAND(TARGET assimp_cmd PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) ENDIF( WIN32 ) TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES}) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 4673cfeb4..167601b24 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -50,7 +50,7 @@ ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) # ADD_CUSTOM_COMMAND(TARGET assimp_viewer PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} $) + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) # Link the executable to the assimp + dx libs. TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) From 69acdabdef0dd72a7c12d7cc742bc55aee71baf1 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 14:42:42 +0200 Subject: [PATCH 039/104] CMake: make assimp_view/assimp_cmd's file copying DEPEND on assimp. --- tools/assimp_cmd/CMakeLists.txt | 3 ++- tools/assimp_view/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index e6f34fefb..899a8e02a 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -22,7 +22,8 @@ SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) IF( WIN32 ) ADD_CUSTOM_COMMAND(TARGET assimp_cmd PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + MAIN_DEPENDENCY assimp) ENDIF( WIN32 ) TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES}) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 167601b24..655a38571 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -50,7 +50,8 @@ ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) # ADD_CUSTOM_COMMAND(TARGET assimp_viewer PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + MAIN_DEPENDENCY assimp) # Link the executable to the assimp + dx libs. TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib ) From 69e9e7c40308444f4762ce0b4835b0b3e62c162c Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 15:17:04 +0200 Subject: [PATCH 040/104] aiMaterial: use overloads instead of template specializations. This fixes multiple instances of int material properties being accidentally registered as BINARY because the given type was unsigned int. --- include/assimp/material.h | 61 +++++++++++++++++++++++++++++++++++++ include/assimp/material.inl | 43 +++++++++----------------- 2 files changed, 76 insertions(+), 28 deletions(-) diff --git a/include/assimp/material.h b/include/assimp/material.h index 25cb3d6e0..9151c8ec5 100644 --- a/include/assimp/material.h +++ b/include/assimp/material.h @@ -691,6 +691,12 @@ public: aiReturn Get(const char* pKey,unsigned int type, unsigned int idx, Type* pOut, unsigned int* pMax) const; + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, int* pOut, unsigned int* pMax) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, float* pOut, unsigned int* pMax) const; + // ------------------------------------------------------------------- /** @brief Retrieve a Type value with a specific key * from the material @@ -705,6 +711,25 @@ public: aiReturn Get(const char* pKey,unsigned int type, unsigned int idx,Type& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, int& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, float& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, aiString& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, aiColor3D& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, aiColor4D& pOut) const; + + aiReturn Get(const char* pKey,unsigned int type, + unsigned int idx, aiUVTransform& pOut) const; + // ------------------------------------------------------------------- /** Get the number of textures for a particular texture type. * @param type Texture type to check for @@ -797,6 +822,42 @@ public: unsigned int type = 0, unsigned int index = 0); + aiReturn AddProperty (const aiVector3D* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + + aiReturn AddProperty (const aiColor3D* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + + aiReturn AddProperty (const aiColor4D* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + + aiReturn AddProperty (const int* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + + aiReturn AddProperty (const float* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + + aiReturn AddProperty (const aiUVTransform* pInput, + unsigned int pNumValues, + const char* pKey, + unsigned int type = 0, + unsigned int index = 0); + // ------------------------------------------------------------------------------ /** @brief Remove a given key from the list. * diff --git a/include/assimp/material.inl b/include/assimp/material.inl index 5e9051f4e..027149d00 100644 --- a/include/assimp/material.inl +++ b/include/assimp/material.inl @@ -89,7 +89,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, } iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type)); - memcpy(pOut,prop->mData,iNum * sizeof(Type)); + ::memcpy(pOut,prop->mData,iNum * sizeof(Type)); if (pMax) { *pMax = iNum; } @@ -115,51 +115,45 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, return AI_FAILURE; } - memcpy(&pOut,prop->mData,sizeof(Type)); + ::memcpy(&pOut,prop->mData,sizeof(Type)); } return ret; } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,float* pOut, unsigned int* pMax) const { return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax); } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,int* pOut, unsigned int* pMax) const { return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax); } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,float& pOut) const { return aiGetMaterialFloat(this,pKey,type,idx,&pOut); } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,int& pOut) const { return aiGetMaterialInteger(this,pKey,type,idx,&pOut); } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,aiColor4D& pOut) const { return aiGetMaterialColor(this,pKey,type,idx,&pOut); } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,aiColor3D& pOut) const { aiColor4D c; @@ -168,8 +162,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, return ret; } // --------------------------------------------------------------------------- -template <> -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, +inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, unsigned int idx,aiString& pOut) const { return aiGetMaterialString(this,pKey,type,idx,&pOut); @@ -190,8 +183,7 @@ aiReturn aiMaterial::AddProperty (const TYPE* pInput, } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const float* pInput, +inline aiReturn aiMaterial::AddProperty(const float* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, @@ -203,8 +195,7 @@ inline aiReturn aiMaterial::AddProperty (const float* pInput, } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const aiUVTransform* pInput, +inline aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, @@ -216,8 +207,7 @@ inline aiReturn aiMaterial::AddProperty (const aiUVTransform* pIn } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const aiColor4D* pInput, +inline aiReturn aiMaterial::AddProperty(const aiColor4D* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, @@ -229,8 +219,7 @@ inline aiReturn aiMaterial::AddProperty (const aiColor4D* pInput, } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const aiColor3D* pInput, +inline aiReturn aiMaterial::AddProperty(const aiColor3D* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, @@ -242,8 +231,7 @@ inline aiReturn aiMaterial::AddProperty (const aiColor3D* pInput, } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const aiVector3D* pInput, +inline aiReturn aiMaterial::AddProperty(const aiVector3D* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, @@ -255,8 +243,7 @@ inline aiReturn aiMaterial::AddProperty (const aiVector3D* pInput, } // --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty (const int* pInput, +inline aiReturn aiMaterial::AddProperty(const int* pInput, const unsigned int pNumValues, const char* pKey, unsigned int type, From 0f5272cb508cf32dcba6c14a6b626fca96b95817 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 18:35:41 +0200 Subject: [PATCH 041/104] Obj: set aiMesh::mPrimitiveTypes --- code/ObjFileImporter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index bb12785e1..aed160738 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -276,14 +276,23 @@ void ObjFileImporter::createTopology(const ObjFile::Model* pModel, for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++) { ObjFile::Face* const inp = pObjMesh->m_Faces[ index ]; + if (inp->m_PrimitiveType == aiPrimitiveType_LINE) { pMesh->mNumFaces += inp->m_pVertices->size() - 1; + pMesh->mPrimitiveTypes |= aiPrimitiveType_LINE; } else if (inp->m_PrimitiveType == aiPrimitiveType_POINT) { pMesh->mNumFaces += inp->m_pVertices->size(); + pMesh->mPrimitiveTypes |= aiPrimitiveType_POINT; } else { ++pMesh->mNumFaces; + if (inp->m_pVertices->size() > 3) { + pMesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON; + } + else { + pMesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE; + } } } From e80886f12c748870c73fff8a0258d3a9612118e9 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Wed, 18 Sep 2013 19:34:03 +0200 Subject: [PATCH 042/104] Obj: support line continuations with \ (fixes #91) --- code/ObjFileParser.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 83f25c40a..ab8fdd124 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -200,6 +200,8 @@ void ObjFileParser::copyNextWord(char *pBuffer, size_t length) break; ++m_DataIt; } + + ai_assert(index < length); pBuffer[index] = '\0'; } @@ -207,16 +209,30 @@ void ObjFileParser::copyNextWord(char *pBuffer, size_t length) // Copy the next line into a temporary buffer void ObjFileParser::copyNextLine(char *pBuffer, size_t length) { - size_t index = 0; - while (m_DataIt != m_DataItEnd) - { - if (*m_DataIt == '\n' || *m_DataIt == '\r' || index == length-1) - break; + size_t index = 0u; - pBuffer[ index ] = *m_DataIt; - ++index; - ++m_DataIt; + // some OBJ files have line continuations using \ (such as in C++ et al) + bool continuation = false; + for (;m_DataIt != m_DataItEnd && index < length-1; ++m_DataIt) + { + const char c = *m_DataIt; + if (c == '\\') { + continuation = true; + continue; + } + + if (c == '\n' || c == '\r') { + if(continuation) { + pBuffer[ index++ ] = ' '; + continue; + } + break; + } + + continuation = false; + pBuffer[ index++ ] = c; } + ai_assert(index < length); pBuffer[ index ] = '\0'; } From 90179ec6e3e6f46a3da62cceff0dffa4faac53b6 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Sat, 21 Sep 2013 10:59:13 -0700 Subject: [PATCH 043/104] Enable SimpleAssimpViewX compilation on OSX Update the XCode projects, and fix several compilation problems. --- .../ModelLoaderHelperClasses.h | 8 +- samples/SimpleAssimpViewX/MyDocument.h | 13 +- samples/SimpleAssimpViewX/MyDocument.mm | 24 ++- .../project.pbxproj | 176 ++++++++++-------- .../xcode3/assimp.xcodeproj/project.pbxproj | 32 ---- 5 files changed, 121 insertions(+), 132 deletions(-) diff --git a/samples/SimpleAssimpViewX/ModelLoaderHelperClasses.h b/samples/SimpleAssimpViewX/ModelLoaderHelperClasses.h index 6e6729bc7..0e6dfab3c 100644 --- a/samples/SimpleAssimpViewX/ModelLoaderHelperClasses.h +++ b/samples/SimpleAssimpViewX/ModelLoaderHelperClasses.h @@ -8,10 +8,10 @@ #import #import -#import "aiColor4D.h" -#import "aiVector3D.h" -#import "aiVector2D.h" -#import "aiMatrix4x4.h" +#import "color4.h" +#import "vector3.h" +#import "vector2.h" +#import "matrix4x4.h" /* workflow: diff --git a/samples/SimpleAssimpViewX/MyDocument.h b/samples/SimpleAssimpViewX/MyDocument.h index 11e836321..16745dc3c 100644 --- a/samples/SimpleAssimpViewX/MyDocument.h +++ b/samples/SimpleAssimpViewX/MyDocument.h @@ -10,9 +10,10 @@ #import "ModelLoaderHelperClasses.h" // assimp include files. These three are usually needed. -#import "assimp.h" -#import "aiPostProcess.h" -#import "aiScene.h" +#import "cimport.h" +#import "postprocess.h" +#import "scene.h" +#import "types.h" #import #import @@ -29,7 +30,7 @@ // Assimp Stuff aiScene* _scene; - struct aiVector3D scene_min, scene_max, scene_center; + aiVector3D scene_min, scene_max, scene_center; double normalizedScale; // Our array of textures. @@ -53,7 +54,7 @@ - (void) deleteGLResourcesInContext:(CGLContextObj)cgl_ctx; - (void) loadTexturesInContext:(CGLContextObj)cgl_ctx withModelPath:(NSString*) modelPath; -- (void) getBoundingBoxWithMinVector:(struct aiVector3D*) min maxVectr:(struct aiVector3D*) max; -- (void) getBoundingBoxForNode:(const struct aiNode*)nd minVector:(struct aiVector3D*) min maxVector:(struct aiVector3D*) max matrix:(struct aiMatrix4x4*) trafo; +- (void) getBoundingBoxWithMinVector:(aiVector3D*) min maxVectr:(aiVector3D*) max; +- (void) getBoundingBoxForNode:(const aiNode*)nd minVector:(aiVector3D*) min maxVector:(aiVector3D*) max matrix:(aiMatrix4x4*) trafo; @end diff --git a/samples/SimpleAssimpViewX/MyDocument.mm b/samples/SimpleAssimpViewX/MyDocument.mm index 7ff025d07..f074126ca 100644 --- a/samples/SimpleAssimpViewX/MyDocument.mm +++ b/samples/SimpleAssimpViewX/MyDocument.mm @@ -6,7 +6,8 @@ // Copyright __MyCompanyName__ 2010 . All rights reserved. // -#import "aiConfig.h" +#import "cimport.h" +#import "config.h" #import "MyDocument.h" #import @@ -16,7 +17,7 @@ #define aisgl_min(x,y) (xx?y:x) -static void color4_to_float4(const struct aiColor4D *c, float f[4]) +static void color4_to_float4(const aiColor4D *c, float f[4]) { f[0] = c->r; f[1] = c->g; @@ -160,7 +161,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS // Load our new path. // only ever give us triangles. - aiSetImportPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT ); + aiPropertyStore* props = aiCreatePropertyStore(); + aiSetImportPropertyInteger(props, AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT ); NSUInteger aiPostProccesFlags; @@ -181,7 +183,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS } // aiProcess_FlipUVs is needed for VAO / VBOs, not sure why. - _scene = (aiScene*) aiImportFile([[openPanel filename] cStringUsingEncoding:[NSString defaultCStringEncoding]], aiPostProccesFlags | aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_PreTransformVertices | 0 ); + _scene = (aiScene*) aiImportFileExWithProperties([[openPanel filename] cStringUsingEncoding:[NSString defaultCStringEncoding]], aiPostProccesFlags | aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_PreTransformVertices | 0, NULL, props); + + aiReleasePropertyStore(props); if (_scene) { @@ -755,9 +759,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS } -- (void) getBoundingBoxWithMinVector:(struct aiVector3D*) min maxVectr:(struct aiVector3D*) max +- (void) getBoundingBoxWithMinVector:(aiVector3D*) min maxVectr:(aiVector3D*) max { - struct aiMatrix4x4 trafo; + aiMatrix4x4 trafo; aiIdentityMatrix4(&trafo); min->x = min->y = min->z = 1e10f; @@ -766,9 +770,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS [self getBoundingBoxForNode:_scene->mRootNode minVector:min maxVector:max matrix:&trafo]; } -- (void) getBoundingBoxForNode:(const struct aiNode*)nd minVector:(struct aiVector3D*) min maxVector:(struct aiVector3D*) max matrix:(struct aiMatrix4x4*) trafo +- (void) getBoundingBoxForNode:(const aiNode*)nd minVector:(aiVector3D*) min maxVector:(aiVector3D*) max matrix:(aiMatrix4x4*) trafo { - struct aiMatrix4x4 prev; + aiMatrix4x4 prev; unsigned int n = 0, t; prev = *trafo; @@ -776,10 +780,10 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS for (; n < nd->mNumMeshes; ++n) { - const struct aiMesh* mesh = _scene->mMeshes[nd->mMeshes[n]]; + const aiMesh* mesh = _scene->mMeshes[nd->mMeshes[n]]; for (t = 0; t < mesh->mNumVertices; ++t) { - struct aiVector3D tmp = mesh->mVertices[t]; + aiVector3D tmp = mesh->mVertices[t]; aiTransformVecByMatrix4(&tmp,trafo); min->x = aisgl_min(min->x,tmp.x); diff --git a/samples/SimpleAssimpViewX/SimpleAssimpViewX.xcodeproj/project.pbxproj b/samples/SimpleAssimpViewX/SimpleAssimpViewX.xcodeproj/project.pbxproj index 71e73044f..625b92cd9 100644 --- a/samples/SimpleAssimpViewX/SimpleAssimpViewX.xcodeproj/project.pbxproj +++ b/samples/SimpleAssimpViewX/SimpleAssimpViewX.xcodeproj/project.pbxproj @@ -9,11 +9,6 @@ /* Begin PBXBuildFile section */ 1B0E9A901279ED43003108E7 /* libassimp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B0E9A8F1279ED43003108E7 /* libassimp.a */; }; 1B0E9A951279EDCD003108E7 /* ModelLoaderHelperClasses.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1B0E9A941279EDCD003108E7 /* ModelLoaderHelperClasses.mm */; }; - 1B0E9AF51279EFCC003108E7 /* aiColor4D.inl in Resources */ = {isa = PBXBuildFile; fileRef = 1B0E9AD71279EFCC003108E7 /* aiColor4D.inl */; }; - 1B0E9AF61279EFCC003108E7 /* aiMaterial.inl in Resources */ = {isa = PBXBuildFile; fileRef = 1B0E9ADD1279EFCC003108E7 /* aiMaterial.inl */; }; - 1B0E9AF71279EFCC003108E7 /* aiMatrix3x3.inl in Resources */ = {isa = PBXBuildFile; fileRef = 1B0E9ADF1279EFCC003108E7 /* aiMatrix3x3.inl */; }; - 1B0E9AF81279EFCC003108E7 /* aiMatrix4x4.inl in Resources */ = {isa = PBXBuildFile; fileRef = 1B0E9AE11279EFCC003108E7 /* aiMatrix4x4.inl */; }; - 1B0E9AF91279EFCC003108E7 /* aiVector3D.inl in Resources */ = {isa = PBXBuildFile; fileRef = 1B0E9AEA1279EFCC003108E7 /* aiVector3D.inl */; }; 1B0E9B1A1279F107003108E7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B0E9B191279F107003108E7 /* libz.dylib */; }; 1BDF446B127772AF00D3E723 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BDF446A127772AF00D3E723 /* OpenGL.framework */; }; 1BDF446F127772AF00D3E723 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BDF446E127772AF00D3E723 /* Quartz.framework */; }; @@ -25,6 +20,13 @@ 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165FFE840EACC02AAC07 /* InfoPlist.strings */; }; 8D15AC310486D014006FF6A4 /* MyDocument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4ACFDCFA73011CA2CEA /* MyDocument.mm */; settings = {ATTRIBUTES = (); }; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + C75BB4F617EE0B64004F0260 /* color4.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB4F117EE0B64004F0260 /* color4.inl */; }; + C75BB4F717EE0B64004F0260 /* quaternion.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB4F517EE0B64004F0260 /* quaternion.inl */; }; + C75BB51417EE0B75004F0260 /* material.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB50317EE0B75004F0260 /* material.inl */; }; + C75BB51517EE0B75004F0260 /* matrix3x3.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB50517EE0B75004F0260 /* matrix3x3.inl */; }; + C75BB51617EE0B75004F0260 /* matrix4x4.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB50717EE0B75004F0260 /* matrix4x4.inl */; }; + C75BB51717EE0B75004F0260 /* vector2.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB51017EE0B75004F0260 /* vector2.inl */; }; + C75BB51817EE0B75004F0260 /* vector3.inl in Resources */ = {isa = PBXBuildFile; fileRef = C75BB51217EE0B75004F0260 /* vector3.inl */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -33,40 +35,6 @@ 1B0E9A8F1279ED43003108E7 /* libassimp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libassimp.a; sourceTree = ""; }; 1B0E9A931279EDCD003108E7 /* ModelLoaderHelperClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelLoaderHelperClasses.h; sourceTree = ""; }; 1B0E9A941279EDCD003108E7 /* ModelLoaderHelperClasses.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModelLoaderHelperClasses.mm; sourceTree = ""; }; - 1B0E9AD31279EFCC003108E7 /* aiAnim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiAnim.h; sourceTree = ""; }; - 1B0E9AD41279EFCC003108E7 /* aiAssert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiAssert.h; sourceTree = ""; }; - 1B0E9AD51279EFCC003108E7 /* aiCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiCamera.h; sourceTree = ""; }; - 1B0E9AD61279EFCC003108E7 /* aiColor4D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiColor4D.h; sourceTree = ""; }; - 1B0E9AD71279EFCC003108E7 /* aiColor4D.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aiColor4D.inl; sourceTree = ""; }; - 1B0E9AD81279EFCC003108E7 /* aiConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiConfig.h; sourceTree = ""; }; - 1B0E9AD91279EFCC003108E7 /* aiDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiDefines.h; sourceTree = ""; }; - 1B0E9ADA1279EFCC003108E7 /* aiFileIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiFileIO.h; sourceTree = ""; }; - 1B0E9ADB1279EFCC003108E7 /* aiLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiLight.h; sourceTree = ""; }; - 1B0E9ADC1279EFCC003108E7 /* aiMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiMaterial.h; sourceTree = ""; }; - 1B0E9ADD1279EFCC003108E7 /* aiMaterial.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aiMaterial.inl; sourceTree = ""; }; - 1B0E9ADE1279EFCC003108E7 /* aiMatrix3x3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiMatrix3x3.h; sourceTree = ""; }; - 1B0E9ADF1279EFCC003108E7 /* aiMatrix3x3.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aiMatrix3x3.inl; sourceTree = ""; }; - 1B0E9AE01279EFCC003108E7 /* aiMatrix4x4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiMatrix4x4.h; sourceTree = ""; }; - 1B0E9AE11279EFCC003108E7 /* aiMatrix4x4.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aiMatrix4x4.inl; sourceTree = ""; }; - 1B0E9AE21279EFCC003108E7 /* aiMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiMesh.h; sourceTree = ""; }; - 1B0E9AE31279EFCC003108E7 /* aiPostProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiPostProcess.h; sourceTree = ""; }; - 1B0E9AE41279EFCC003108E7 /* aiQuaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiQuaternion.h; sourceTree = ""; }; - 1B0E9AE51279EFCC003108E7 /* aiScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiScene.h; sourceTree = ""; }; - 1B0E9AE61279EFCC003108E7 /* aiTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiTexture.h; sourceTree = ""; }; - 1B0E9AE71279EFCC003108E7 /* aiTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiTypes.h; sourceTree = ""; }; - 1B0E9AE81279EFCC003108E7 /* aiVector2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiVector2D.h; sourceTree = ""; }; - 1B0E9AE91279EFCC003108E7 /* aiVector3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiVector3D.h; sourceTree = ""; }; - 1B0E9AEA1279EFCC003108E7 /* aiVector3D.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aiVector3D.inl; sourceTree = ""; }; - 1B0E9AEB1279EFCC003108E7 /* aiVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aiVersion.h; sourceTree = ""; }; - 1B0E9AEC1279EFCC003108E7 /* assimp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assimp.h; sourceTree = ""; }; - 1B0E9AED1279EFCC003108E7 /* assimp.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = assimp.hpp; sourceTree = ""; }; - 1B0E9AEE1279EFCC003108E7 /* DefaultLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultLogger.h; sourceTree = ""; }; - 1B0E9AEF1279EFCC003108E7 /* IOStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOStream.h; sourceTree = ""; }; - 1B0E9AF01279EFCC003108E7 /* IOSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSystem.h; sourceTree = ""; }; - 1B0E9AF11279EFCC003108E7 /* Logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logger.h; sourceTree = ""; }; - 1B0E9AF21279EFCC003108E7 /* LogStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogStream.h; sourceTree = ""; }; - 1B0E9AF31279EFCC003108E7 /* NullLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullLogger.h; sourceTree = ""; }; - 1B0E9AF41279EFCC003108E7 /* ProgressHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressHandler.h; sourceTree = ""; }; 1B0E9AFD1279F006003108E7 /* poppack1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = poppack1.h; path = "/Users/vade/Asset Import/include/Compiler/poppack1.h"; sourceTree = ""; }; 1B0E9AFE1279F006003108E7 /* pushpack1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pushpack1.h; path = "/Users/vade/Asset Import/include/Compiler/pushpack1.h"; sourceTree = ""; }; 1B0E9B191279F107003108E7 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; @@ -85,6 +53,46 @@ 7788DA0506752A1600599AAD /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; 8D15AC360486D014006FF6A4 /* SimpleAssimpViewX-Info.plist */ = {isa = PBXFileReference; explicitFileType = text.plist.xml; fileEncoding = 4; path = "SimpleAssimpViewX-Info.plist"; sourceTree = ""; }; 8D15AC370486D014006FF6A4 /* SimpleAssimpViewX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleAssimpViewX.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C75BB4EA17EE0B64004F0260 /* ai_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ai_assert.h; sourceTree = ""; }; + C75BB4EB17EE0B64004F0260 /* anim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = anim.h; sourceTree = ""; }; + C75BB4EC17EE0B64004F0260 /* camera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = camera.h; sourceTree = ""; }; + C75BB4ED17EE0B64004F0260 /* cexport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cexport.h; sourceTree = ""; }; + C75BB4EE17EE0B64004F0260 /* cfileio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfileio.h; sourceTree = ""; }; + C75BB4EF17EE0B64004F0260 /* cimport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cimport.h; sourceTree = ""; }; + C75BB4F017EE0B64004F0260 /* color4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = color4.h; sourceTree = ""; }; + C75BB4F117EE0B64004F0260 /* color4.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = color4.inl; sourceTree = ""; }; + C75BB4F217EE0B64004F0260 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; + C75BB4F317EE0B64004F0260 /* metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metadata.h; sourceTree = ""; }; + C75BB4F417EE0B64004F0260 /* NullLogger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NullLogger.hpp; sourceTree = ""; }; + C75BB4F517EE0B64004F0260 /* quaternion.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = quaternion.inl; sourceTree = ""; }; + C75BB4F817EE0B75004F0260 /* DefaultLogger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DefaultLogger.hpp; sourceTree = ""; }; + C75BB4F917EE0B75004F0260 /* defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = defs.h; sourceTree = ""; }; + C75BB4FA17EE0B75004F0260 /* Exporter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Exporter.hpp; sourceTree = ""; }; + C75BB4FB17EE0B75004F0260 /* Importer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Importer.hpp; sourceTree = ""; }; + C75BB4FC17EE0B75004F0260 /* importerdesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = importerdesc.h; sourceTree = ""; }; + C75BB4FD17EE0B75004F0260 /* IOStream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IOStream.hpp; sourceTree = ""; }; + C75BB4FE17EE0B75004F0260 /* IOSystem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IOSystem.hpp; sourceTree = ""; }; + C75BB4FF17EE0B75004F0260 /* light.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = light.h; sourceTree = ""; }; + C75BB50017EE0B75004F0260 /* Logger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Logger.hpp; sourceTree = ""; }; + C75BB50117EE0B75004F0260 /* LogStream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LogStream.hpp; sourceTree = ""; }; + C75BB50217EE0B75004F0260 /* material.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = material.h; sourceTree = ""; }; + C75BB50317EE0B75004F0260 /* material.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = material.inl; sourceTree = ""; }; + C75BB50417EE0B75004F0260 /* matrix3x3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = matrix3x3.h; sourceTree = ""; }; + C75BB50517EE0B75004F0260 /* matrix3x3.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = matrix3x3.inl; sourceTree = ""; }; + C75BB50617EE0B75004F0260 /* matrix4x4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = matrix4x4.h; sourceTree = ""; }; + C75BB50717EE0B75004F0260 /* matrix4x4.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = matrix4x4.inl; sourceTree = ""; }; + C75BB50817EE0B75004F0260 /* mesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mesh.h; sourceTree = ""; }; + C75BB50917EE0B75004F0260 /* postprocess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = postprocess.h; sourceTree = ""; }; + C75BB50A17EE0B75004F0260 /* ProgressHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ProgressHandler.hpp; sourceTree = ""; }; + C75BB50B17EE0B75004F0260 /* quaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = quaternion.h; sourceTree = ""; }; + C75BB50C17EE0B75004F0260 /* scene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scene.h; sourceTree = ""; }; + C75BB50D17EE0B75004F0260 /* texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = texture.h; sourceTree = ""; }; + C75BB50E17EE0B75004F0260 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = types.h; sourceTree = ""; }; + C75BB50F17EE0B75004F0260 /* vector2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vector2.h; sourceTree = ""; }; + C75BB51017EE0B75004F0260 /* vector2.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = vector2.inl; sourceTree = ""; }; + C75BB51117EE0B75004F0260 /* vector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vector3.h; sourceTree = ""; }; + C75BB51217EE0B75004F0260 /* vector3.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = vector3.inl; sourceTree = ""; }; + C75BB51317EE0B75004F0260 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -134,40 +142,46 @@ 1B0E9AD21279EFCC003108E7 /* include */ = { isa = PBXGroup; children = ( - 1B0E9AD31279EFCC003108E7 /* aiAnim.h */, - 1B0E9AD41279EFCC003108E7 /* aiAssert.h */, - 1B0E9AD51279EFCC003108E7 /* aiCamera.h */, - 1B0E9AD61279EFCC003108E7 /* aiColor4D.h */, - 1B0E9AD71279EFCC003108E7 /* aiColor4D.inl */, - 1B0E9AD81279EFCC003108E7 /* aiConfig.h */, - 1B0E9AD91279EFCC003108E7 /* aiDefines.h */, - 1B0E9ADA1279EFCC003108E7 /* aiFileIO.h */, - 1B0E9ADB1279EFCC003108E7 /* aiLight.h */, - 1B0E9ADC1279EFCC003108E7 /* aiMaterial.h */, - 1B0E9ADD1279EFCC003108E7 /* aiMaterial.inl */, - 1B0E9ADE1279EFCC003108E7 /* aiMatrix3x3.h */, - 1B0E9ADF1279EFCC003108E7 /* aiMatrix3x3.inl */, - 1B0E9AE01279EFCC003108E7 /* aiMatrix4x4.h */, - 1B0E9AE11279EFCC003108E7 /* aiMatrix4x4.inl */, - 1B0E9AE21279EFCC003108E7 /* aiMesh.h */, - 1B0E9AE31279EFCC003108E7 /* aiPostProcess.h */, - 1B0E9AE41279EFCC003108E7 /* aiQuaternion.h */, - 1B0E9AE51279EFCC003108E7 /* aiScene.h */, - 1B0E9AE61279EFCC003108E7 /* aiTexture.h */, - 1B0E9AE71279EFCC003108E7 /* aiTypes.h */, - 1B0E9AE81279EFCC003108E7 /* aiVector2D.h */, - 1B0E9AE91279EFCC003108E7 /* aiVector3D.h */, - 1B0E9AEA1279EFCC003108E7 /* aiVector3D.inl */, - 1B0E9AEB1279EFCC003108E7 /* aiVersion.h */, - 1B0E9AEC1279EFCC003108E7 /* assimp.h */, - 1B0E9AED1279EFCC003108E7 /* assimp.hpp */, - 1B0E9AEE1279EFCC003108E7 /* DefaultLogger.h */, - 1B0E9AEF1279EFCC003108E7 /* IOStream.h */, - 1B0E9AF01279EFCC003108E7 /* IOSystem.h */, - 1B0E9AF11279EFCC003108E7 /* Logger.h */, - 1B0E9AF21279EFCC003108E7 /* LogStream.h */, - 1B0E9AF31279EFCC003108E7 /* NullLogger.h */, - 1B0E9AF41279EFCC003108E7 /* ProgressHandler.h */, + C75BB4F817EE0B75004F0260 /* DefaultLogger.hpp */, + C75BB4F917EE0B75004F0260 /* defs.h */, + C75BB4FA17EE0B75004F0260 /* Exporter.hpp */, + C75BB4FB17EE0B75004F0260 /* Importer.hpp */, + C75BB4FC17EE0B75004F0260 /* importerdesc.h */, + C75BB4FD17EE0B75004F0260 /* IOStream.hpp */, + C75BB4FE17EE0B75004F0260 /* IOSystem.hpp */, + C75BB4FF17EE0B75004F0260 /* light.h */, + C75BB50017EE0B75004F0260 /* Logger.hpp */, + C75BB50117EE0B75004F0260 /* LogStream.hpp */, + C75BB50217EE0B75004F0260 /* material.h */, + C75BB50317EE0B75004F0260 /* material.inl */, + C75BB50417EE0B75004F0260 /* matrix3x3.h */, + C75BB50517EE0B75004F0260 /* matrix3x3.inl */, + C75BB50617EE0B75004F0260 /* matrix4x4.h */, + C75BB50717EE0B75004F0260 /* matrix4x4.inl */, + C75BB50817EE0B75004F0260 /* mesh.h */, + C75BB50917EE0B75004F0260 /* postprocess.h */, + C75BB50A17EE0B75004F0260 /* ProgressHandler.hpp */, + C75BB50B17EE0B75004F0260 /* quaternion.h */, + C75BB50C17EE0B75004F0260 /* scene.h */, + C75BB50D17EE0B75004F0260 /* texture.h */, + C75BB50E17EE0B75004F0260 /* types.h */, + C75BB50F17EE0B75004F0260 /* vector2.h */, + C75BB51017EE0B75004F0260 /* vector2.inl */, + C75BB51117EE0B75004F0260 /* vector3.h */, + C75BB51217EE0B75004F0260 /* vector3.inl */, + C75BB51317EE0B75004F0260 /* version.h */, + C75BB4EA17EE0B64004F0260 /* ai_assert.h */, + C75BB4EB17EE0B64004F0260 /* anim.h */, + C75BB4EC17EE0B64004F0260 /* camera.h */, + C75BB4ED17EE0B64004F0260 /* cexport.h */, + C75BB4EE17EE0B64004F0260 /* cfileio.h */, + C75BB4EF17EE0B64004F0260 /* cimport.h */, + C75BB4F017EE0B64004F0260 /* color4.h */, + C75BB4F117EE0B64004F0260 /* color4.inl */, + C75BB4F217EE0B64004F0260 /* config.h */, + C75BB4F317EE0B64004F0260 /* metadata.h */, + C75BB4F417EE0B64004F0260 /* NullLogger.hpp */, + C75BB4F517EE0B64004F0260 /* quaternion.inl */, 1B0E9AFC1279F006003108E7 /* Compiler */, ); path = include; @@ -295,11 +309,13 @@ 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */, 2F7446AB0DB6BCF400F9684A /* MainMenu.xib in Resources */, 2F7446AC0DB6BCF400F9684A /* MyDocument.xib in Resources */, - 1B0E9AF51279EFCC003108E7 /* aiColor4D.inl in Resources */, - 1B0E9AF61279EFCC003108E7 /* aiMaterial.inl in Resources */, - 1B0E9AF71279EFCC003108E7 /* aiMatrix3x3.inl in Resources */, - 1B0E9AF81279EFCC003108E7 /* aiMatrix4x4.inl in Resources */, - 1B0E9AF91279EFCC003108E7 /* aiVector3D.inl in Resources */, + C75BB4F617EE0B64004F0260 /* color4.inl in Resources */, + C75BB4F717EE0B64004F0260 /* quaternion.inl in Resources */, + C75BB51417EE0B75004F0260 /* material.inl in Resources */, + C75BB51517EE0B75004F0260 /* matrix3x3.inl in Resources */, + C75BB51617EE0B75004F0260 /* matrix4x4.inl in Resources */, + C75BB51717EE0B75004F0260 /* vector2.inl in Resources */, + C75BB51817EE0B75004F0260 /* vector3.inl in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -413,7 +429,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Debug; }; @@ -425,7 +441,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Release; }; diff --git a/workspaces/xcode3/assimp.xcodeproj/project.pbxproj b/workspaces/xcode3/assimp.xcodeproj/project.pbxproj index e0e268982..e6c5b6b11 100644 --- a/workspaces/xcode3/assimp.xcodeproj/project.pbxproj +++ b/workspaces/xcode3/assimp.xcodeproj/project.pbxproj @@ -1487,7 +1487,6 @@ B919758A163AEA54009C397B /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = F9BA8B9E1543268400E63FFE /* version.h */; settings = {ATTRIBUTES = (Public, ); }; }; B919758B163AEA54009C397B /* OgreImporter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = F9BA8C36154328B600E63FFE /* OgreImporter.hpp */; }; B919758C163AEA54009C397B /* OgreXmlHelper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = F9BA8C3A154328B600E63FFE /* OgreXmlHelper.hpp */; }; - B9197595163AEA54009C397B /* M3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F2715436207000682F3 /* M3Importer.h */; }; B9197596163AEA54009C397B /* PlyExporter.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F3115436269000682F3 /* PlyExporter.h */; }; B919759C163AEA54009C397B /* crc32.h in Headers */ = {isa = PBXBuildFile; fileRef = F960704B154366AB004D91DD /* crc32.h */; }; B919759D163AEA54009C397B /* deflate.h in Headers */ = {isa = PBXBuildFile; fileRef = F960704D154366AB004D91DD /* deflate.h */; }; @@ -1565,7 +1564,6 @@ B919761A163AEA54009C397B /* OgreMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9BA8C37154328B600E63FFE /* OgreMaterial.cpp */; }; B919761B163AEA54009C397B /* OgreMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9BA8C38154328B600E63FFE /* OgreMesh.cpp */; }; B919761C163AEA54009C397B /* OgreSkeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9BA8C39154328B600E63FFE /* OgreSkeleton.cpp */; }; - B919761F163AEA54009C397B /* M3Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F2615436207000682F3 /* M3Importer.cpp */; }; B9197620163AEA54009C397B /* PlyExporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F3015436269000682F3 /* PlyExporter.cpp */; }; B9197625163AEA54009C397B /* adler32.c in Sources */ = {isa = PBXBuildFile; fileRef = F9607047154366AB004D91DD /* adler32.c */; }; B9197626163AEA54009C397B /* compress.c in Sources */ = {isa = PBXBuildFile; fileRef = F9607049154366AB004D91DD /* compress.c */; }; @@ -1830,14 +1828,6 @@ F97BA03715439DB3009EB9DD /* ai_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = F97BA03515439DB3009EB9DD /* ai_assert.h */; }; F97BA03815439DB3009EB9DD /* ai_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = F97BA03515439DB3009EB9DD /* ai_assert.h */; }; F97BA03915439DB3009EB9DD /* ai_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = F97BA03515439DB3009EB9DD /* ai_assert.h */; }; - F99A9F2815436207000682F3 /* M3Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F2615436207000682F3 /* M3Importer.cpp */; }; - F99A9F2915436207000682F3 /* M3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F2715436207000682F3 /* M3Importer.h */; }; - F99A9F2A15436207000682F3 /* M3Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F2615436207000682F3 /* M3Importer.cpp */; }; - F99A9F2B15436207000682F3 /* M3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F2715436207000682F3 /* M3Importer.h */; }; - F99A9F2C15436207000682F3 /* M3Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F2615436207000682F3 /* M3Importer.cpp */; }; - F99A9F2D15436207000682F3 /* M3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F2715436207000682F3 /* M3Importer.h */; }; - F99A9F2E15436207000682F3 /* M3Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F2615436207000682F3 /* M3Importer.cpp */; }; - F99A9F2F15436207000682F3 /* M3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F2715436207000682F3 /* M3Importer.h */; }; F99A9F3215436269000682F3 /* PlyExporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F3015436269000682F3 /* PlyExporter.cpp */; }; F99A9F3315436269000682F3 /* PlyExporter.h in Headers */ = {isa = PBXBuildFile; fileRef = F99A9F3115436269000682F3 /* PlyExporter.h */; }; F99A9F3415436269000682F3 /* PlyExporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99A9F3015436269000682F3 /* PlyExporter.cpp */; }; @@ -2369,8 +2359,6 @@ F96070DD1543675E004D91DD /* sweep_context.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sweep_context.cc; sourceTree = ""; }; F96070DE1543675E004D91DD /* sweep_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sweep_context.h; sourceTree = ""; }; F97BA03515439DB3009EB9DD /* ai_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ai_assert.h; sourceTree = ""; }; - F99A9F2615436207000682F3 /* M3Importer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = M3Importer.cpp; path = ../../code/M3Importer.cpp; sourceTree = SOURCE_ROOT; }; - F99A9F2715436207000682F3 /* M3Importer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = M3Importer.h; path = ../../code/M3Importer.h; sourceTree = SOURCE_ROOT; }; F99A9F3015436269000682F3 /* PlyExporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlyExporter.cpp; sourceTree = ""; }; F99A9F3115436269000682F3 /* PlyExporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlyExporter.h; sourceTree = ""; }; F9BA8B751543268400E63FFE /* anim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = anim.h; sourceTree = ""; }; @@ -3173,7 +3161,6 @@ F90BAFD40F5DD8F200124155 /* IRR */, 3AB8A3A80E50D5F400606590 /* LWO */, 7411B15811416D6600BCD793 /* LWS */, - F99A9F21154361F8000682F3 /* M3 */, 3AF45B870E4B74DA00207D74 /* MD2 */, 3AF45B880E4B751000207D74 /* MD3 */, 3AF45B8A0E4B755E00207D74 /* MD5 */, @@ -3309,15 +3296,6 @@ name = IFC; sourceTree = ""; }; - F99A9F21154361F8000682F3 /* M3 */ = { - isa = PBXGroup; - children = ( - F99A9F2615436207000682F3 /* M3Importer.cpp */, - F99A9F2715436207000682F3 /* M3Importer.h */, - ); - name = M3; - sourceTree = ""; - }; F99A9F5315436318000682F3 /* STEP */ = { isa = PBXGroup; children = ( @@ -3499,7 +3477,6 @@ F9BA8C041543268400E63FFE /* version.h in Headers */, F9BA8C48154328B600E63FFE /* OgreImporter.hpp in Headers */, F9BA8C4C154328B600E63FFE /* OgreXmlHelper.hpp in Headers */, - F99A9F2D15436207000682F3 /* M3Importer.h in Headers */, F99A9F3715436269000682F3 /* PlyExporter.h in Headers */, F9607088154366AB004D91DD /* crc32.h in Headers */, F960708A154366AB004D91DD /* deflate.h in Headers */, @@ -3748,7 +3725,6 @@ F9BA8C261543268400E63FFE /* version.h in Headers */, F9BA8C4E154328B600E63FFE /* OgreImporter.hpp in Headers */, F9BA8C52154328B600E63FFE /* OgreXmlHelper.hpp in Headers */, - F99A9F2F15436207000682F3 /* M3Importer.h in Headers */, F99A9F3915436269000682F3 /* PlyExporter.h in Headers */, F960709C154366AB004D91DD /* crc32.h in Headers */, F960709E154366AB004D91DD /* deflate.h in Headers */, @@ -3997,7 +3973,6 @@ B919758A163AEA54009C397B /* version.h in Headers */, B919758B163AEA54009C397B /* OgreImporter.hpp in Headers */, B919758C163AEA54009C397B /* OgreXmlHelper.hpp in Headers */, - B9197595163AEA54009C397B /* M3Importer.h in Headers */, B9197596163AEA54009C397B /* PlyExporter.h in Headers */, B919759C163AEA54009C397B /* crc32.h in Headers */, B919759D163AEA54009C397B /* deflate.h in Headers */, @@ -4246,7 +4221,6 @@ F9BA8BC01543268400E63FFE /* version.h in Headers */, F9BA8C3C154328B600E63FFE /* OgreImporter.hpp in Headers */, F9BA8C40154328B600E63FFE /* OgreXmlHelper.hpp in Headers */, - F99A9F2915436207000682F3 /* M3Importer.h in Headers */, F99A9F3315436269000682F3 /* PlyExporter.h in Headers */, F9607060154366AB004D91DD /* crc32.h in Headers */, F9607062154366AB004D91DD /* deflate.h in Headers */, @@ -4495,7 +4469,6 @@ F9BA8BE21543268400E63FFE /* version.h in Headers */, F9BA8C42154328B600E63FFE /* OgreImporter.hpp in Headers */, F9BA8C46154328B600E63FFE /* OgreXmlHelper.hpp in Headers */, - F99A9F2B15436207000682F3 /* M3Importer.h in Headers */, F99A9F3515436269000682F3 /* PlyExporter.h in Headers */, F9607074154366AB004D91DD /* crc32.h in Headers */, F9607076154366AB004D91DD /* deflate.h in Headers */, @@ -4815,7 +4788,6 @@ F9BA8C49154328B600E63FFE /* OgreMaterial.cpp in Sources */, F9BA8C4A154328B600E63FFE /* OgreMesh.cpp in Sources */, F9BA8C4B154328B600E63FFE /* OgreSkeleton.cpp in Sources */, - F99A9F2C15436207000682F3 /* M3Importer.cpp in Sources */, F99A9F3615436269000682F3 /* PlyExporter.cpp in Sources */, F9607085154366AB004D91DD /* adler32.c in Sources */, F9607086154366AB004D91DD /* compress.c in Sources */, @@ -4978,7 +4950,6 @@ F9BA8C4F154328B600E63FFE /* OgreMaterial.cpp in Sources */, F9BA8C50154328B600E63FFE /* OgreMesh.cpp in Sources */, F9BA8C51154328B600E63FFE /* OgreSkeleton.cpp in Sources */, - F99A9F2E15436207000682F3 /* M3Importer.cpp in Sources */, F99A9F3815436269000682F3 /* PlyExporter.cpp in Sources */, F9607099154366AB004D91DD /* adler32.c in Sources */, F960709A154366AB004D91DD /* compress.c in Sources */, @@ -5141,7 +5112,6 @@ B919761A163AEA54009C397B /* OgreMaterial.cpp in Sources */, B919761B163AEA54009C397B /* OgreMesh.cpp in Sources */, B919761C163AEA54009C397B /* OgreSkeleton.cpp in Sources */, - B919761F163AEA54009C397B /* M3Importer.cpp in Sources */, B9197620163AEA54009C397B /* PlyExporter.cpp in Sources */, B9197625163AEA54009C397B /* adler32.c in Sources */, B9197626163AEA54009C397B /* compress.c in Sources */, @@ -5304,7 +5274,6 @@ F9BA8C3D154328B600E63FFE /* OgreMaterial.cpp in Sources */, F9BA8C3E154328B600E63FFE /* OgreMesh.cpp in Sources */, F9BA8C3F154328B600E63FFE /* OgreSkeleton.cpp in Sources */, - F99A9F2815436207000682F3 /* M3Importer.cpp in Sources */, F99A9F3215436269000682F3 /* PlyExporter.cpp in Sources */, F960705D154366AB004D91DD /* adler32.c in Sources */, F960705E154366AB004D91DD /* compress.c in Sources */, @@ -5467,7 +5436,6 @@ F9BA8C43154328B600E63FFE /* OgreMaterial.cpp in Sources */, F9BA8C44154328B600E63FFE /* OgreMesh.cpp in Sources */, F9BA8C45154328B600E63FFE /* OgreSkeleton.cpp in Sources */, - F99A9F2A15436207000682F3 /* M3Importer.cpp in Sources */, F99A9F3415436269000682F3 /* PlyExporter.cpp in Sources */, F9607071154366AB004D91DD /* adler32.c in Sources */, F9607072154366AB004D91DD /* compress.c in Sources */, From 6f4632e4d903c6e212d205d981aafea74290dc83 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Wed, 25 Sep 2013 13:25:02 -0700 Subject: [PATCH 044/104] Allow spaces before the ascii STL header keyword The text "solid" is the general STL header indicator that the file is in fact an ascii STL archive. Allows spaces to precede the "solid" keyword, providing compatibility with exporters that insert such (non-compliant )spaces. --- code/STLLoader.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index fff58d04a..39c6ac9cd 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -86,7 +86,12 @@ bool IsAsciiSTL(const char* buffer, unsigned int fileSize) { if (IsBinarySTL(buffer, fileSize)) return false; - if (fileSize < 5) + const char* bufferEnd = buffer + fileSize; + + if (!SkipSpaces(&buffer)) + return false; + + if (buffer + 5 >= bufferEnd) return false; return strncmp(buffer, "solid", 5) == 0; @@ -209,7 +214,11 @@ void STLImporter::LoadASCIIFile() { aiMesh* pMesh = pScene->mMeshes[0]; - const char* sz = mBuffer + 5; // skip the "solid" + const char* sz = mBuffer; + SkipSpaces(&sz); + ai_assert(!IsLineEnd(sz)); + + sz += 5; // skip the "solid" SkipSpaces(&sz); const char* szMe = sz; while (!::IsSpaceOrNewLine(*sz)) { From 5a0b40db92b05c357c1997fe5ea997ddffb99857 Mon Sep 17 00:00:00 2001 From: acgessler Date: Sun, 29 Sep 2013 21:56:32 +0200 Subject: [PATCH 045/104] ColladaExporter: fix assertion in ::isalnum() when a special character > 0x7f is present in material names. --- code/ColladaExporter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 19f86fcf8..8fba4bf74 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -235,9 +235,13 @@ void ColladaExporter::WriteMaterials() if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS ) name = "mat"; materials[a].name = std::string( "m") + boost::lexical_cast (a) + name.C_Str(); - for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) - if( !isalnum( *it) ) + for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) { + // isalnum on MSVC asserts for code points in [0,255]. Thus prevent unwanted promotion + // of char to signed int and take the unsigned char value. + if( !isalnum( static_cast(*it) ) ) { *it = '_'; + } + } ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT); if( !materials[a].ambient.texture.empty() ) numTextures++; From 8f34c24ae0fd9c49eb90d8f1c1cc2b3c85fd3e30 Mon Sep 17 00:00:00 2001 From: Marshall Hahn Date: Mon, 30 Sep 2013 14:07:53 -0400 Subject: [PATCH 046/104] remove duplicate vectors when export obj format --- code/ObjExporter.cpp | 54 +++++++++++++++++++++++++++----------- code/ObjExporter.h | 15 +++++++++++ include/assimp/vector3.h | 1 + include/assimp/vector3.inl | 10 +++++++ 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 9ac902ee3..6cc1063d2 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -59,16 +59,10 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write both the main OBJ file and the material script { boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); - if(outfile == NULL) { - throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); - } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } { boost::scoped_ptr outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); - if(outfile == NULL) { - throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName())); - } outfile->Write( exporter.mOutputMat.str().c_str(), static_cast(exporter.mOutputMat.tellp()),1); } } @@ -199,6 +193,7 @@ void ObjExporter :: WriteGeometryFile() AddNode(pScene->mRootNode,mBase); // write vertex positions + vpMap.getVectors(vp); mOutput << "# " << vp.size() << " vertex positions" << endl; BOOST_FOREACH(const aiVector3D& v, vp) { mOutput << "v " << v.x << " " << v.y << " " << v.z << endl; @@ -206,6 +201,7 @@ void ObjExporter :: WriteGeometryFile() mOutput << endl; // write uv coordinates + vtMap.getVectors(vt); mOutput << "# " << vt.size() << " UV coordinates" << endl; BOOST_FOREACH(const aiVector3D& v, vt) { mOutput << "vt " << v.x << " " << v.y << " " << v.z << endl; @@ -213,6 +209,7 @@ void ObjExporter :: WriteGeometryFile() mOutput << endl; // write vertex normals + vnMap.getVectors(vn); mOutput << "# " << vn.size() << " vertex normals" << endl; BOOST_FOREACH(const aiVector3D& v, vn) { mOutput << "vn " << v.x << " " << v.y << " " << v.z << endl; @@ -252,6 +249,31 @@ void ObjExporter :: WriteGeometryFile() } } + + + + +int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) +{ + std::map::iterator vertIt = vecMap.find(vec); + if(vertIt != vecMap.end()){// vertex already exists, so reference it + return vertIt->second; + } + vecMap[vec] = mNextIndex; + int ret = mNextIndex; + mNextIndex++; + return ret; +} + +void ObjExporter::vecIndexMap::getVectors( std::vector& vecs ) +{ + vecs.resize(vecMap.size()); + for(std::map::iterator it = vecMap.begin(); it != vecMap.end(); it++){ + vecs[it->second-1] = it->first; + } +} + + // ------------------------------------------------------------------------------------------------ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) { @@ -262,6 +284,7 @@ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatri mesh.matname = GetMaterialName(m->mMaterialIndex); mesh.faces.resize(m->mNumFaces); + for(unsigned int i = 0; i < m->mNumFaces; ++i) { const aiFace& f = m->mFaces[i]; @@ -281,21 +304,22 @@ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatri for(unsigned int a = 0; a < f.mNumIndices; ++a) { const unsigned int idx = f.mIndices[a]; - // XXX need a way to check if this is an unique vertex or if we had it already, - // in which case we should instead reference the previous occurrence. - ai_assert(m->mVertices); - vp.push_back( mat * m->mVertices[idx] ); - face.indices[a].vp = vp.size(); + aiVector3D vert = mat * m->mVertices[idx]; + face.indices[a].vp = vpMap.getIndex(vert); if (m->mNormals) { - vn.push_back( m->mNormals[idx] ); + face.indices[a].vn = vnMap.getIndex(m->mNormals[idx]); + } + else{ + face.indices[a].vn = 0; } - face.indices[a].vn = vn.size(); if (m->mTextureCoords[0]) { - vt.push_back( m->mTextureCoords[0][idx] ); + face.indices[a].vt = vtMap.getIndex(m->mTextureCoords[0][idx]); + } + else{ + face.indices[a].vt = 0; } - face.indices[a].vt = vt.size(); } } } diff --git a/code/ObjExporter.h b/code/ObjExporter.h index f857f5879..4f2f83240 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -112,6 +112,21 @@ private: const aiScene* const pScene; std::vector vp, vn, vt; + + class vecIndexMap + { + int mNextIndex; + std::map vecMap; + public: + + vecIndexMap():mNextIndex(1) + {} + + int getIndex(const aiVector3D& vec); + void getVectors( std::vector& vecs ); + }; + + vecIndexMap vpMap, vnMap, vtMap; std::vector meshes; // this endl() doesn't flush() the stream diff --git a/include/assimp/vector3.h b/include/assimp/vector3.h index cbdee264d..5b3da297d 100644 --- a/include/assimp/vector3.h +++ b/include/assimp/vector3.h @@ -85,6 +85,7 @@ public: // comparison bool operator== (const aiVector3t& other) const; bool operator!= (const aiVector3t& other) const; + bool operator< (const aiVector3t& other) const; template operator aiVector3t () const; diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl index c03437980..90370fa07 100644 --- a/include/assimp/vector3.inl +++ b/include/assimp/vector3.inl @@ -149,6 +149,16 @@ AI_FORCE_INLINE bool aiVector3t::operator!= (const aiVector3t& oth } // ------------------------------------------------------------------------------------------------ template +AI_FORCE_INLINE bool aiVector3t::operator< (const aiVector3t& other) const { + if(x < other.x) return true; + if(x > other.x) return false; + if(y < other.y) return true; + if(y > other.y) return false; + if(z < other.z) return true; + return false; +} +// ------------------------------------------------------------------------------------------------ +template AI_FORCE_INLINE const aiVector3t aiVector3t::SymMul(const aiVector3t& o) { return aiVector3t(x*o.x,y*o.y,z*o.z); } From 66fd9bb8a28ea170522d1d50fc3c3c51bdfbbefb Mon Sep 17 00:00:00 2001 From: Marshall Hahn Date: Mon, 30 Sep 2013 14:11:37 -0400 Subject: [PATCH 047/104] fixed bad merge --- code/ObjExporter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 6cc1063d2..bbf26ce56 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -59,10 +59,16 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write both the main OBJ file and the material script { boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); + } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } { boost::scoped_ptr outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName())); + } outfile->Write( exporter.mOutputMat.str().c_str(), static_cast(exporter.mOutputMat.tellp()),1); } } From b72b16c90b025486a756caad68838cbd7b77f887 Mon Sep 17 00:00:00 2001 From: Marshall Hahn Date: Mon, 30 Sep 2013 14:12:38 -0400 Subject: [PATCH 048/104] whitespace fix --- code/ObjExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index bbf26ce56..dce217d12 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -60,7 +60,7 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene { boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); if(outfile == NULL) { - throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); + throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } From c29109d1a4ee237d60d4334acfbceb95b2e5cf3a Mon Sep 17 00:00:00 2001 From: Calvin Hsu Date: Mon, 30 Sep 2013 15:12:56 -0700 Subject: [PATCH 049/104] obj: Fix tabs causing vertices to be skipped If an obj vertex definition 'v' is followed by a tab instead of a space, the vertex definition is skipped. --- code/ObjFileParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index ab8fdd124..3d81ab925 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -112,7 +112,7 @@ void ObjFileParser::parseFile() case 'v': // Parse a vertex texture coordinate { ++m_DataIt; - if (*m_DataIt == ' ') + if (*m_DataIt == ' ' || *m_DataIt == '\t') { // Read in vertex definition getVector3(m_pModel->m_Vertices); From 32a10ec0a040aad78e3d9e5cbdac336a76af2903 Mon Sep 17 00:00:00 2001 From: Calvin Hsu Date: Mon, 30 Sep 2013 15:13:11 -0700 Subject: [PATCH 050/104] obj: Add support for relative vertex indexing obj files allow faces to specify indices relatively by using negative integers. See vertex refering in http://www.martinreddy.net/gfx/3d/OBJ.spec --- code/ObjFileParser.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 3d81ab925..e701ddc62 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -290,6 +290,10 @@ void ObjFileParser::getFace(aiPrimitiveType type) std::vector *pNormalID = new std::vector; bool hasNormal = false; + const int vSize = m_pModel->m_Vertices.size(); + const int vtSize = m_pModel->m_TextureCoord.size(); + const int vnSize = m_pModel->m_Normals.size(); + const bool vt = (!m_pModel->m_TextureCoord.empty()); const bool vn = (!m_pModel->m_Normals.empty()); int iStep = 0, iPos = 0; @@ -323,7 +327,11 @@ void ObjFileParser::getFace(aiPrimitiveType type) { //OBJ USES 1 Base ARRAYS!!!! const int iVal = atoi( pPtr ); + + // increment iStep position based off of the sign and # of digits int tmp = iVal; + if (iVal < 0) + ++iStep; while ( ( tmp = tmp / 10 )!=0 ) ++iStep; @@ -348,6 +356,27 @@ void ObjFileParser::getFace(aiPrimitiveType type) reportErrorTokenInFace(); } } + else if ( iVal < 0 ) + { + // Store relatively index + if ( 0 == iPos ) + { + pIndices->push_back( vSize + iVal ); + } + else if ( 1 == iPos ) + { + pTexID->push_back( vtSize + iVal ); + } + else if ( 2 == iPos ) + { + pNormalID->push_back( vnSize + iVal ); + hasNormal = true; + } + else + { + reportErrorTokenInFace(); + } + } } pPtr += iStep; } From c5921540064ee19cabd0707422274b9c3262f9b9 Mon Sep 17 00:00:00 2001 From: Marshall Hahn Date: Tue, 1 Oct 2013 11:21:36 -0400 Subject: [PATCH 051/104] using a custom compare function instead of a global aiVector3t less than operator --- code/ObjExporter.cpp | 4 ++-- code/ObjExporter.h | 17 ++++++++++++++++- include/assimp/vector3.h | 1 - include/assimp/vector3.inl | 10 ---------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index dce217d12..b680abb74 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -261,7 +261,7 @@ void ObjExporter :: WriteGeometryFile() int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) { - std::map::iterator vertIt = vecMap.find(vec); + vecIndexMap::dataType::iterator vertIt = vecMap.find(vec); if(vertIt != vecMap.end()){// vertex already exists, so reference it return vertIt->second; } @@ -274,7 +274,7 @@ int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) void ObjExporter::vecIndexMap::getVectors( std::vector& vecs ) { vecs.resize(vecMap.size()); - for(std::map::iterator it = vecMap.begin(); it != vecMap.end(); it++){ + for(vecIndexMap::dataType::iterator it = vecMap.begin(); it != vecMap.end(); it++){ vecs[it->second-1] = it->first; } } diff --git a/code/ObjExporter.h b/code/ObjExporter.h index 4f2f83240..4f6555aa5 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -113,10 +113,25 @@ private: std::vector vp, vn, vt; + + struct aiVectorCompare + { + bool operator() (const aiVector3D& a, const aiVector3D& b) const + { + if(a.x < b.x) return true; + if(a.x > b.x) return false; + if(a.y < b.y) return true; + if(a.y > b.y) return false; + if(a.z < b.z) return true; + return false; + } + }; + class vecIndexMap { int mNextIndex; - std::map vecMap; + typedef std::map dataType; + dataType vecMap; public: vecIndexMap():mNextIndex(1) diff --git a/include/assimp/vector3.h b/include/assimp/vector3.h index 5b3da297d..cbdee264d 100644 --- a/include/assimp/vector3.h +++ b/include/assimp/vector3.h @@ -85,7 +85,6 @@ public: // comparison bool operator== (const aiVector3t& other) const; bool operator!= (const aiVector3t& other) const; - bool operator< (const aiVector3t& other) const; template operator aiVector3t () const; diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl index 90370fa07..c03437980 100644 --- a/include/assimp/vector3.inl +++ b/include/assimp/vector3.inl @@ -149,16 +149,6 @@ AI_FORCE_INLINE bool aiVector3t::operator!= (const aiVector3t& oth } // ------------------------------------------------------------------------------------------------ template -AI_FORCE_INLINE bool aiVector3t::operator< (const aiVector3t& other) const { - if(x < other.x) return true; - if(x > other.x) return false; - if(y < other.y) return true; - if(y > other.y) return false; - if(z < other.z) return true; - return false; -} -// ------------------------------------------------------------------------------------------------ -template AI_FORCE_INLINE const aiVector3t aiVector3t::SymMul(const aiVector3t& o) { return aiVector3t(x*o.x,y*o.y,z*o.z); } From 325ef632cfad8efb3ece5f62121e0f6457bdc735 Mon Sep 17 00:00:00 2001 From: acgessler Date: Tue, 1 Oct 2013 17:56:00 +0200 Subject: [PATCH 052/104] PlyExporter: fix export format for compatibility with Blender and MeshLab (and the PLY spec). Fixes #122 --- code/PlyExporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index 257e6f1f7..e78cfd964 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -103,7 +103,7 @@ PlyExporter :: PlyExporter(const char* _filename, const aiScene* pScene) mOutput << "ply" << endl; mOutput << "format ascii 1.0" << endl; - mOutput << "Created by Open Asset Import Library - http://assimp.sf.net (v" + mOutput << "comment Created by Open Asset Import Library - http://assimp.sf.net (v" << aiGetVersionMajor() << '.' << aiGetVersionMinor() << '.' << aiGetVersionRevision() << ")" << endl; @@ -159,7 +159,7 @@ PlyExporter :: PlyExporter(const char* _filename, const aiScene* pScene) } mOutput << "element face " << faces << endl; - mOutput << "property list uint uint vertex_indices" << endl; + mOutput << "property list uint uint vertex_index" << endl; mOutput << "end_header" << endl; for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { From 3408a0a838b7ca52b3c36a483ebbf1e9b24666cb Mon Sep 17 00:00:00 2001 From: acgessler Date: Wed, 2 Oct 2013 01:39:59 +0200 Subject: [PATCH 053/104] Blender: iterative loading code for the linked list of scene objects, fixes #28 but is preliminary as it touches code that is normally machine-generated. --- code/BlenderDNA.h | 28 +++++++++------ code/BlenderDNA.inl | 80 ++++++++++++++++++++++++++++--------------- code/BlenderScene.cpp | 43 ++++++++++++++++++----- 3 files changed, 105 insertions(+), 46 deletions(-) diff --git a/code/BlenderDNA.h b/code/BlenderDNA.h index 2eeaee97a..b4733f385 100644 --- a/code/BlenderDNA.h +++ b/code/BlenderDNA.h @@ -278,19 +278,23 @@ public: // -------------------------------------------------------- // field parsing for pointer or dynamic array types // (boost::shared_ptr or boost::shared_array) + // The return value indicates whether the data was already cached. template class TOUT, typename T> - void ReadFieldPtr(TOUT& out, const char* name, - const FileDatabase& db) const; + bool ReadFieldPtr(TOUT& out, const char* name, + const FileDatabase& db, + bool non_recursive = false) const; // -------------------------------------------------------- // field parsing for static arrays of pointer or dynamic // array types (boost::shared_ptr[] or boost::shared_array[]) + // The return value indicates whether the data was already cached. template class TOUT, typename T, size_t N> - void ReadFieldPtr(TOUT (&out)[N], const char* name, + bool ReadFieldPtr(TOUT (&out)[N], const char* name, const FileDatabase& db) const; // -------------------------------------------------------- // field parsing for `normal` values + // The return value indicates whether the data was already cached. template void ReadField(T& out, const char* name, const FileDatabase& db) const; @@ -299,17 +303,18 @@ private: // -------------------------------------------------------- template