diff --git a/.travis.sh b/.travis.sh index 24aff9368..75f00ec60 100755 --- a/.travis.sh +++ b/.travis.sh @@ -5,8 +5,7 @@ # # License see LICENSE file # -function generate() -{ +function generate() { OPTIONS="-DASSIMP_WERROR=ON" if [ "$DISABLE_EXPORTERS" = "YES" ] ; then diff --git a/.travis.yml b/.travis.yml index fa37e5955..95e2fc164 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,6 @@ before_install: # install latest LCOV (1.9 was failing) - if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ${TRAVIS_BUILD_DIR} && wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz && tar xf lcov_1.11.orig.tar.gz && sudo make -C lcov-1.11/ install && gem install coveralls-lcov && lcov --version && g++ --version ; fi -branches: - only: - - master - os: - linux diff --git a/assimp.pc.in b/assimp.pc.in index 5b2139e6d..02cf59dc4 100644 --- a/assimp.pc.in +++ b/assimp.pc.in @@ -1,7 +1,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@/ libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@ -includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@/assimp +includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@ Name: @CMAKE_PROJECT_NAME@ Description: Import various well-known 3D model formats in an uniform manner. diff --git a/cmake-modules/CoverallsGenerateGcov.cmake b/cmake-modules/CoverallsGenerateGcov.cmake index ba506e3d4..104737164 100644 --- a/cmake-modules/CoverallsGenerateGcov.cmake +++ b/cmake-modules/CoverallsGenerateGcov.cmake @@ -310,7 +310,7 @@ foreach (GCOV_FILE ${GCOV_FILES}) message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}") # Loads the gcov file as a list of lines. - # (We first open the file and replace all occurences of [] with _ + # (We first open the file and replace all occurrences of [] with _ # because CMake will fail to parse a line containing unmatched brackets... # also the \ to escaped \n in macros screws up things.) # https://public.kitware.com/Bug/view.php?id=15369 @@ -329,7 +329,7 @@ foreach (GCOV_FILE ${GCOV_FILES}) # Instead of trying to parse the source from the # gcov file, simply read the file contents from the source file. # (Parsing it from the gcov is hard because C-code uses ; in many places - # which also happens to be the same as the CMake list delimeter). + # which also happens to be the same as the CMake list delimiter). file(READ ${GCOV_SRC_PATH} GCOV_FILE_SOURCE) string(REPLACE "\\" "\\\\" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") diff --git a/code/3DSExporter.cpp b/code/3DSExporter.cpp index 642f7dc57..7b937d878 100644 --- a/code/3DSExporter.cpp +++ b/code/3DSExporter.cpp @@ -151,7 +151,7 @@ namespace { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp -void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { std::shared_ptr outfile (pIOSystem->Open(pFile, "wb")); if(!outfile) { diff --git a/code/AMFImporter.hpp b/code/AMFImporter.hpp index 561ec3c8f..47ddc073b 100644 --- a/code/AMFImporter.hpp +++ b/code/AMFImporter.hpp @@ -249,7 +249,7 @@ private: /// \fn size_t PostprocessHelper_GetTextureID_Or_Create(const std::string& pID_R, const std::string& pID_G, const std::string& pID_B, const std::string& pID_A) /// Return converted texture ID which related to specified source textures ID's. If converted texture does not exist then it will be created and ID on new - /// converted texture will be returned. Convertion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it + /// converted texture will be returned. Conversion: set of textures from \ref CAMFImporter_NodeElement_Texture to one \ref SPP_Texture and place it /// to converted textures list. /// Any of source ID's can be absent(empty string) or even one ID only specified. But at least one ID must be specified. /// \param [in] pID_R - ID of source "red" texture. @@ -378,7 +378,7 @@ private: void XML_CheckNode_MustHaveChildren(); /// \fn bool XML_CheckNode_NameEqual(const std::string& pNodeName) - /// Chek if current node name is equal to pNodeName. + /// Check if current node name is equal to pNodeName. /// \param [in] pNodeName - name for checking. /// return true if current node name is equal to pNodeName, else - false. bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } diff --git a/code/AMFImporter_Node.hpp b/code/AMFImporter_Node.hpp index cb8b0b66d..522e6ccca 100644 --- a/code/AMFImporter_Node.hpp +++ b/code/AMFImporter_Node.hpp @@ -137,7 +137,7 @@ struct CAMFImporter_NodeElement_Instance : public CAMFImporter_NodeElement { /****************** Variables ******************/ - std::string ObjectID;///< ID of object for instanciation. + std::string ObjectID;///< ID of object for instantiation. /// \var Delta - The distance of translation in the x, y, or z direction, respectively, in the referenced object's coordinate system, to /// create an instance of the object in the current constellation. aiVector3D Delta; diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 789a11eb8..0e639026c 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -aiColor4D AMFImporter::SPP_Material::GetColor(const float pX, const float pY, const float pZ) const +aiColor4D AMFImporter::SPP_Material::GetColor(const float /*pX*/, const float /*pY*/, const float /*pZ*/) const { aiColor4D tcol; diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp index a6fbcd8f7..6bee6d6d1 100644 --- a/code/AssbinExporter.cpp +++ b/code/AssbinExporter.cpp @@ -810,7 +810,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size) } }; -void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { AssbinExport exporter; exporter.WriteBinaryDump( pFile, pIOSystem, pScene ); diff --git a/code/AssbinLoader.cpp b/code/AssbinLoader.cpp index f418638e1..a7044c119 100644 --- a/code/AssbinLoader.cpp +++ b/code/AssbinLoader.cpp @@ -200,6 +200,7 @@ template void ReadBounds( IOStream * stream, T* /*p*/, unsigned int void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* parent ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AINODE); /*uint32_t size =*/ Read(stream); @@ -274,6 +275,7 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node, aiNode* p void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AIBONE); /*uint32_t size =*/ Read(stream); @@ -298,6 +300,7 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b ) void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AIMESH); /*uint32_t size =*/ Read(stream); @@ -423,6 +426,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh ) void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY); /*uint32_t size =*/ Read(stream); @@ -440,6 +444,7 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL); /*uint32_t size =*/ Read(stream); @@ -462,6 +467,7 @@ void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat) void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM); /*uint32_t size =*/ Read(stream); @@ -511,6 +517,7 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd) void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION); /*uint32_t size =*/ Read(stream); @@ -532,6 +539,7 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim ) void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE); /*uint32_t size =*/ Read(stream); @@ -556,6 +564,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT); /*uint32_t size =*/ Read(stream); @@ -583,6 +592,7 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l ) void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA); /*uint32_t size =*/ Read(stream); @@ -599,6 +609,7 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam ) void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene ) { uint32_t chunkID = Read(stream); + (void)(chunkID); ai_assert(chunkID == ASSBIN_CHUNK_AISCENE); /*uint32_t size =*/ Read(stream); diff --git a/code/AssxmlExporter.cpp b/code/AssxmlExporter.cpp index 8019232c0..90ed66701 100644 --- a/code/AssxmlExporter.cpp +++ b/code/AssxmlExporter.cpp @@ -631,7 +631,7 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened) { } // end of namespace AssxmlExport -void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportSceneAssxml(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { IOStream * out = pIOSystem->Open( pFile, "wt" ); if (!out) return; diff --git a/code/BlenderIntermediate.h b/code/BlenderIntermediate.h index 0fc9cdafc..c6f9cba1e 100644 --- a/code/BlenderIntermediate.h +++ b/code/BlenderIntermediate.h @@ -110,7 +110,7 @@ namespace Blender { void operator= (const TempArray&) { } - TempArray(const TempArray& arr) { + TempArray(const TempArray& /*arr*/) { } private: diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 53ee07388..ffef6f067 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -68,7 +68,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { std::string path = DefaultIOSystem::absolutePath(std::string(pFile)); std::string file = DefaultIOSystem::completeBaseName(std::string(pFile)); @@ -141,6 +141,9 @@ void ColladaExporter::WriteFile() WriteControllerLibrary(); WriteSceneLibrary(); + + // customized, Writes the animation library + WriteAnimationsLibrary(); // useless Collada fu at the end, just in case we haven't had enough indirections, yet. mOutput << startstr << "" << endstr; @@ -1129,6 +1132,7 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy case FloatType_Color: floatsPerElement = 3; break; case FloatType_Mat4x4: floatsPerElement = 16; break; case FloatType_Weight: floatsPerElement = 1; break; + case FloatType_Time: floatsPerElement = 1; break; default: return; } @@ -1205,7 +1209,13 @@ void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataTy case FloatType_Weight: mOutput << startstr << "" << endstr; break; - } + + // customized, add animation related + case FloatType_Time: + mOutput << startstr << "" << endstr; + break; + + } PopTag(); mOutput << startstr << "" << endstr; @@ -1235,7 +1245,172 @@ void ColladaExporter::WriteSceneLibrary() PopTag(); mOutput << startstr << "" << endstr; } +// ------------------------------------------------------------------------------------------------ +void ColladaExporter::WriteAnimationLibrary(size_t pIndex) +{ + const aiAnimation * anim = mScene->mAnimations[pIndex]; + + if ( anim->mNumChannels == 0 && anim->mNumMeshChannels == 0 && anim->mNumMorphMeshChannels ==0 ) + return; + + const std::string animation_name_escaped = XMLEscape( anim->mName.C_Str() ); + std::string idstr = anim->mName.C_Str(); + std::string ending = std::string( "AnimId" ) + to_string(pIndex); + if (idstr.length() >= ending.length()) { + if (0 != idstr.compare (idstr.length() - ending.length(), ending.length(), ending)) { + idstr = idstr + ending; + } + } else { + idstr = idstr + ending; + } + const std::string idstrEscaped = XMLEscape(idstr); + + mOutput << startstr << "" << endstr; + PushTag(); + + for (size_t a = 0; a < anim->mNumChannels; ++a) { + const aiNodeAnim * nodeAnim = anim->mChannels[a]; + + // sanity check + if ( nodeAnim->mNumPositionKeys != nodeAnim->mNumScalingKeys || nodeAnim->mNumPositionKeys != nodeAnim->mNumRotationKeys ) continue; + + { + const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-input"); + + std::vector frames; + for( size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) { + frames.push_back(nodeAnim->mPositionKeys[i].mTime); + } + + WriteFloatArray( node_idstr , FloatType_Time, (const ai_real*) frames.data(), frames.size()); + frames.clear(); + } + + { + const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-output"); + + std::vector keyframes; + keyframes.reserve(nodeAnim->mNumPositionKeys * 16); + for( size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) { + + aiVector3D Scaling = nodeAnim->mScalingKeys[i].mValue; + aiMatrix4x4 ScalingM; // identity + ScalingM[0][0] = Scaling.x; ScalingM[1][1] = Scaling.y; ScalingM[2][2] = Scaling.z; + + aiQuaternion RotationQ = nodeAnim->mRotationKeys[i].mValue; + aiMatrix4x4 s = aiMatrix4x4( RotationQ.GetMatrix() ); + aiMatrix4x4 RotationM(s.a1, s.a2, s.a3, 0, s.b1, s.b2, s.b3, 0, s.c1, s.c2, s.c3, 0, 0, 0, 0, 1); + + aiVector3D Translation = nodeAnim->mPositionKeys[i].mValue; + aiMatrix4x4 TranslationM; // identity + TranslationM[0][3] = Translation.x; TranslationM[1][3] = Translation.y; TranslationM[2][3] = Translation.z; + + // Combine the above transformations + aiMatrix4x4 mat = TranslationM * RotationM * ScalingM; + + for( size_t j = 0; j < 4; ++j) { + keyframes.insert(keyframes.end(), mat[j], mat[j] + 4); + } + } + + WriteFloatArray( node_idstr, FloatType_Mat4x4, (const ai_real*) keyframes.data(), keyframes.size() / 16); + } + + { + std::vector names; + for ( size_t i = 0; i < nodeAnim->mNumPositionKeys; ++i) { + if ( nodeAnim->mPreState == aiAnimBehaviour_DEFAULT + || nodeAnim->mPreState == aiAnimBehaviour_LINEAR + || nodeAnim->mPreState == aiAnimBehaviour_REPEAT + ) { + names.push_back( "LINEAR" ); + } else if (nodeAnim->mPostState == aiAnimBehaviour_CONSTANT) { + names.push_back( "STEP" ); + } + } + + const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-interpolation"); + std::string arrayId = node_idstr + "-array"; + + mOutput << startstr << "" << endstr; + PushTag(); + + // source array + mOutput << startstr << " "; + for( size_t a = 0; a < names.size(); ++a ) { + mOutput << names[a] << " "; + } + mOutput << "" << endstr; + + mOutput << startstr << "" << endstr; + PushTag(); + + mOutput << startstr << "" << endstr; + PushTag(); + + mOutput << startstr << "" << endstr; + + PopTag(); + mOutput << startstr << "" << endstr; + + PopTag(); + mOutput << startstr << "" << endstr; + + PopTag(); + mOutput << startstr << "" << endstr; + } + + } + + for (size_t a = 0; a < anim->mNumChannels; ++a) { + const aiNodeAnim * nodeAnim = anim->mChannels[a]; + + { + // samplers + const std::string node_idstr = nodeAnim->mNodeName.data + std::string("_matrix-sampler"); + mOutput << startstr << "" << endstr; + PushTag(); + + mOutput << startstr << "mNodeName.data + std::string("_matrix-input") ) << "\"/>" << endstr; + mOutput << startstr << "mNodeName.data + std::string("_matrix-output") ) << "\"/>" << endstr; + mOutput << startstr << "mNodeName.data + std::string("_matrix-interpolation") ) << "\"/>" << endstr; + + PopTag(); + mOutput << startstr << "" << endstr; + } + } + + for (size_t a = 0; a < anim->mNumChannels; ++a) { + const aiNodeAnim * nodeAnim = anim->mChannels[a]; + + { + // channels + mOutput << startstr << "mNodeName.data + std::string("_matrix-sampler") ) << "\" target=\"" << XMLEscape(nodeAnim->mNodeName.data) << "/matrix\"/>" << endstr; + } + } + + PopTag(); + mOutput << startstr << "" << endstr; + +} +// ------------------------------------------------------------------------------------------------ +void ColladaExporter::WriteAnimationsLibrary() +{ + const std::string scene_name_escaped = XMLEscape(mScene->mRootNode->mName.C_Str()); + + if ( mScene->mNumAnimations > 0 ) { + mOutput << startstr << "" << endstr; + PushTag(); + + // start recursive write at the root node + for( size_t a = 0; a < mScene->mNumAnimations; ++a) + WriteAnimationLibrary( a ); + + PopTag(); + mOutput << startstr << "" << endstr; + } +} // ------------------------------------------------------------------------------------------------ // Helper to find a bone by name in the scene aiBone* findBone( const aiScene* scene, const char * name) { @@ -1251,6 +1426,59 @@ aiBone* findBone( const aiScene* scene, const char * name) { return NULL; } +// ------------------------------------------------------------------------------------------------ +const aiNode * findBoneNode( const aiNode* aNode, const aiBone* bone) +{ + if ( aNode && bone && aNode->mName == bone->mName ) { + return aNode; + } + + if ( aNode && bone ) { + for (unsigned int i=0; i < aNode->mNumChildren; ++i) { + aiNode * aChild = aNode->mChildren[i]; + const aiNode * foundFromChild = 0; + if ( aChild ) { + foundFromChild = findBoneNode( aChild, bone ); + if ( foundFromChild ) return foundFromChild; + } + } + } + + return NULL; +} + +const aiNode * findSkeletonRootNode( const aiScene* scene, const aiMesh * mesh) +{ + std::set topParentBoneNodes; + if ( mesh && mesh->mNumBones > 0 ) { + for (unsigned int i=0; i < mesh->mNumBones; ++i) { + aiBone * bone = mesh->mBones[i]; + + const aiNode * node = findBoneNode( scene->mRootNode, bone); + if ( node ) { + while ( node->mParent && findBone(scene, node->mParent->mName.C_Str() ) != 0 ) { + node = node->mParent; + } + topParentBoneNodes.insert( node ); + } + } + } + + if ( !topParentBoneNodes.empty() ) { + const aiNode * parentBoneNode = *topParentBoneNodes.begin(); + if ( topParentBoneNodes.size() == 1 ) { + return parentBoneNode; + } else { + for (auto it : topParentBoneNodes) { + if ( it->mParent ) return it->mParent; + } + return parentBoneNode; + } + } + + return NULL; +} + // ------------------------------------------------------------------------------------------------ // Recursively writes the given node void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode) @@ -1278,12 +1506,22 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode) } const std::string node_name_escaped = XMLEscape(pNode->mName.data); + /* // customized, Note! the id field is crucial for inter-xml look up, it cannot be replaced with sid ?! mOutput << startstr << "" << endstr; PushTag(); @@ -1291,7 +1529,11 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode) // write transformation - we can directly put the matrix there // TODO: (thom) decompose into scale - rot - quad to allow addressing it by animations afterwards const aiMatrix4x4& mat = pNode->mTransformation; - mOutput << startstr << ""; + + // customized, sid should be 'matrix' to match with loader code. + //mOutput << startstr << ""; + mOutput << startstr << ""; + mOutput << mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4 << " "; mOutput << mat.b1 << " " << mat.b2 << " " << mat.b3 << " " << mat.b4 << " "; mOutput << mat.c1 << " " << mat.c2 << " " << mat.c3 << " " << mat.c4 << " "; @@ -1319,7 +1561,7 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode) for( size_t a = 0; a < pNode->mNumMeshes; ++a ) { const aiMesh* mesh = mScene->mMeshes[pNode->mMeshes[a]]; - // do not instanciate mesh if empty. I wonder how this could happen + // do not instantiate mesh if empty. I wonder how this could happen if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 ) continue; @@ -1335,7 +1577,13 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode) << endstr; PushTag(); - mOutput << startstr << "#skeleton_root" << endstr; + // note! this mFoundSkeletonRootNodeID some how affects animation, it makes the mesh attaches to armature skeleton root node. + // use the first bone to find skeleton root + const aiNode * skeletonRootBoneNode = findSkeletonRootNode( pScene, mesh ); + if ( skeletonRootBoneNode ) { + mFoundSkeletonRootNodeID = XMLEscape( skeletonRootBoneNode->mName.C_Str() ); + } + mOutput << startstr << "#" << mFoundSkeletonRootNodeID << "" << endstr; } mOutput << startstr << "" << endstr; PushTag(); diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index c78272726..e7a4a9b5d 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -114,7 +114,9 @@ protected: /// Writes the given mesh void WriteGeometry( size_t pIndex); - enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight }; + //enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight }; + // customized to add animation related type + enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color, FloatType_Mat4x4, FloatType_Weight, FloatType_Time }; /// Writes a float array of the given type void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount); @@ -122,6 +124,11 @@ protected: /// Writes the scene library void WriteSceneLibrary(); + // customized, Writes the animation library + void WriteAnimationsLibrary(); + void WriteAnimationLibrary( size_t pIndex); + std::string mFoundSkeletonRootNodeID = "skeleton_root"; // will be replaced by found node id in the WriteNode call. + /// Recursively writes the given node void WriteNode( const aiScene* scene, aiNode* pNode); diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index 8ccd6cafe..e691a6062 100644 --- a/code/ColladaHelper.h +++ b/code/ColladaHelper.h @@ -302,7 +302,7 @@ struct Accessor size_t mOffset; // in number of values size_t mStride; // Stride in number of values std::vector mParams; // names of the data streams in the accessors. Empty string tells to ignore. - size_t mSubOffset[4]; // Suboffset inside the object for the common 4 elements. For a vector, thats XYZ, for a color RGBA and so on. + size_t mSubOffset[4]; // Suboffset inside the object for the common 4 elements. For a vector, that's XYZ, for a color RGBA and so on. // For example, SubOffset[0] denotes which of the values inside the object is the vector X component. std::string mSource; // URL of the source array mutable const Data* mData; // Pointer to the source array, if resolved. NULL else diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index ccf79ed62..d2141c374 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -1619,7 +1619,7 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI); // transparency, a very hard one. seemingly not all files are following the - // specification here (1.0 transparency => completly opaque)... + // specification here (1.0 transparency => completely opaque)... // therefore, we let the opportunity for the user to manually invert // the transparency if necessary and we add preliminary support for RGB_ZERO mode if(effect.mTransparency >= 0.f && effect.mTransparency <= 1.f) { diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 7b6592351..2fe0f1e0a 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -224,7 +224,7 @@ void ColladaParser::ReadStructure() } // ------------------------------------------------------------------------------------------------ -// Reads asset informations such as coordinate system informations and legal blah +// Reads asset information such as coordinate system information and legal blah void ColladaParser::ReadAssetInfo() { if( mReader->isEmptyElement()) @@ -2469,8 +2469,7 @@ void ColladaParser::CopyVertex(size_t currentVertex, size_t numOffsets, size_t n size_t baseOffset = currentPrimitive * numOffsets * numPoints + currentVertex * numOffsets; // don't overrun the boundaries of the index list - size_t maxIndexRequested = baseOffset + numOffsets - 1; - ai_assert(maxIndexRequested < indices.size()); + ai_assert((baseOffset + numOffsets - 1) < indices.size()); // extract per-vertex channels using the global per-vertex offset for (std::vector::iterator it = pMesh->mPerVertexData.begin(); it != pMesh->mPerVertexData.end(); ++it) diff --git a/code/ColladaParser.h b/code/ColladaParser.h index b34974470..941ab8414 100644 --- a/code/ColladaParser.h +++ b/code/ColladaParser.h @@ -77,7 +77,7 @@ namespace Assimp /** Reads the structure of the file */ void ReadStructure(); - /** Reads asset informations such as coordinate system informations and legal blah */ + /** Reads asset information such as coordinate system information and legal blah */ void ReadAssetInfo(); /** Reads the animation library */ diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index e97e22859..6d61a0669 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -344,7 +344,7 @@ bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool return false; } -void D3MFImporter::SetupProperties(const Importer *pImp) +void D3MFImporter::SetupProperties(const Importer */*pImp*/) { } diff --git a/code/D3MFOpcPackage.cpp b/code/D3MFOpcPackage.cpp index b6b1ba170..03c39a29d 100644 --- a/code/D3MFOpcPackage.cpp +++ b/code/D3MFOpcPackage.cpp @@ -379,6 +379,7 @@ IOStream *D3MFZipArchive::Open(const char* pFile, const char* /*pMode*/) { // ------------------------------------------------------------------------------------------------ // Close a filestream. void D3MFZipArchive::Close(IOStream *pFile) { + (void)(pFile); ai_assert(pFile != NULL); // We don't do anything in case the file would be opened again in the future diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 1e2d7cbf1..76bda9fdf 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -83,6 +83,7 @@ void ExportSceneCollada(const char*,IOSystem*, const aiScene*, const ExportPrope void ExportSceneXFile(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneStep(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneObj(const char*,IOSystem*, const aiScene*, const ExportProperties*); +void ExportSceneObjNoMtl(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneSTL(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*, const ExportProperties*); void ExportScenePly(const char*,IOSystem*, const aiScene*, const ExportProperties*); @@ -115,6 +116,8 @@ Exporter::ExportFormatEntry gExporters[] = #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */), + Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl, + aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */), #endif #ifndef ASSIMP_BUILD_NO_STL_EXPORTER @@ -241,7 +244,7 @@ bool Exporter::IsDefaultIOHandler() const { // ------------------------------------------------------------------------------------------------ const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const char* pFormatId, - unsigned int, const ExportProperties* pProperties ) { + unsigned int, const ExportProperties* /*pProperties*/ ) { if (pimpl->blob) { delete pimpl->blob; pimpl->blob = NULL; diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 1a80fa4f5..a1e3ae07c 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -645,7 +645,6 @@ void Converter::ConvertCameras( const Model& model ) } } - void Converter::ConvertLight( const Model& model, const Light& light ) { lights.push_back( new aiLight() ); @@ -783,7 +782,6 @@ const char* Converter::NameTransformationComp( TransformationComp comp ) return NULL; } - const char* Converter::NameTransformationCompProperty( TransformationComp comp ) { switch ( comp ) @@ -2239,9 +2237,17 @@ void Converter::ConvertAnimations() } } +void Converter::RenameNode( const std::string& fixed_name, const std::string& new_name ) { + if ( node_names.find( fixed_name ) == node_names.end() ) { + FBXImporter::LogError( "Cannot rename node " + fixed_name + ", not existing."); + return; + } + + if ( node_names.find( new_name ) != node_names.end() ) { + FBXImporter::LogError( "Cannot rename node " + fixed_name + " to " + new_name +", name already existing." ); + return; + } -void Converter::RenameNode( const std::string& fixed_name, const std::string& new_name ) -{ ai_assert( node_names.find( fixed_name ) != node_names.end() ); ai_assert( node_names.find( new_name ) == node_names.end() ); @@ -2429,6 +2435,7 @@ void Converter::ConvertAnimationStack( const AnimationStack& st ) anim->mTicksPerSecond = anim_fps; } +#ifdef ASSIMP_BUILD_DEBUG // ------------------------------------------------------------------------------------------------ // sanity check whether the input is ok static void validateAnimCurveNodes( const std::vector& curves, @@ -2446,6 +2453,7 @@ static void validateAnimCurveNodes( const std::vector } } } +#endif // ASSIMP_BUILD_DEBUG // ------------------------------------------------------------------------------------------------ void Converter::GenerateNodeAnimations( std::vector& node_anims, diff --git a/code/FBXParser.cpp b/code/FBXParser.cpp index b5661caf8..d4d06567b 100644 --- a/code/FBXParser.cpp +++ b/code/FBXParser.cpp @@ -103,6 +103,7 @@ namespace { T SafeParse(const char* data, const char* end) { // Actual size validation happens during Tokenization so // this is valid as an assertion. + (void)(end); ai_assert(static_cast(end - data) >= sizeof(T)); T result = static_cast(0); ::memcpy(&result, data, sizeof(T)); diff --git a/code/FIReader.cpp b/code/FIReader.cpp index 95b22a1b8..fdf6b8a83 100755 --- a/code/FIReader.cpp +++ b/code/FIReader.cpp @@ -1776,17 +1776,17 @@ public: return reader->getParserFormat(); } - virtual std::shared_ptr getAttributeEncodedValue(int idx) const /*override*/ { + virtual std::shared_ptr getAttributeEncodedValue(int /*idx*/) const /*override*/ { return nullptr; } - virtual std::shared_ptr getAttributeEncodedValue(const char* name) const /*override*/ { + virtual std::shared_ptr getAttributeEncodedValue(const char* /*name*/) const /*override*/ { return nullptr; } - virtual void registerDecoder(const std::string &algorithmUri, std::unique_ptr decoder) /*override*/ {} + virtual void registerDecoder(const std::string &/*algorithmUri*/, std::unique_ptr /*decoder*/) /*override*/ {} - virtual void registerVocabulary(const std::string &vocabularyUri, const FIVocabulary *vocabulary) /*override*/ {} + virtual void registerVocabulary(const std::string &/*vocabularyUri*/, const FIVocabulary */*vocabulary*/) /*override*/ {} private: diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index a6cb037b2..0113e4c5b 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -169,8 +169,8 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) // ------------------------------------------------------------------------------------------------ template -inline const char* ValidateArrayContents(const T* arr, unsigned int size, - const std::vector& dirtyMask, bool mayBeIdentical = false, bool mayBeZero = true) +inline const char* ValidateArrayContents(const T* /*arr*/, unsigned int /*size*/, + const std::vector& /*dirtyMask*/, bool /*mayBeIdentical = false*/, bool /*mayBeZero = true*/) { return NULL; } diff --git a/code/IFCCurve.cpp b/code/IFCCurve.cpp index 4a8026551..2aa3ef6a4 100644 --- a/code/IFCCurve.cpp +++ b/code/IFCCurve.cpp @@ -513,6 +513,7 @@ IfcFloat Curve::GetParametricRangeDelta() const { // ------------------------------------------------------------------------------------------------ size_t Curve::EstimateSampleCount(IfcFloat a, IfcFloat b) const { + (void)(a); (void)(b); ai_assert( InRange( a ) ); ai_assert( InRange( b ) ); diff --git a/code/IFCReaderGen1.cpp b/code/IFCReaderGen1.cpp index d334e8322..bd526d454 100644 --- a/code/IFCReaderGen1.cpp +++ b/code/IFCReaderGen1.cpp @@ -1045,7 +1045,7 @@ void IFC::GetSchema(EXPRESS::ConversionSchema& out) namespace STEP { // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const STEP::DB& db, const LIST& params, NotImplemented* in) +template <> size_t GenericFill(const STEP::DB& /*db*/, const LIST& /*params*/, NotImplemented* /*in*/) { return 0; } @@ -1253,7 +1253,7 @@ template <> size_t GenericFill(const DB& db, const LIST& return base; } // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, IfcRepresentationItem* in) +template <> size_t GenericFill(const DB& /*db*/, const LIST& /*params*/, IfcRepresentationItem* /*in*/) { size_t base = 0; return base; @@ -1715,7 +1715,7 @@ template <> size_t GenericFill(const DB& db, const LIST& params, I return base; } // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& db, const LIST& params, IfcObjectPlacement* in) +template <> size_t GenericFill(const DB& /*db*/, const LIST& /*params*/, IfcObjectPlacement* /*in*/) { size_t base = 0; return base; diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 8cc4acaad..5113ab70d 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -394,7 +394,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector 3 && in[1] == ':'&& in[2] != '\\' && in[2] != '/') { diff --git a/code/MD2Loader.cpp b/code/MD2Loader.cpp index cb494d5b2..f0a5432bf 100644 --- a/code/MD2Loader.cpp +++ b/code/MD2Loader.cpp @@ -274,11 +274,9 @@ void MD2Importer::InternReadFile( const std::string& pFile, aiMesh* pcMesh = pScene->mMeshes[0] = new aiMesh(); pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - // navigate to the begin of the frame data - BE_NCONST MD2::Frame* pcFrame = (BE_NCONST MD2::Frame*) ((uint8_t*) - m_pcHeader + m_pcHeader->offsetFrames); - - pcFrame += configFrameID; + // navigate to the begin of the current frame data + BE_NCONST MD2::Frame* pcFrame = (BE_NCONST MD2::Frame*) ((uint8_t*) + m_pcHeader + m_pcHeader->offsetFrames + (m_pcHeader->frameSize * configFrameID)); // navigate to the begin of the triangle data MD2::Triangle* pcTriangles = (MD2::Triangle*) ((uint8_t*) diff --git a/code/MMDImporter.cpp b/code/MMDImporter.cpp index c40978c0e..cf7c87c8a 100644 --- a/code/MMDImporter.cpp +++ b/code/MMDImporter.cpp @@ -107,7 +107,7 @@ const aiImporterDesc *MMDImporter::GetInfo() const { return &desc; } // ------------------------------------------------------------------------------------------------ // MMD import implementation void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene, - IOSystem *pIOHandler) { + IOSystem */*pIOHandler*/) { // Read file by istream std::filebuf fb; if (!fb.open(file, std::ios::in | std::ios::binary)) { diff --git a/code/MMDPmxParser.cpp b/code/MMDPmxParser.cpp index 3af23529a..5be370f26 100644 --- a/code/MMDPmxParser.cpp +++ b/code/MMDPmxParser.cpp @@ -471,7 +471,7 @@ namespace pmx stream->read((char*) &this->is_near, sizeof(uint8_t)); } - void PmxSoftBody::Read(std::istream *stream, PmxSetting *setting) + void PmxSoftBody::Read(std::istream */*stream*/, PmxSetting */*setting*/) { // 未実装 std::cerr << "Not Implemented Exception" << std::endl; diff --git a/code/MMDVmdParser.h b/code/MMDVmdParser.h index 778ee1161..43e7a923a 100644 --- a/code/MMDVmdParser.h +++ b/code/MMDVmdParser.h @@ -302,7 +302,7 @@ namespace vmd return result; } - bool SaveToFile(const std::u16string& filename) + bool SaveToFile(const std::u16string& /*filename*/) { // TODO: How to adapt u16string to string? /* diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 692eac0e6..a8bf9935a 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -58,7 +58,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp -void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) { +void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { // invoke the exporter ObjExporter exporter(pFile, pScene); @@ -83,18 +83,40 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene } } +// ------------------------------------------------------------------------------------------------ +// Worker function for exporting a scene to Wavefront OBJ without the material file. Prototyped and registered in Exporter.cpp +void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) { + // invoke the exporter + ObjExporter exporter(pFile, pScene, true); + + if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + + // we're still here - export successfully completed. Write both the main OBJ file and the material script + { + std::unique_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); + } + + +} + } // end of namespace Assimp static const std::string MaterialExt = ".mtl"; // ------------------------------------------------------------------------------------------------ -ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene) +ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMtl) : filename(_filename) , pScene(pScene) , vp() , vn() , vt() -, vc() +, vc() , mVpMap() , mVnMap() , mVtMap() @@ -108,8 +130,9 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene) mOutputMat.imbue(l); mOutputMat.precision(16); - WriteGeometryFile(); - WriteMaterialFile(); + WriteGeometryFile(noMtl); + if (!noMtl) + WriteMaterialFile(); } // ------------------------------------------------------------------------------------------------ @@ -132,7 +155,7 @@ std::string ObjExporter :: GetMaterialLibName() // ------------------------------------------------------------------------------------------------ std::string ObjExporter::GetMaterialLibFileName() { - // Remove existing .obj file extention so that the final material file name will be fileName.mtl and not fileName.obj.mtl + // Remove existing .obj file extension so that the final material file name will be fileName.mtl and not fileName.obj.mtl size_t lastdot = filename.find_last_of('.'); if (lastdot != std::string::npos) return filename.substr(0, lastdot) + MaterialExt; @@ -193,7 +216,7 @@ void ObjExporter::WriteMaterialFile() if(AI_SUCCESS == mat->Get(AI_MATKEY_COLOR_TRANSPARENT,c)) { mOutputMat << "Tf " << c.r << " " << c.g << " " << c.b << endl; } - + ai_real o; if(AI_SUCCESS == mat->Get(AI_MATKEY_OPACITY,o)) { mOutputMat << "d " << o << endl; @@ -235,10 +258,10 @@ void ObjExporter::WriteMaterialFile() } } -// ------------------------------------------------------------------------------------------------ -void ObjExporter::WriteGeometryFile() { +void ObjExporter::WriteGeometryFile(bool noMtl) { WriteHeader(mOutput); - mOutput << "mtllib " << GetMaterialLibName() << endl << endl; + if (!noMtl) + mOutput << "mtllib " << GetMaterialLibName() << endl << endl; // collect mesh geometry aiMatrix4x4 mBase; @@ -256,8 +279,10 @@ void ObjExporter::WriteGeometryFile() { mOutput << "# " << vp.size() << " vertex positions and colors" << endl; size_t colIdx = 0; for ( const aiVector3D& v : vp ) { - mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl; - colIdx++; + if ( colIdx < vc.size() ) { + mOutput << "v " << v.x << " " << v.y << " " << v.z << " " << vc[ colIdx ].r << " " << vc[ colIdx ].g << " " << vc[ colIdx ].b << endl; + } + ++colIdx; } } mOutput << endl; @@ -284,7 +309,8 @@ void ObjExporter::WriteGeometryFile() { if (!m.name.empty()) { mOutput << "g " << m.name << endl; } - mOutput << "usemtl " << m.matname << endl; + if (!noMtl) + mOutput << "usemtl " << m.matname << endl; for(const Face& f : m.faces) { mOutput << f.kind << ' '; @@ -341,7 +367,7 @@ int ObjExporter::colIndexMap::getIndex( const aiColor4D& col ) { colMap[ col ] = mNextIndex; int ret = mNextIndex; mNextIndex++; - + return ret; } @@ -358,7 +384,7 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4 mMeshes.push_back(MeshInstance()); MeshInstance& mesh = mMeshes.back(); - mesh.name = std::string(name.data,name.length) + (m->mName.length ? "_" + std::string(m->mName.data,m->mName.length) : ""); + mesh.name = std::string( name.data, name.length ); mesh.matname = GetMaterialName(m->mMaterialIndex); mesh.faces.resize(m->mNumFaces); diff --git a/code/ObjExporter.h b/code/ObjExporter.h index fb60402d7..391f8416d 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -62,7 +62,7 @@ namespace Assimp { class ObjExporter { public: /// Constructor for a specific scene to export - ObjExporter(const char* filename, const aiScene* pScene); + ObjExporter(const char* filename, const aiScene* pScene, bool noMtl=false); ~ObjExporter(); std::string GetMaterialLibName(); std::string GetMaterialLibFileName(); @@ -97,7 +97,7 @@ private: void WriteHeader(std::ostringstream& out); void WriteMaterialFile(); - void WriteGeometryFile(); + void WriteGeometryFile(bool noMtl=false); std::string GetMaterialName(unsigned int index); void AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat); void AddNode(const aiNode* nd, const aiMatrix4x4& mParent); diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 4b203a8c2..d89d52977 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -477,6 +477,9 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { } } else { //On error, std::atoi will return 0 which is not a valid value + delete face; + delete m_pModel; + m_pModel = nullptr; throw DeadlyImportError("OBJ: Invalid face indice"); } diff --git a/code/OgreMaterial.cpp b/code/OgreMaterial.cpp index dfb77ffef..1abca2cf1 100644 --- a/code/OgreMaterial.cpp +++ b/code/OgreMaterial.cpp @@ -258,7 +258,7 @@ aiMaterial* OgreImporter::ReadMaterial(const std::string &pFile, Assimp::IOSyste ReadTechnique(Trim(techniqueName), ss, material); } - // Read informations from a custom material + // Read information from a custom material /** @todo This "set $x y" does not seem to be a official Ogre material system feature. Materials can inherit other materials and override texture units by using the (unique) parent texture unit name in your cloned material. diff --git a/code/OpenGEXExporter.cpp b/code/OpenGEXExporter.cpp index ea3c770ec..b3597656b 100644 --- a/code/OpenGEXExporter.cpp +++ b/code/OpenGEXExporter.cpp @@ -51,7 +51,7 @@ OpenGEXExporter::OpenGEXExporter() { OpenGEXExporter::~OpenGEXExporter() { } -bool OpenGEXExporter::exportScene( const char *filename, const aiScene* pScene ) { +bool OpenGEXExporter::exportScene( const char */*filename*/, const aiScene* /*pScene*/ ) { return true; } diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 47e3e3e8c..52e9ce501 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -431,7 +431,7 @@ void OpenGEXImporter::handleNodes( DDLNode *node, aiScene *pScene ) { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == node || nullptr == m_ctx ) { return; } @@ -467,7 +467,7 @@ void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene *pScene ) { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == m_currentNode ) { throw DeadlyImportError( "No current node for name." ); return; @@ -512,7 +512,7 @@ static void getRefNames( DDLNode *node, std::vector &names ) { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == m_currentNode ) { throw DeadlyImportError( "No parent node for name." ); return; @@ -536,7 +536,7 @@ void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleMaterialRefNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleMaterialRefNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == m_currentNode ) { throw DeadlyImportError( "No parent node for name." ); return; @@ -674,7 +674,7 @@ static void setMatrix( aiNode *node, DataArrayList *transformData ) { } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == m_currentNode ) { throw DeadlyImportError( "No parent node for name." ); return; @@ -819,7 +819,7 @@ static void copyColor4DArray( size_t numItems, DataArrayList *vaList, aiColor4D } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == node ) { throw DeadlyImportError( "No parent node for name." ); return; @@ -862,7 +862,7 @@ void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == node ) { throw DeadlyImportError( "No parent node for name." ); return; @@ -1001,7 +1001,7 @@ void OpenGEXImporter::handleMaterialNode( ODDLParser::DDLNode *node, aiScene *pS } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == node ) { return; } @@ -1040,7 +1040,7 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if( nullptr == node ) { return; } @@ -1074,7 +1074,7 @@ void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pSc } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleParamNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleParamNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if ( nullptr == node ) { return; } @@ -1103,7 +1103,7 @@ void OpenGEXImporter::handleParamNode( ODDLParser::DDLNode *node, aiScene *pScen } //------------------------------------------------------------------------------------------------ -void OpenGEXImporter::handleAttenNode( ODDLParser::DDLNode *node, aiScene *pScene ) { +void OpenGEXImporter::handleAttenNode( ODDLParser::DDLNode *node, aiScene * /*pScene*/ ) { if ( nullptr == node ) { return; } diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index eb0867046..b20c2b328 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -65,7 +65,7 @@ template<> const char* type_of(double&) { return "double"; } // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp -void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { // invoke the exporter PlyExporter exporter(pFile, pScene); @@ -83,7 +83,7 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } -void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { // invoke the exporter PlyExporter exporter(pFile, pScene, true); diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index f4b68a83f..65de665ab 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -381,6 +381,11 @@ bool PLY::Element::ParseElement(IOStreamBuffer &streamBuffer, std::vector< { char* endPos = &buffer[0] + (strlen(&buffer[0]) - 1); pOut->szName = std::string(&buffer[0], endPos); + + // go to the next line + PLY::DOM::SkipSpacesAndLineEnd(buffer); + + return true; } //parse the number of occurrences of this element @@ -933,7 +938,7 @@ bool PLY::PropertyInstance::ParseValue(const char* &pCur, { ai_assert(NULL != pCur); ai_assert(NULL != out); - + //calc element size bool ret = true; switch (eType) diff --git a/code/Q3BSPZipArchive.cpp b/code/Q3BSPZipArchive.cpp index 7428c04c3..86c966d8e 100644 --- a/code/Q3BSPZipArchive.cpp +++ b/code/Q3BSPZipArchive.cpp @@ -255,6 +255,7 @@ IOStream *Q3BSPZipArchive::Open(const char* pFile, const char* /*pMode*/) { // ------------------------------------------------------------------------------------------------ // Close a filestream. void Q3BSPZipArchive::Close(IOStream *pFile) { + (void)(pFile); ai_assert(pFile != NULL); // We don't do anything in case the file would be opened again in the future diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index bdda3c677..e85c9bdcb 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -163,7 +163,7 @@ static aiColor3D ReadColor(StreamReaderLE* stream) return aiColor3D(r, g, b); } -static void UnknownChunk(StreamReaderLE* stream, const SIBChunk& chunk) +static void UnknownChunk(StreamReaderLE* /*stream*/, const SIBChunk& chunk) { char temp[5] = { static_cast(( chunk.Tag>>24 ) & 0xff), diff --git a/code/STEPFileEncoding.cpp b/code/STEPFileEncoding.cpp index f9a9dd1ce..7204f802b 100644 --- a/code/STEPFileEncoding.cpp +++ b/code/STEPFileEncoding.cpp @@ -334,7 +334,7 @@ bool STEP::StringToUTF8(std::string& s) size_t j = basei, jend = s.size()-3; for (; j < jend; ++j) { - if (s[j] == '\\' && s[j] == 'X' && s[j] == '0' && s[j] == '\\') { + if (s[j] == '\\' && s[j+1] == 'X' && s[j+2] == '0' && s[j+3] == '\\') { break; } } diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index f94debfc9..60b5d8bf3 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -57,7 +57,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp -void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { // invoke the exporter STLExporter exporter(pFile, pScene); @@ -74,7 +74,7 @@ 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, const ExportProperties* pProperties) +void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) { // invoke the exporter STLExporter exporter(pFile, pScene, true); diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index f4d6ddda7..600c4275d 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -80,7 +80,9 @@ static bool IsBinarySTL(const char* buffer, unsigned int fileSize) { return false; } - const uint32_t faceCount = *reinterpret_cast(buffer + 80); + const char *facecount_pos = buffer + 80; + uint32_t faceCount( 0 ); + ::memcpy( &faceCount, facecount_pos, sizeof( uint32_t ) ); const uint32_t expectedBinaryFileSize = faceCount * 50 + 84; return expectedBinaryFileSize == fileSize; @@ -200,17 +202,17 @@ void STLImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS if (IsBinarySTL(mBuffer, fileSize)) { bMatClr = LoadBinaryFile(); } else if (IsAsciiSTL(mBuffer, fileSize)) { - LoadASCIIFile(); + LoadASCIIFile( pScene->mRootNode ); } else { throw DeadlyImportError( "Failed to determine STL storage representation for " + pFile + "."); } // add all created meshes to the single node - pScene->mRootNode->mNumMeshes = pScene->mNumMeshes; + /*pScene->mRootNode->mNumMeshes = pScene->mNumMeshes; pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes]; for (unsigned int i = 0; i < pScene->mNumMeshes; i++) pScene->mRootNode->mMeshes[i] = i; - + */ // create a single default material, using a white diffuse color for consistency with // other geometric types (e.g., PLY). aiMaterial* pcMat = new aiMaterial(); @@ -231,11 +233,12 @@ void STLImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS pScene->mMaterials = new aiMaterial*[1]; pScene->mMaterials[0] = pcMat; } + // ------------------------------------------------------------------------------------------------ // Read an ASCII STL file -void STLImporter::LoadASCIIFile() -{ +void STLImporter::LoadASCIIFile( aiNode *root ) { std::vector meshes; + std::vector nodes; const char* sz = mBuffer; const char* bufferEnd = mBuffer + fileSize; std::vector positionBuffer; @@ -247,12 +250,15 @@ void STLImporter::LoadASCIIFile() positionBuffer.reserve(sizeEstimate); normalBuffer.reserve(sizeEstimate); - while (IsAsciiSTL(sz, static_cast(bufferEnd - sz))) - { + while (IsAsciiSTL(sz, static_cast(bufferEnd - sz))) { + std::vector meshIndices; aiMesh* pMesh = new aiMesh(); pMesh->mMaterialIndex = 0; + meshIndices.push_back( meshes.size() ); meshes.push_back(pMesh); - + aiNode *node = new aiNode; + node->mParent = root; + nodes.push_back( node ); SkipSpaces(&sz); ai_assert(!IsLineEnd(sz)); @@ -265,20 +271,21 @@ void STLImporter::LoadASCIIFile() size_t temp; // setup the name of the node - if ((temp = (size_t)(sz-szMe))) { + if ((temp = (size_t)(sz-szMe))) { if (temp >= MAXLEN) { throw DeadlyImportError( "STL: Node name too long" ); } - - pScene->mRootNode->mName.length = temp; - memcpy(pScene->mRootNode->mName.data,szMe,temp); - pScene->mRootNode->mName.data[temp] = '\0'; + std::string name( szMe, temp ); + node->mName.Set( name.c_str() ); + //pScene->mRootNode->mName.length = temp; + //memcpy(pScene->mRootNode->mName.data,szMe,temp); + //pScene->mRootNode->mName.data[temp] = '\0'; + } else { + pScene->mRootNode->mName.Set(""); } - else pScene->mRootNode->mName.Set(""); unsigned int faceVertexCounter = 3; - for ( ;; ) - { + for ( ;; ) { // go to the next token if(!SkipSpacesAndLineEnd(&sz)) { @@ -300,9 +307,7 @@ void STLImporter::LoadASCIIFile() SkipSpaces(&sz); if (strncmp(sz,"normal",6)) { DefaultLogger::get()->warn("STL: a facet normal vector was expected but not found"); - } - else - { + } else { if (sz[6] == '\0') { throw DeadlyImportError("STL: unexpected EOF while parsing facet"); } @@ -316,16 +321,11 @@ void STLImporter::LoadASCIIFile() normalBuffer.push_back(*vn); normalBuffer.push_back(*vn); } - } - // vertex 1.50000 1.50000 0.00000 - else if (!strncmp(sz,"vertex",6) && ::IsSpaceOrNewLine(*(sz+6))) - { + } else if (!strncmp(sz,"vertex",6) && ::IsSpaceOrNewLine(*(sz+6))) { // vertex 1.50000 1.50000 0.00000 if (faceVertexCounter >= 3) { DefaultLogger::get()->error("STL: a facet with more than 3 vertices has been found"); ++sz; - } - else - { + } else { if (sz[6] == '\0') { throw DeadlyImportError("STL: unexpected EOF while parsing facet"); } @@ -340,17 +340,14 @@ void STLImporter::LoadASCIIFile() sz = fast_atoreal_move(sz, (ai_real&)vn->z ); faceVertexCounter++; } - } - else if (!::strncmp(sz,"endsolid",8)) { + } else if (!::strncmp(sz,"endsolid",8)) { do { ++sz; } while (!::IsLineEnd(*sz)); SkipSpacesAndLineEnd(&sz); // finished! break; - } - // else skip the whole identifier - else { + } else { // else skip the whole identifier do { ++sz; } while (!::IsSpaceOrNewLine(*sz)); @@ -380,13 +377,22 @@ void STLImporter::LoadASCIIFile() // now copy faces addFacesToMesh(pMesh); + + // assign the meshes to the current node + pushMeshesToNode( meshIndices, node ); } + // now add the loaded meshes pScene->mNumMeshes = (unsigned int)meshes.size(); pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; - for (size_t i = 0; i < meshes.size(); i++) - { - pScene->mMeshes[i] = meshes[i]; + for (size_t i = 0; i < meshes.size(); i++) { + pScene->mMeshes[ i ] = meshes[i]; + } + + root->mNumChildren = nodes.size(); + root->mChildren = new aiNode*[ root->mNumChildren ]; + for ( size_t i=0; imChildren[ i ] = nodes[ i ]; } } @@ -513,4 +519,18 @@ bool STLImporter::LoadBinaryFile() return false; } +void STLImporter::pushMeshesToNode( std::vector &meshIndices, aiNode *node ) { + ai_assert( nullptr != node ); + if ( meshIndices.empty() ) { + return; + } + + node->mNumMeshes = static_cast( meshIndices.size() ); + node->mMeshes = new unsigned int[ meshIndices.size() ]; + for ( size_t i=0; imMeshes[ i ] = meshIndices[ i ]; + } + meshIndices.clear(); +} + #endif // !! ASSIMP_BUILD_NO_STL_IMPORTER diff --git a/code/STLLoader.h b/code/STLLoader.h index 87ed3288d..c51604861 100644 --- a/code/STLLoader.h +++ b/code/STLLoader.h @@ -48,53 +48,61 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "BaseImporter.h" #include -namespace Assimp { +// Forward declarations +struct aiNode; + +namespace Assimp { + // --------------------------------------------------------------------------- -/** Importer class for the sterolithography STL file format -*/ -class STLImporter : public BaseImporter -{ +/** + * @brief Importer class for the sterolithography STL file format. + */ +class STLImporter : public BaseImporter { public: + /** + * @brief STLImporter, the class default constructor. + */ STLImporter(); + + /** + * @brief The class destructor. + */ ~STLImporter(); - -public: - - // ------------------------------------------------------------------- - /** Returns whether the class can handle the format of the given file. - * See BaseImporter::CanRead() for details. + /** + * @brief Returns whether the class can handle the format of the given file. + * See BaseImporter::CanRead() for details. */ - bool CanRead( const std::string& pFile, IOSystem* pIOHandler, - bool checkSig) const; + bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const; protected: - // ------------------------------------------------------------------- - /** Return importer meta information. - * See #BaseImporter::GetInfo for the details + /** + * @brief Return importer meta information. + * See #BaseImporter::GetInfo for the details */ const aiImporterDesc* GetInfo () const; - // ------------------------------------------------------------------- - /** Imports the given file into the given scene structure. + /** + * @brief Imports the given file into the given scene structure. * See BaseImporter::InternReadFile() for details */ void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler); - - // ------------------------------------------------------------------- - /** Loads a binary .stl file + /** + * @brief Loads a binary .stl file * @return true if the default vertex color must be used as material color - */ + */ bool LoadBinaryFile(); - // ------------------------------------------------------------------- - /** Loads a ASCII text .stl file - */ - void LoadASCIIFile(); + /** + * @brief Loads a ASCII text .stl file + */ + void LoadASCIIFile( aiNode *root ); + + void pushMeshesToNode( std::vector &meshIndices, aiNode *node ); protected: diff --git a/code/Subdivision.h b/code/Subdivision.h index b8ce228d2..d06bc09d6 100644 --- a/code/Subdivision.h +++ b/code/Subdivision.h @@ -40,10 +40,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file Defines a helper class to evaluate subdivision surfaces.*/ +#pragma once #ifndef AI_SUBDISIVION_H_INC #define AI_SUBDISIVION_H_INC #include +#include + struct aiMesh; namespace Assimp { @@ -52,8 +55,7 @@ namespace Assimp { /** Helper class to evaluate subdivision surfaces. Different algorithms * are provided for choice. */ // ------------------------------------------------------------------------------ -class Subdivider -{ +class ASSIMP_API Subdivider { public: /** Enumerates all supported subvidision algorithms */ @@ -61,12 +63,7 @@ public: CATMULL_CLARKE = 0x1 }; -public: - - virtual ~Subdivider() { - } - -public: + virtual ~Subdivider(); // --------------------------------------------------------------- /** Create a subdivider of a specific type @@ -119,9 +116,13 @@ public: unsigned int num, bool discard_input = false) = 0; -private: }; +inline +Subdivider::~Subdivider() { + // empty +} + } // end namespace Assimp diff --git a/code/TextureTransform.cpp b/code/TextureTransform.cpp index 76f0ce58c..30953113e 100644 --- a/code/TextureTransform.cpp +++ b/code/TextureTransform.cpp @@ -317,7 +317,7 @@ void TextureTransformStep::Execute( aiScene* pScene) info.lockedPos = AI_TT_UV_IDX_LOCK_TBD; } - // Get all coresponding meshes + // Get all corresponding meshes for (unsigned int n = 0; n < pScene->mNumMeshes;++n) { aiMesh* mesh = pScene->mMeshes[n]; if (mesh->mMaterialIndex != i || !mesh->mTextureCoords[0]) diff --git a/code/X3DExporter.cpp b/code/X3DExporter.cpp index 31a391c47..df688fd79 100644 --- a/code/X3DExporter.cpp +++ b/code/X3DExporter.cpp @@ -692,7 +692,7 @@ bool found = false; return true; } -X3DExporter::X3DExporter(const char* pFileName, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) +X3DExporter::X3DExporter(const char* pFileName, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) : mScene(pScene) { list attr_list; diff --git a/code/X3DExporter.hpp b/code/X3DExporter.hpp index bf1e72218..45f302d8d 100644 --- a/code/X3DExporter.hpp +++ b/code/X3DExporter.hpp @@ -27,7 +27,7 @@ namespace Assimp /// /// Pay attention that X3D is format for interactive graphic and simulations for web browsers. aiScene can not contain all features of the X3D format. /// Also, aiScene contain rasterized-like data. For example, X3D can describe circle all cylinder with one tag, but aiScene contain result of tesselation: -/// vertices, faces etc. Yes, you can use algorithm for detecting figures or shapes, but thats not good idea at all. +/// vertices, faces etc. Yes, you can use algorithm for detecting figures or shapes, but that's not a good idea at all. /// /// Supported nodes: /// Core component: @@ -96,7 +96,7 @@ private: aiMatrix4x4 Matrix_GlobalToCurrent(const aiNode& pNode) const; /// \fn void AttrHelper_CommaToPoint(std::string& pStringWithComma) - /// Convert commas in string to points. Thats need because "std::to_string" result depend on locale (regional settings). + /// Convert commas in string to points. That's needed because "std::to_string" result depends on locale (regional settings). /// \param [in, out] pStringWithComma - reference to string, which must be modified. void AttrHelper_CommaToPoint(std::string& pStringWithComma) { for(char& c: pStringWithComma) { if(c == ',') c = '.'; } } diff --git a/code/X3DImporter.hpp b/code/X3DImporter.hpp index 2d2d41fdb..468db5f3e 100644 --- a/code/X3DImporter.hpp +++ b/code/X3DImporter.hpp @@ -176,7 +176,7 @@ namespace Assimp { /// Ignored attributes: "creaseAngle", "convex", "solid". /// /// Texture coordinates generating: only for Sphere, Cone, Cylinder. In all other case used PLANE mapping. -/// It's better that Assimp main code has powerfull texture coordinates generator. Then is not needed to +/// It's better that Assimp main code has powerful texture coordinates generator. Then is not needed to /// duplicate this code in every importer. /// /// Lighting limitations. @@ -401,10 +401,10 @@ private: /************** Functions: XML set *************/ /***********************************************/ - /// Chek if current node is empty: . If not then exception will throwed. + /// Check if current node is empty: . If not then exception will throwed. void XML_CheckNode_MustBeEmpty(); - /// Chek if current node name is equal to pNodeName. + /// Check if current node name is equal to pNodeName. /// \param [in] pNodeName - name for checking. /// return true if current node name is equal to pNodeName, else - false. bool XML_CheckNode_NameEqual(const std::string& pNodeName) { return mReader->getNodeName() == pNodeName; } diff --git a/code/X3DImporter_Metadata.cpp b/code/X3DImporter_Metadata.cpp index 9d7147aea..0fa1b27b3 100644 --- a/code/X3DImporter_Metadata.cpp +++ b/code/X3DImporter_Metadata.cpp @@ -105,7 +105,7 @@ bool X3DImporter::ParseHelper_CheckRead_X3DMetadataObject() return true; } -void X3DImporter::ParseNode_Metadata(CX3DImporter_NodeElement* pParentElement, const std::string& pNodeName) +void X3DImporter::ParseNode_Metadata(CX3DImporter_NodeElement* pParentElement, const std::string& /*pNodeName*/) { ParseHelper_Node_Enter(pParentElement); MACRO_NODECHECK_METADATA(mReader->getNodeName()); diff --git a/code/glTF2Asset.h b/code/glTF2Asset.h index c9390d8d4..7ebc5ba95 100644 --- a/code/glTF2Asset.h +++ b/code/glTF2Asset.h @@ -403,7 +403,7 @@ namespace glTF2 virtual ~Object() {} //! Maps special IDs to another ID, where needed. Subclasses may override it (statically) - static const char* TranslateId(Asset& r, const char* id) + static const char* TranslateId(Asset& /*r*/, const char* id) { return id; } }; diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index c7d0cdc54..37a8fc662 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -332,7 +332,7 @@ inline Buffer::~Buffer() for(SEncodedRegion* reg : EncodedRegion_List) delete reg; } -inline const char* Buffer::TranslateId(Asset& r, const char* id) +inline const char* Buffer::TranslateId(Asset& /*r*/, const char* id) { return id; } @@ -667,7 +667,7 @@ inline Image::Image() } -inline void Image::Read(Value& obj, Asset& r) +inline void Image::Read(Value& obj, Asset& /*r*/) { if (!mDataLength) { if (Value* uri = FindString(obj, "uri")) { @@ -712,7 +712,7 @@ inline void Image::SetData(uint8_t* data, size_t length, Asset& r) } } -inline void Sampler::Read(Value& obj, Asset& r) +inline void Sampler::Read(Value& obj, Asset& /*r*/) { SetDefaults(); @@ -930,7 +930,7 @@ inline void Mesh::Read(Value& pJSON_Object, Asset& pAsset_Root) } } -inline void Camera::Read(Value& obj, Asset& r) +inline void Camera::Read(Value& obj, Asset& /*r*/) { type = MemberOrDefault(obj, "type", Camera::Perspective); @@ -1131,7 +1131,7 @@ inline void Asset::ReadExtensionsUsed(Document& doc) #undef CHECK_EXT } -inline IOStream* Asset::OpenFile(std::string path, const char* mode, bool absolute) +inline IOStream* Asset::OpenFile(std::string path, const char* mode, bool /*absolute*/) { #ifdef ASSIMP_API return mIOSystem->Open(path, mode); diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index df28cb681..8583462ce 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -72,7 +72,7 @@ namespace glTF2 { return val; } - inline Value& MakeValue(Value& val, float r, MemoryPoolAllocator<>& al) { + inline Value& MakeValue(Value& val, float r, MemoryPoolAllocator<>& /*al*/) { val.SetDouble(r); return val; @@ -171,7 +171,7 @@ namespace glTF2 { obj.AddMember("target", int(bv.target), w.mAl); } - inline void Write(Value& obj, Camera& c, AssetWriter& w) + inline void Write(Value& /*obj*/, Camera& /*c*/, AssetWriter& /*w*/) { } @@ -432,7 +432,7 @@ namespace glTF2 { } } - inline void Write(Value& obj, Program& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Program& /*b*/, AssetWriter& /*w*/) { } @@ -465,7 +465,7 @@ namespace glTF2 { AddRefsVector(scene, "nodes", s.nodes, w.mAl); } - inline void Write(Value& obj, Shader& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Shader& /*b*/, AssetWriter& /*w*/) { } diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index e71d949be..a7a640b5d 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -// Header files, standart library. +// Header files, standard library. #include #include @@ -80,7 +80,7 @@ namespace Assimp { } // end of namespace Assimp glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene, - const ExportProperties* pProperties, bool isBinary) + const ExportProperties* pProperties, bool /*isBinary*/) : mFilename(filename) , mIOSystem(pIOSystem) , mProperties(pProperties) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 292e0eeb2..5d40d75bc 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -159,21 +159,21 @@ static void CopyValue(const glTF2::mat4& v, aiMatrix4x4& o) o.a4 = v[12]; o.b4 = v[13]; o.c4 = v[14]; o.d4 = v[15]; } -inline void SetMaterialColorProperty(Asset& r, vec4& prop, aiMaterial* mat, const char* pKey, unsigned int type, unsigned int idx) +inline void SetMaterialColorProperty(Asset& /*r*/, vec4& prop, aiMaterial* mat, const char* pKey, unsigned int type, unsigned int idx) { aiColor4D col; CopyValue(prop, col); mat->AddProperty(&col, 1, pKey, type, idx); } -inline void SetMaterialColorProperty(Asset& r, vec3& prop, aiMaterial* mat, const char* pKey, unsigned int type, unsigned int idx) +inline void SetMaterialColorProperty(Asset& /*r*/, vec3& prop, aiMaterial* mat, const char* pKey, unsigned int type, unsigned int idx) { aiColor4D col; CopyValue(prop, col); mat->AddProperty(&col, 1, pKey, type, idx); } -inline void SetMaterialTextureProperty(std::vector& embeddedTexIdxs, Asset& r, glTF2::TextureInfo prop, aiMaterial* mat, aiTextureType texType, unsigned int texSlot = 0) +inline void SetMaterialTextureProperty(std::vector& embeddedTexIdxs, Asset& /*r*/, glTF2::TextureInfo prop, aiMaterial* mat, aiTextureType texType, unsigned int texSlot = 0) { if (prop.texture && prop.texture->source) { aiString uri(prop.texture->source->uri); @@ -296,6 +296,7 @@ static inline void SetFace(aiFace& face, int a, int b, int c) face.mIndices[2] = c; } +#ifdef ASSIMP_BUILD_DEBUG static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsigned nVerts) { for (unsigned i = 0; i < nFaces; ++i) { @@ -307,6 +308,7 @@ static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsign } return true; } +#endif // ASSIMP_BUILD_DEBUG void glTF2Importer::ImportMeshes(glTF2::Asset& r) { diff --git a/code/glTFAsset.h b/code/glTFAsset.h index e018e5ace..0c3de16a5 100644 --- a/code/glTFAsset.h +++ b/code/glTFAsset.h @@ -393,7 +393,7 @@ namespace glTF virtual ~Object() {} //! Maps special IDs to another ID, where needed. Subclasses may override it (statically) - static const char* TranslateId(Asset& r, const char* id) + static const char* TranslateId(Asset& /*r*/, const char* id) { return id; } }; diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index 61afebfb4..6d328614e 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -675,7 +675,7 @@ inline void Image::SetData(uint8_t* data, size_t length, Asset& r) } } -inline void Sampler::Read(Value& obj, Asset& r) +inline void Sampler::Read(Value& obj, Asset& /*r*/) { SetDefaults(); @@ -1093,7 +1093,7 @@ Ref buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer); } #endif -inline void Camera::Read(Value& obj, Asset& r) +inline void Camera::Read(Value& obj, Asset& /*r*/) { type = MemberOrDefault(obj, "type", Camera::Perspective); @@ -1116,7 +1116,7 @@ inline void Camera::Read(Value& obj, Asset& r) } } -inline void Light::Read(Value& obj, Asset& r) +inline void Light::Read(Value& obj, Asset& /*r*/) { SetDefaults(); @@ -1414,7 +1414,7 @@ inline void Asset::ReadExtensionsUsed(Document& doc) #undef CHECK_EXT } -inline IOStream* Asset::OpenFile(std::string path, const char* mode, bool absolute) +inline IOStream* Asset::OpenFile(std::string path, const char* mode, bool /*absolute*/) { #ifdef ASSIMP_API return mIOSystem->Open(path, mode); diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index 698f0ba8f..485abc4f6 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -187,7 +187,7 @@ namespace glTF { obj.AddMember("target", int(bv.target), w.mAl); } - inline void Write(Value& obj, Camera& c, AssetWriter& w) + inline void Write(Value& /*obj*/, Camera& /*c*/, AssetWriter& /*w*/) { } @@ -398,7 +398,7 @@ namespace glTF { } } - inline void Write(Value& obj, Program& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Program& /*b*/, AssetWriter& /*w*/) { } @@ -424,7 +424,7 @@ namespace glTF { AddRefsVector(scene, "nodes", s.nodes, w.mAl); } - inline void Write(Value& obj, Shader& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Shader& /*b*/, AssetWriter& /*w*/) { } @@ -452,7 +452,7 @@ namespace glTF { } - inline void Write(Value& obj, Technique& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Technique& /*b*/, AssetWriter& /*w*/) { } @@ -467,7 +467,7 @@ namespace glTF { } } - inline void Write(Value& obj, Light& b, AssetWriter& w) + inline void Write(Value& /*obj*/, Light& /*b*/, AssetWriter& /*w*/) { } diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 39886aaad..d88081884 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -// Header files, standart library. +// Header files, standard library. #include #include diff --git a/code/glTFImporter.cpp b/code/glTFImporter.cpp index a1d8e0cd0..5d1b5afab 100644 --- a/code/glTFImporter.cpp +++ b/code/glTFImporter.cpp @@ -154,7 +154,7 @@ static void CopyValue(const glTF::mat4& v, aiMatrix4x4& o) o.a4 = v[12]; o.b4 = v[13]; o.c4 = v[14]; o.d4 = v[15]; } -inline void SetMaterialColorProperty(std::vector& embeddedTexIdxs, Asset& r, glTF::TexProperty prop, aiMaterial* mat, +inline void SetMaterialColorProperty(std::vector& embeddedTexIdxs, Asset& /*r*/, glTF::TexProperty prop, aiMaterial* mat, aiTextureType texType, const char* pKey, unsigned int type, unsigned int idx) { if (prop.texture) { @@ -234,6 +234,7 @@ static inline void SetFace(aiFace& face, int a, int b, int c) face.mIndices[2] = c; } +#ifdef ASSIMP_BUILD_DEBUG static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsigned nVerts) { for (unsigned i = 0; i < nFaces; ++i) { @@ -245,6 +246,7 @@ static inline bool CheckValidFacesIndices(aiFace* faces, unsigned nFaces, unsign } return true; } +#endif // ASSIMP_BUILD_DEBUG void glTFImporter::ImportMeshes(glTF::Asset& r) { diff --git a/contrib/Open3DGC/o3dgcTriangleListEncoder.inl b/contrib/Open3DGC/o3dgcTriangleListEncoder.inl index d499f6dc9..017dd86bf 100644 --- a/contrib/Open3DGC/o3dgcTriangleListEncoder.inl +++ b/contrib/Open3DGC/o3dgcTriangleListEncoder.inl @@ -125,7 +125,7 @@ namespace o3dgc } return true; } - inline bool IsCase6(long degree, long numIndices, const long * const ops, const long * const indices) + inline bool IsCase6(long degree, long numIndices, const long * const ops, const long * const /*indices*/) { // ops: 0000000 indices: if (numIndices!= 0) diff --git a/contrib/openddlparser/code/DDLNode.cpp b/contrib/openddlparser/code/DDLNode.cpp index 6548cdf24..a7c557fc5 100644 --- a/contrib/openddlparser/code/DDLNode.cpp +++ b/contrib/openddlparser/code/DDLNode.cpp @@ -191,7 +191,7 @@ Reference *DDLNode::getReferences() const { return m_references; } -void DDLNode::dump(IOStreamBase &stream) { +void DDLNode::dump(IOStreamBase &/*stream*/) { // Todo! } diff --git a/contrib/openddlparser/code/Value.cpp b/contrib/openddlparser/code/Value.cpp index 3c8b06a10..b5a35e722 100644 --- a/contrib/openddlparser/code/Value.cpp +++ b/contrib/openddlparser/code/Value.cpp @@ -294,7 +294,7 @@ Reference *Value::getRef() const { return (Reference*) m_data; } -void Value::dump( IOStreamBase &stream ) { +void Value::dump( IOStreamBase &/*stream*/ ) { switch( m_type ) { case ddl_none: std::cout << "None" << std::endl; diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLParser.h b/contrib/openddlparser/include/openddlparser/OpenDDLParser.h index e9ac665b5..ef7f3a72e 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLParser.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLParser.h @@ -42,6 +42,10 @@ struct Property; template inline bool isEmbeddedCommentOpenTag( T *in, T *end ) { + if ( in == end ) { + return false; + } + if ( in == '/' && in+1 == '*' ) { return true; } diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index ebb6b72b8..8d51259a8 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -725,7 +725,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = irrXML.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1742,7 +1742,7 @@ UML_LOOK = NO # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 diff --git a/doc/dox.h b/doc/dox.h index 46ca23251..2672adcb5 100644 --- a/doc/dox.h +++ b/doc/dox.h @@ -60,7 +60,7 @@ that it has not been implemented yet and some (most ...) formats lack proper spe Stanford Ply ( *.ply )
TrueSpace ( *.cob, *.scn )2

-See the @link importer_notes Importer Notes Page @endlink for informations, what a specific importer can do and what not. +See the @link importer_notes Importer Notes Page @endlink for information, what a specific importer can do and what not. Note that although this paper claims to be the official documentation, http://assimp.sourceforge.net/main_features_formats.html
is usually the most up-to-date list of file formats supported by the library.
@@ -81,7 +81,7 @@ formats handle the required endian conversion correctly, so large parts of the l The assimp linker library and viewer application are provided under the BSD 3-clause license. This basically means that you are free to use it in open- or closed-source projects, for commercial or non-commercial purposes as you like -as long as you retain the license informations and take own responsibility for what you do with it. For details see +as long as you retain the license information and take own responsibility for what you do with it. For details see the LICENSE file. You can find test models for almost all formats in the /test/models directory. Beware, they're *free*, @@ -1420,7 +1420,7 @@ IFC file properties (IfcPropertySet) are kept as per-node metadata, see aiNode:: This section contains implementations notes for the OgreXML importer. @subsection overview Overview -Ogre importer is currently optimized for the Blender Ogre exporter, because thats the only one that I use. You can find the Blender Ogre exporter at: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=45922 +Ogre importer is currently optimized for the Blender Ogre exporter, because that's the only one that I use. You can find the Blender Ogre exporter at: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=45922 @subsection what What will be loaded? @@ -1434,7 +1434,7 @@ Skeleton: Skeleton with Bone hierarchy (Position and Rotation, but no Scaling in animations with rotation, translation and scaling keys. @subsection export_Blender How to export Files from Blender -You can find informations about how to use the Ogreexporter by your own, so here are just some options that you need, so the assimp +You can find information about how to use the Ogreexporter by your own, so here are just some options that you need, so the assimp importer will load everything correctly: - Use either "Rendering Material" or "Custom Material" see @ref material - do not use "Flip Up Axies to Y" @@ -1543,7 +1543,7 @@ Done! Please, share your loader that everyone can profit from it! @section properties Properties -You can use properties to chance the behavior of you importer. In order to do so, you have to overide BaseImporter::SetupProperties, and specify +You can use properties to chance the behavior of you importer. In order to do so, you have to override BaseImporter::SetupProperties, and specify you custom properties in config.h. Just have a look to the other AI_CONFIG_IMPORT_* defines and you will understand, how it works. The properties can be set with Importer::SetProperty***() and can be accessed in your SetupProperties function with Importer::GetProperty***(). You can diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 2c141ded2..c6a6f684a 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -171,7 +171,7 @@ public: * 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, const ExportProperties* pProperties = NULL); + const aiExportDataBlob* ExportToBlob(const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* = NULL); const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); // ------------------------------------------------------------------- diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in index 29b9d5870..bafd96189 100644 --- a/include/assimp/config.h.in +++ b/include/assimp/config.h.in @@ -903,7 +903,7 @@ enum aiComponent /** @brief Set the tessellation for IFC cylindrical shapes. * * This is used by the IFC importer to determine the tessellation parameter - * for cylindrical shapes, i.e. the number of segments used to aproximate a circle. + * for cylindrical shapes, i.e. the number of segments used to approximate a circle. * @note The default value is AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION and the * accepted values are in range [3, 180]. * Property type: Integer. diff --git a/port/PyAssimp/pyassimp/structs.py b/port/PyAssimp/pyassimp/structs.py index 84fcfb7a0..edae77d8d 100644 --- a/port/PyAssimp/pyassimp/structs.py +++ b/port/PyAssimp/pyassimp/structs.py @@ -206,7 +206,7 @@ class MeshKey(Structure): ("mTime", c_double), # Index into the aiMesh::mAnimMeshes array of the - # mesh coresponding to the + # mesh corresponding to the #aiMeshAnim hosting this # key frame. The referenced anim mesh is evaluated # according to the rules defined in the docs for diff --git a/port/PyAssimp/scripts/3d_viewer.py b/port/PyAssimp/scripts/3d_viewer.py index 9aae25efe..08a62660b 100755 --- a/port/PyAssimp/scripts/3d_viewer.py +++ b/port/PyAssimp/scripts/3d_viewer.py @@ -895,7 +895,7 @@ class PyAssimp3DViewer: aspect = camera.aspect u = 0.1 # unit size (in m) - l = 3 * u # lenght of the camera cone + l = 3 * u # length of the camera cone f = 3 * u # aperture of the camera cone glPushMatrix() diff --git a/port/PyAssimp/scripts/3d_viewer_py3.py b/port/PyAssimp/scripts/3d_viewer_py3.py index 4e4ecebe8..4c88edc7b 100755 --- a/port/PyAssimp/scripts/3d_viewer_py3.py +++ b/port/PyAssimp/scripts/3d_viewer_py3.py @@ -897,7 +897,7 @@ class PyAssimp3DViewer: aspect = camera.aspect u = 0.1 # unit size (in m) - l = 3 * u # lenght of the camera cone + l = 3 * u # length of the camera cone f = 3 * u # aperture of the camera cone glPushMatrix() diff --git a/port/PyAssimp/scripts/transformations.py b/port/PyAssimp/scripts/transformations.py index 6d6f19e5b..bf0cac9e3 100644 --- a/port/PyAssimp/scripts/transformations.py +++ b/port/PyAssimp/scripts/transformations.py @@ -583,7 +583,7 @@ def clip_matrix(left, right, bottom, top, near, far, perspective=False): orthographic canonical view volume (a box). Homogeneous coordinates transformed by the perspective clip matrix - need to be dehomogenized (devided by w coordinate). + need to be dehomogenized (divided by w coordinate). >>> frustrum = numpy.random.rand(6) >>> frustrum[1] += frustrum[0] diff --git a/port/dAssimp/assimp/mesh.d b/port/dAssimp/assimp/mesh.d index 9f20c9a66..da6193631 100644 --- a/port/dAssimp/assimp/mesh.d +++ b/port/dAssimp/assimp/mesh.d @@ -51,7 +51,7 @@ import assimp.types; extern ( C ) { /* * These limits are required to match the settings Assimp was compiled - * against. Therfore, do not redefine them unless you build the library + * against. Therefore, do not redefine them unless you build the library * from source using the same definitions. */ diff --git a/port/jassimp/jassimp-native/src/jassimp.cpp b/port/jassimp/jassimp-native/src/jassimp.cpp index c2a893896..070dbc95d 100644 --- a/port/jassimp/jassimp-native/src/jassimp.cpp +++ b/port/jassimp/jassimp-native/src/jassimp.cpp @@ -1951,7 +1951,7 @@ error: if (NULL == exception) { - /* thats really a problem because we cannot throw in this case */ + /* that's really a problem because we cannot throw in this case */ env->FatalError("could not throw java.io.IOException"); } gLastErrorString = imp.GetErrorString(); diff --git a/port/swig/assimp.i b/port/swig/assimp.i index d1a078d49..58e1546e7 100644 --- a/port/swig/assimp.i +++ b/port/swig/assimp.i @@ -114,7 +114,7 @@ %include "interface/IOSystem.i" -// We have to "instanciate" the templates used by the ASSSIMP_*_ARRAY macros +// We have to "instantiate" the templates used by the ASSSIMP_*_ARRAY macros // here at the end to avoid running into forward reference issues (SWIG would // spit out the helper functions before the header includes for the element // types otherwise). diff --git a/samples/SimpleAssimpViewX/MyDocument.mm b/samples/SimpleAssimpViewX/MyDocument.mm index be688a6be..cbe034842 100644 --- a/samples/SimpleAssimpViewX/MyDocument.mm +++ b/samples/SimpleAssimpViewX/MyDocument.mm @@ -641,7 +641,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink,const CVTimeS { for(MeshHelper* helper in modelMeshes) { - // Set up meterial state. + // Set up material state. glCallList(helper.displayList); } } diff --git a/samples/glut/GL/glut.h b/samples/glut/GL/glut.h index 0e6ddfbfe..86aa5c423 100644 --- a/samples/glut/GL/glut.h +++ b/samples/glut/GL/glut.h @@ -179,7 +179,7 @@ extern void exit(int); glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat, glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!). **/ -#ifndef GLUT_API_VERSION /* allow this to be overriden */ +#ifndef GLUT_API_VERSION /* allow this to be overridden */ #define GLUT_API_VERSION 3 #endif @@ -219,7 +219,7 @@ extern void exit(int); GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa **/ -#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */ +#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overridden. */ #define GLUT_XLIB_IMPLEMENTATION 15 #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62270b935..cc5d3f83c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -129,8 +129,10 @@ SET( TEST_SRCS unit/utVersion.cpp unit/utVector3.cpp unit/utXImporterExporter.cpp + unit/utX3DImportExport.cpp unit/utD3MFImportExport.cpp unit/utQ3DImportExport.cpp + unit/utSTLImportExport.cpp unit/utProfiler.cpp ) SET( POST_PROCESSES diff --git a/test/models-nonbsd/BLEND/fleurOptonl.source.txt b/test/models-nonbsd/BLEND/fleurOptonl.source.txt index 13f54a108..b9c58b5d9 100644 --- a/test/models-nonbsd/BLEND/fleurOptonl.source.txt +++ b/test/models-nonbsd/BLEND/fleurOptonl.source.txt @@ -32,7 +32,7 @@ L'utilizzo della Creative Commons non influisce su questo diritto. ************************************************ This model is released under Creative Commons Licence, Attribution 2.0 -for informations see: +for information see: http://creativecommons.org http://creativecommons.org/licenses/by/2.0/ feel free to use and improve it. diff --git a/test/models/AMF/README b/test/models/AMF/README index a64a8508e..7de7cadb2 100644 --- a/test/models/AMF/README +++ b/test/models/AMF/README @@ -1 +1 @@ -Simple models for testing importer. No desription because models are simple and created by hands. +Simple models for testing importer. No description because models are simple and created by hand. diff --git a/test/models/STL/triangle_with_two_solids.stl b/test/models/STL/triangle_with_two_solids.stl new file mode 100644 index 000000000..9af3841ae --- /dev/null +++ b/test/models/STL/triangle_with_two_solids.stl @@ -0,0 +1,18 @@ +solid testTriangle_1 + facet normal 0.0 0.0 1.0 + outer loop + vertex 1.0 1.0 0.0 + vertex -1.0 1.0 0.0 + vertex 0.0 -1.0 0.0 + endloop + endfacet +endsolid +solid testTriangle_2 + facet normal 0.0 0.0 1.0 + outer loop + vertex 3.0 3.0 0.0 + vertex 2.0 3.0 0.0 + vertex 0.0 2.0 0.0 + endloop + endfacet +endsolid diff --git a/test/unit/utObjImportExport.cpp b/test/unit/utObjImportExport.cpp index 3b08df80f..6361813d0 100644 --- a/test/unit/utObjImportExport.cpp +++ b/test/unit/utObjImportExport.cpp @@ -205,6 +205,7 @@ protected: const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 ); EXPECT_NE( nullptr, scene ); EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.obj" ) ); + EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_test.obj" ) ); return true; } @@ -305,3 +306,38 @@ TEST_F(utObjImportExport, relative_indices_Test) { } } + +TEST_F(utObjImportExport, homogeneous_coordinates_Test) { + static const std::string ObjModel = + "v -0.500000 0.000000 0.400000 0.50000\n" + "v -0.500000 0.000000 -0.800000 1.00000\n" + "v 0.500000 1.000000 -0.800000 0.5000\n" + "f 1 2 3\nB"; + + Assimp::Importer myimporter; + const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), aiProcess_ValidateDataStructure); + EXPECT_NE(nullptr, scene); + + EXPECT_EQ(scene->mNumMeshes, 1); + const aiMesh *mesh = scene->mMeshes[0]; + EXPECT_EQ(mesh->mNumVertices, 3); + EXPECT_EQ(mesh->mNumFaces, 1); + const aiFace face = mesh->mFaces[0]; + EXPECT_EQ(face.mNumIndices, 3); + const aiVector3D vertice = mesh->mVertices[0]; + EXPECT_EQ(vertice.x, -1.0f); + EXPECT_EQ(vertice.y, 0.0f); + EXPECT_EQ(vertice.z, 0.8f); +} + +TEST_F(utObjImportExport, 0based_array_Test) { + static const std::string ObjModel = + "v -0.500000 0.000000 0.400000\n" + "v -0.500000 0.000000 -0.800000\n" + "v -0.500000 1.000000 -0.800000\n" + "f 0 1 2\nB"; + + Assimp::Importer myimporter; + const aiScene *scene = myimporter.ReadFileFromMemory(ObjModel.c_str(), ObjModel.size(), 0); + EXPECT_EQ(nullptr, scene); +} diff --git a/test/unit/utSTLImportExport.cpp b/test/unit/utSTLImportExport.cpp new file mode 100644 index 000000000..0ee3de955 --- /dev/null +++ b/test/unit/utSTLImportExport.cpp @@ -0,0 +1,68 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2017, assimp team + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" +#include "SceneDiffer.h" +#include "AbstractImportExportBase.h" + +#include + +using namespace Assimp; + +class utSTLImporterExporter : public AbstractImportExportBase { +public: + virtual bool importerTest() { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", 0 ); + return nullptr != scene; + } +}; + +TEST_F( utSTLImporterExporter, importXFromFileTest ) { + EXPECT_TRUE( importerTest() ); +} + +TEST_F( utSTLImporterExporter, test_with_two_solids ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", 0 ); + EXPECT_NE( nullptr, scene ); +} diff --git a/test/unit/utX3DImportExport.cpp b/test/unit/utX3DImportExport.cpp new file mode 100644 index 000000000..a84c58efc --- /dev/null +++ b/test/unit/utX3DImportExport.cpp @@ -0,0 +1,62 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2017, assimp team + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" +#include "SceneDiffer.h" +#include "AbstractImportExportBase.h" + +#include + +using namespace Assimp; + +class utX3DImportExport : public AbstractImportExportBase { +public: + virtual bool importerTest() { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", 0 ); + return nullptr != scene; + } +}; + +TEST_F( utX3DImportExport, importX3DFromFileTest ) { + EXPECT_TRUE( importerTest() ); +} diff --git a/tools/assimp_qt_viewer/glview.cpp b/tools/assimp_qt_viewer/glview.cpp index 429f2ca99..5b755d456 100644 --- a/tools/assimp_qt_viewer/glview.cpp +++ b/tools/assimp_qt_viewer/glview.cpp @@ -561,7 +561,7 @@ void CGLView::Enable_Textures(const bool pEnable) } /********************************************************************/ -/*********************** Overrided functions ************************/ +/*********************** Override functions ************************/ /********************************************************************/ void CGLView::initializeGL() diff --git a/tools/assimp_qt_viewer/glview.hpp b/tools/assimp_qt_viewer/glview.hpp index 49207a7ed..ecd7c6b0f 100644 --- a/tools/assimp_qt_viewer/glview.hpp +++ b/tools/assimp_qt_viewer/glview.hpp @@ -249,13 +249,13 @@ private: void Draw_BBox(const SBBox& pBBox); /********************************************************************/ - /*********************** Overrided functions ************************/ + /*********************** Override functions ************************/ /********************************************************************/ protected: void drawCoordSystem(); /// \fn void initializeGL() override - /// Overrided function for initialise OpenGL. + /// Override function to initialise OpenGL. void initializeGL() override; /// \fn void resizeGL(int pWidth, int pHeight) override @@ -264,7 +264,7 @@ protected: void resizeGL(int pWidth, int pHeight) override; /// \fn void paintGL() override - /// Overrided function for rendering. + /// Override function for rendering. void paintGL() override; public: diff --git a/tools/assimp_qt_viewer/mainwindow.cpp b/tools/assimp_qt_viewer/mainwindow.cpp index 9b6e231bd..82ddc7092 100644 --- a/tools/assimp_qt_viewer/mainwindow.cpp +++ b/tools/assimp_qt_viewer/mainwindow.cpp @@ -107,7 +107,7 @@ void MainWindow::LogError(const QString& pMessage) } /********************************************************************/ -/*********************** Overrided functions ************************/ +/*********************** Override functions ************************/ /********************************************************************/ void MainWindow::mousePressEvent(QMouseEvent* pEvent) diff --git a/tools/assimp_qt_viewer/mainwindow.hpp b/tools/assimp_qt_viewer/mainwindow.hpp index 940840aee..b20acb884 100644 --- a/tools/assimp_qt_viewer/mainwindow.hpp +++ b/tools/assimp_qt_viewer/mainwindow.hpp @@ -65,23 +65,23 @@ private: void LogError(const QString& pMessage); /********************************************************************/ - /*********************** Overrided functions ************************/ + /*********************** Override functions ************************/ /********************************************************************/ protected: /// \fn void mousePressEvent(QMouseEvent* pEvent) override - /// Overrided function which handle mouse event "button pressed". + /// Override function which handles mouse event "button pressed". /// \param [in] pEvent - pointer to event data. void mousePressEvent(QMouseEvent* pEvent) override; /// \fn void mouseMoveEvent(QMouseEvent* pEvent) override - /// Overrided function which handle mouse event "move". + /// Override function which handles mouse event "move". /// \param [in] pEvent - pointer to event data. void mouseMoveEvent(QMouseEvent* pEvent) override; /// \fn void keyPressEvent(QKeyEvent* pEvent) override - /// Overrided function which handle key event "key pressed". + /// Override function which handles key event "key pressed". /// \param [in] pEvent - pointer to event data. void keyPressEvent(QKeyEvent* pEvent) override; diff --git a/tools/assimp_view/assimp_view.rc b/tools/assimp_view/assimp_view.rc index 13b05b18c..aebb1e2d9 100644 --- a/tools/assimp_view/assimp_view.rc +++ b/tools/assimp_view/assimp_view.rc @@ -189,7 +189,7 @@ BEGIN LTEXT "Angle limit (in degrees):",IDC_STATIC,13,10,76,8 LTEXT "The angle limit defines the maximum angle that may be between two adjacent face normals that they're smoothed together.",IDC_STATIC,13,31,253,19 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,113,278,1 - LTEXT "This setting is also used during import, but it can be overriden by single model importers to match the original look of a model as closely as possible. Examples include 3DS, ASE and LWO, all of them relying on smoothing groups and their own angle limits. ",IDC_STATIC,13,51,254,33 + LTEXT "This setting is also used during import, but it can be overridden by single model importers to match the original look of a model as closely as possible. Examples include 3DS, ASE and LWO, all of them relying on smoothing groups and their own angle limits. ",IDC_STATIC,13,51,254,33 LTEXT "NOTE: New settings don't take effect immediately, use 'Smooth Normals' or 'Reload' to update the model.",IDC_STATIC,14,118,254,22 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,90,277,1 END