From 27f37715824e0b0ac68b356dea259f57c831745f Mon Sep 17 00:00:00 2001 From: Ricardo Ortiz Date: Tue, 20 Jan 2015 13:23:15 -0500 Subject: [PATCH 01/15] Set ASSIMP_LIBRARIES to the proper library name in assimp-config.cmake so that other programs can find it. --- assimp-config.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assimp-config.cmake.in b/assimp-config.cmake.in index 1b68b4f18..d608a0fff 100644 --- a/assimp-config.cmake.in +++ b/assimp-config.cmake.in @@ -40,9 +40,9 @@ set( ASSIMP_LINK_FLAGS "" ) set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") set( ASSIMP_LIBRARIES assimp${ASSIMP_LIBRARY_SUFFIX}) -if (CMAKE_BUILD_TYPE EQUAL "DEBUG") - set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}D) -endif (CMAKE_BUILD_TYPE EQUAL "DEBUG") +if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}@ASSIMP_DEBUG_POSTFIX@) +endif () # search for the boost version assimp was compiled with #set(Boost_USE_MULTITHREAD ON) From a09de30d83336bc0fa66bf75b39a9df88f223eee Mon Sep 17 00:00:00 2001 From: Tom Mettam Date: Wed, 21 Jan 2015 01:45:35 +0000 Subject: [PATCH 02/15] Add support for component controlled matrix transforms, i.e transform(0)(0) etc. --- code/ColladaLoader.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index aa4826fc9..5771bc7af 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -985,6 +985,47 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars entry.mTransformId = srcChannel.mTarget.substr( slashPos+1); } + std::string::size_type bracketPos = srcChannel.mTarget.find('('); + if (bracketPos != std::string::npos) + { + entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1, bracketPos - slashPos - 1); + std::string subElement = srcChannel.mTarget.substr(bracketPos); + + if (subElement == "(0)(0)") + entry.mSubElement = 0; + else if (subElement == "(1)(0)") + entry.mSubElement = 1; + else if (subElement == "(2)(0)") + entry.mSubElement = 2; + else if (subElement == "(3)(0)") + entry.mSubElement = 3; + else if (subElement == "(0)(1)") + entry.mSubElement = 4; + else if (subElement == "(1)(1)") + entry.mSubElement = 5; + else if (subElement == "(2)(1)") + entry.mSubElement = 6; + else if (subElement == "(3)(1)") + entry.mSubElement = 7; + else if (subElement == "(0)(2)") + entry.mSubElement = 8; + else if (subElement == "(1)(2)") + entry.mSubElement = 9; + else if (subElement == "(2)(2)") + entry.mSubElement = 10; + else if (subElement == "(3)(2)") + entry.mSubElement = 11; + else if (subElement == "(0)(3)") + entry.mSubElement = 12; + else if (subElement == "(1)(3)") + entry.mSubElement = 13; + else if (subElement == "(2)(3)") + entry.mSubElement = 14; + else if (subElement == "(3)(3)") + entry.mSubElement = 15; + + } + // determine which transform step is affected by this channel entry.mTransformIndex = SIZE_MAX; for( size_t a = 0; a < srcNode->mTransforms.size(); ++a) From e8d44793444c6275e866aaa7a9c3e0e03a1351f8 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Thu, 22 Jan 2015 20:03:13 +0000 Subject: [PATCH 03/15] Squash incorrect abs usage Replace calls to abs with a float to calls to std::abs. Before int abs(int) was being called. --- code/IFCCurve.cpp | 8 ++++---- code/IFCGeometry.cpp | 6 +++--- code/IFCOpenings.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/IFCCurve.cpp b/code/IFCCurve.cpp index c25ee68eb..ffe52dfd2 100644 --- a/code/IFCCurve.cpp +++ b/code/IFCCurve.cpp @@ -91,7 +91,7 @@ public: a = std::fmod(a,static_cast( AI_MATH_TWO_PI )); b = std::fmod(b,static_cast( AI_MATH_TWO_PI )); const IfcFloat setting = static_cast( AI_MATH_PI * conv.settings.conicSamplingAngle / 180.0 ); - return static_cast( std::ceil(abs( b-a)) / setting); + return static_cast( std::ceil(std::abs( b-a)) / setting); } // -------------------------------------------------- @@ -276,7 +276,7 @@ public: IfcFloat acc = 0; BOOST_FOREACH(const CurveEntry& entry, curves) { const ParamRange& range = entry.first->GetParametricRange(); - const IfcFloat delta = abs(range.second-range.first); + const IfcFloat delta = std::abs(range.second-range.first); if (u < acc+delta) { return entry.first->Eval( entry.second ? (u-acc) + range.first : range.second-(u-acc)); } @@ -295,7 +295,7 @@ public: IfcFloat acc = 0; BOOST_FOREACH(const CurveEntry& entry, curves) { const ParamRange& range = entry.first->GetParametricRange(); - const IfcFloat delta = abs(range.second-range.first); + const IfcFloat delta = std::abs(range.second-range.first); if (a <= acc+delta && b >= acc) { const IfcFloat at = std::max(static_cast( 0. ),a-acc), bt = std::min(delta,b-acc); cnt += entry.first->EstimateSampleCount( entry.second ? at + range.first : range.second - bt, entry.second ? bt + range.first : range.second - at ); @@ -569,7 +569,7 @@ bool Curve :: InRange(IfcFloat u) const IfcFloat Curve :: GetParametricRangeDelta() const { const ParamRange& range = GetParametricRange(); - return abs(range.second - range.first); + return std::abs(range.second - range.first); } // ------------------------------------------------------------------------------------------------ diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index cb918a47e..e991f8e57 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -375,21 +375,21 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv bool take_any = false; for (unsigned int i = 0; i < 2; ++i, take_any = true) { - if ((last_dir == 0 || take_any) && abs(d.x) > 1e-6) { + if ((last_dir == 0 || take_any) && std::abs(d.x) > 1e-6) { q.y = startvec.y; q.z = startvec.z; q.x = -(d.y * q.y + d.z * q.z) / d.x; last_dir = 0; break; } - else if ((last_dir == 1 || take_any) && abs(d.y) > 1e-6) { + else if ((last_dir == 1 || take_any) && std::abs(d.y) > 1e-6) { q.x = startvec.x; q.z = startvec.z; q.y = -(d.x * q.x + d.z * q.z) / d.y; last_dir = 1; break; } - else if ((last_dir == 2 && abs(d.z) > 1e-6) || take_any) { + else if ((last_dir == 2 && std::abs(d.z) > 1e-6) || take_any) { q.y = startvec.y; q.x = startvec.x; q.z = -(d.y * q.y + d.x * q.x) / d.z; diff --git a/code/IFCOpenings.cpp b/code/IFCOpenings.cpp index 6b2f06d59..fb5d432fd 100644 --- a/code/IFCOpenings.cpp +++ b/code/IFCOpenings.cpp @@ -1244,7 +1244,7 @@ bool GenerateOpenings(std::vector& openings, const IfcVector3& face_nor = ((profile_verts[vi_total+2] - profile_verts[vi_total]) ^ (profile_verts[vi_total+1] - profile_verts[vi_total])).Normalize(); - const IfcFloat abs_dot_face_nor = abs(nor * face_nor); + const IfcFloat abs_dot_face_nor = std::abs(nor * face_nor); if (abs_dot_face_nor < 0.9) { vi_total += profile_vertcnts[f]; continue; From 7494cb6e4bf800b1cded52dc367a96e29e835042 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Thu, 22 Jan 2015 20:19:34 +0000 Subject: [PATCH 04/15] Use correct include file for INT_MAX INT_MAX is defined in limits.h, not stdint.h --- include/assimp/metadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 16809a511..4e1f6732d 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(_MSC_VER) && (_MSC_VER <= 1500) #include "Compiler/pstdint.h" #else -#include +#include #endif From 50dbb867ec56182ade7209f08b538ec662dc52d3 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Thu, 22 Jan 2015 21:27:43 +0000 Subject: [PATCH 05/15] Include stdint.h for uint64_t --- include/assimp/metadata.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 4e1f6732d..12670252e 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Compiler/pstdint.h" #else #include +#include #endif From e2a33e726d4c9c34c63b6a54bda1db8abd12da80 Mon Sep 17 00:00:00 2001 From: Ricardo Ortiz Date: Fri, 23 Jan 2015 10:10:51 -0500 Subject: [PATCH 06/15] Add quotes to build type variable. --- assimp-config.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assimp-config.cmake.in b/assimp-config.cmake.in index d608a0fff..acf6bd56d 100644 --- a/assimp-config.cmake.in +++ b/assimp-config.cmake.in @@ -40,7 +40,7 @@ set( ASSIMP_LINK_FLAGS "" ) set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") set( ASSIMP_LIBRARIES assimp${ASSIMP_LIBRARY_SUFFIX}) -if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}@ASSIMP_DEBUG_POSTFIX@) endif () From a94e668486fd65bb2b16178a45ee72d14c93acf2 Mon Sep 17 00:00:00 2001 From: Ricardo Ortiz Date: Fri, 23 Jan 2015 13:10:36 -0500 Subject: [PATCH 07/15] Define CMAKE_DEBUG_POSTFIX and use it instead of ASSIMP_DEBUG_PREFIX to have a consistent library name accross platforms. --- CMakeLists.txt | 12 ++++---- assimp-config.cmake.in | 4 +-- code/CMakeLists.txt | 34 ++++++++++++++------- samples/SimpleOpenGL/CMakeLists.txt | 10 +++--- samples/SimpleTexturedOpenGL/CMakeLists.txt | 8 ++--- test/CMakeLists.txt | 2 +- tools/assimp_cmd/CMakeLists.txt | 4 +-- tools/assimp_view/CMakeLists.txt | 4 +-- 8 files changed, 44 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8661f55..90cf503c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names") option(ASSIMP_ANDROID_JNIIOSYSTEM "Android JNI IOSystem support is active" OFF) # Workaround to be able to deal with compiler bug "Too many sections" with mingw. -if( CMAKE_COMPILER_IS_MINGW ) +if( CMAKE_COMPILER_IS_MINGW ) ADD_DEFINITIONS(-DASSIMP_BUILD_NO_IFC_IMPORTER ) endif() @@ -84,7 +84,7 @@ SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH "Path the tool executables are installed to." ) -SET(ASSIMP_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") +SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") # Allow the user to build a shared or static library option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON ) @@ -108,7 +108,7 @@ IF ( ASSIMP_ENABLE_BOOST_WORKAROUND ) MESSAGE( STATUS "Building a non-boost version of Assimp." ) ELSE ( ASSIMP_ENABLE_BOOST_WORKAROUND ) SET( Boost_DETAILED_FAILURE_MSG ON ) - SET( Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48.0" "1.48" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55" "1.55.0" "1.56" "1.56.0" "1.57" "1.57.0" ) + SET( Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48.0" "1.48" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52.0" "1.53.0" "1.54.0" "1.55" "1.55.0" "1.56" "1.56.0" "1.57" "1.57.0" ) FIND_PACKAGE( Boost ) IF ( NOT Boost_FOUND ) MESSAGE( FATAL_ERROR @@ -164,7 +164,7 @@ IF ( ASSIMP_NO_EXPORT ) MESSAGE( STATUS "Build an import-only version of Assimp." ) ENDIF( ASSIMP_NO_EXPORT ) -SET ( ASSIMP_BUILD_ARCHITECTURE "" CACHE STRING +SET ( ASSIMP_BUILD_ARCHITECTURE "" CACHE STRING "describe the current architecture." ) IF ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "") @@ -173,7 +173,7 @@ ELSE ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "") ENDIF ( ASSIMP_BUILD_ARCHITECTURE STREQUAL "") # ${CMAKE_GENERATOR} -SET ( ASSIMP_BUILD_COMPILER "" CACHE STRING +SET ( ASSIMP_BUILD_COMPILER "" CACHE STRING "describe the current compiler." ) IF ( ASSIMP_BUILD_COMPILER STREQUAL "") @@ -211,7 +211,7 @@ option ( ASSIMP_BUILD_TESTS "If the test suite for Assimp is built in addition to the library." ON ) - + IF ( ASSIMP_BUILD_TESTS ) ADD_SUBDIRECTORY( test/ ) ENDIF ( ASSIMP_BUILD_TESTS ) diff --git a/assimp-config.cmake.in b/assimp-config.cmake.in index acf6bd56d..4e5bb6dd7 100644 --- a/assimp-config.cmake.in +++ b/assimp-config.cmake.in @@ -40,9 +40,7 @@ set( ASSIMP_LINK_FLAGS "" ) set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") set( ASSIMP_LIBRARIES assimp${ASSIMP_LIBRARY_SUFFIX}) -if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}@ASSIMP_DEBUG_POSTFIX@) -endif () +set( ASSIMP_LIBRARIES ${ASSIMP_LIBRARIES}@CMAKE_DEBUG_POSTFIX@) # search for the boost version assimp was compiled with #set(Boost_USE_MULTITHREAD ON) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 4f651c7c5..87821f98e 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -205,7 +205,7 @@ SET( Collada_SRCS ColladaParser.cpp ColladaParser.h ColladaExporter.h - ColladaExporter.cpp + ColladaExporter.cpp ) SOURCE_GROUP( Collada FILES ${Collada_SRCS}) @@ -332,7 +332,7 @@ SET( Obj_SRCS ObjFileParser.cpp ObjFileParser.h ObjTools.h - + ObjExporter.h ObjExporter.cpp ) @@ -596,14 +596,14 @@ SET( ConvertUTF_SRCS ) SOURCE_GROUP( ConvertUTF FILES ${ConvertUTF_SRCS}) -SET( Clipper_SRCS +SET( Clipper_SRCS ../contrib/clipper/clipper.hpp ../contrib/clipper/clipper.cpp ) SOURCE_GROUP( Clipper FILES ${Clipper_SRCS}) -SET( Poly2Tri_SRCS +SET( Poly2Tri_SRCS ../contrib/poly2tri/poly2tri/common/shapes.cc ../contrib/poly2tri/poly2tri/common/shapes.h ../contrib/poly2tri/poly2tri/common/utils.h @@ -699,7 +699,7 @@ SET( assimp_src ${IFC_SRCS} ${XGL_SRCS} ${FBX_SRCS} - + # Third-party libraries ${IrrXML_SRCS} ${ConvertUTF_SRCS} @@ -711,7 +711,7 @@ SET( assimp_src ${PUBLIC_HEADERS} ${COMPILER_HEADERS} - + # Old precompiled header # (removed because the precompiled header is not updated when visual studio switch configuration which leads to failed compilation. # Moreover it's a drag to recompile assimp entirely each time a modification is made to one of the included header, which is definitely counter-productive.) @@ -722,8 +722,6 @@ SET( assimp_src ADD_LIBRARY( assimp ${assimp_src} ) -SET_PROPERTY(TARGET assimp PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) - TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES}) if(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) @@ -732,10 +730,24 @@ if(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) target_link_libraries(assimp android_jniiosystem) endif(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) +if( MSVC ) + # in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix + if( MSVC70 OR MSVC71 ) + set(MSVC_PREFIX "vc70") + elseif( MSVC80 ) + set(MSVC_PREFIX "vc80") + elseif( MSVC90 ) + set(MSVC_PREFIX "vc90") + else() + set(MSVC_PREFIX "vc100") + endif() + set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE) +endif() + SET_TARGET_PROPERTIES( assimp PROPERTIES VERSION ${ASSIMP_VERSION} - SOVERSION ${ASSIMP_SOVERSION} # use full version - OUTPUT_NAME assimp${ASSIMP_LIBRARY_SUFFIX} + SOVERSION ${ASSIMP_SOVERSION} # use full version + OUTPUT_NAME assimp${LIBRARY_SUFFIX} ) if (APPLE) @@ -765,7 +777,7 @@ if (ASSIMP_ANDROID_JNIIOSYSTEM) endif(ASSIMP_ANDROID_JNIIOSYSTEM) if(MSVC AND ASSIMP_INSTALL_PDB) - install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${ASSIMP_DEBUG_POSTFIX}.pdb + install(FILES ${Assimp_BINARY_DIR}/code/Debug/assimp${CMAKE_DEBUG_POSTFIX}.pdb DESTINATION ${ASSIMP_LIB_INSTALL_DIR} CONFIGURATIONS Debug ) diff --git a/samples/SimpleOpenGL/CMakeLists.txt b/samples/SimpleOpenGL/CMakeLists.txt index dea335ee1..cc83a7301 100644 --- a/samples/SimpleOpenGL/CMakeLists.txt +++ b/samples/SimpleOpenGL/CMakeLists.txt @@ -19,16 +19,16 @@ INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR} ) -LINK_DIRECTORIES( - ${Assimp_BINARY_DIR} - ${Assimp_BINARY_DIR}/lib +LINK_DIRECTORIES( + ${Assimp_BINARY_DIR} + ${Assimp_BINARY_DIR}/lib ) ADD_EXECUTABLE( assimp_simpleogl Sample_SimpleOpenGL.c ) -SET_PROPERTY(TARGET assimp_simpleogl PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) +SET_PROPERTY(TARGET assimp_simpleogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( assimp_simpleogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${M_LIB} ) SET_TARGET_PROPERTIES( assimp_simpleogl PROPERTIES @@ -37,4 +37,4 @@ SET_TARGET_PROPERTIES( assimp_simpleogl PROPERTIES INSTALL( TARGETS assimp_simpleogl DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev -) +) diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index cc1db1024..d26756bfb 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -19,8 +19,8 @@ INCLUDE_DIRECTORIES( ${Assimp_SOURCE_DIR}/samples/DevIL/include/ ) -LINK_DIRECTORIES( - ${Assimp_BINARY_DIR} +LINK_DIRECTORIES( + ${Assimp_BINARY_DIR} ${Assimp_BINARY_DIR}/lib/ ${Assimp_SOURCE_DIR}/samples/DevIL/lib/ ) @@ -30,7 +30,7 @@ ADD_EXECUTABLE( assimp_simpletexturedogl WIN32 SimpleTexturedOpenGL/src/model_loading.cpp ) -SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) +SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( assimp_simpletexturedogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} DevIL.lib ) @@ -40,4 +40,4 @@ SET_TARGET_PROPERTIES( assimp_simpletexturedogl PROPERTIES INSTALL( TARGETS assimp_simpletexturedogl DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev -) +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5eb1f1b90..3a8bbe82d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,7 +52,7 @@ add_executable( unit ${TEST_SRCS} ) -SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX} ) +SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} ) add_dependencies( unit gtest ) target_link_libraries( unit assimp diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index 374758db8..b549f9b10 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -19,7 +19,7 @@ ADD_EXECUTABLE( assimp_cmd Export.cpp ) -SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) +SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) IF( WIN32 ) ADD_CUSTOM_COMMAND(TARGET assimp_cmd @@ -35,4 +35,4 @@ SET_TARGET_PROPERTIES( assimp_cmd PROPERTIES INSTALL( TARGETS assimp_cmd DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-bin -) +) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index ddc18686a..e65060c9d 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -42,7 +42,7 @@ ADD_EXECUTABLE( assimp_viewer WIN32 txi.bmp ) -SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX}) +SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) IF ( MSVC ) @@ -52,7 +52,7 @@ ENDIF ( MSVC ) # -ADD_CUSTOM_COMMAND(TARGET assimp_viewer +ADD_CUSTOM_COMMAND(TARGET assimp_viewer PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ MAIN_DEPENDENCY assimp) From 380021e7c4e6a9c69d0a380b539def637338ad82 Mon Sep 17 00:00:00 2001 From: Johnny Dickinson Date: Sat, 24 Jan 2015 00:00:35 -0500 Subject: [PATCH 08/15] Check that zlib initialized correctly in FBX parser Check the return code of inflateInit() indicates success to avoid crashing later when zstream contains invalid data. --- code/FBXParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/FBXParser.cpp b/code/FBXParser.cpp index 7559a380d..bdeb40a09 100644 --- a/code/FBXParser.cpp +++ b/code/FBXParser.cpp @@ -549,7 +549,9 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha zstream.data_type = Z_BINARY; // http://hewgill.com/journal/entries/349-how-to-decompress-gzip-stream-with-zlib - inflateInit(&zstream); + if(Z_OK != inflateInit(&zstream)) { + ParseError("failure initializing zlib"); + } zstream.next_in = reinterpret_cast( const_cast(data) ); zstream.avail_in = comp_len; From b97c26b1d2abb53d00c0c251e4bd5e3f9a59f72c Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 25 Jan 2015 22:27:57 +0200 Subject: [PATCH 09/15] Avoid division by zero in assimp_cmd info when scene loading succeeds but contains no meshes --- tools/assimp_cmd/Info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index a34129f31..055193f6e 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -112,12 +112,12 @@ unsigned int CountAnimChannels(const aiScene* scene) // ----------------------------------------------------------------------------------- unsigned int GetAvgFacePerMesh(const aiScene* scene) { - return static_cast(CountFaces(scene)/scene->mNumMeshes); + return (scene->mNumMeshes != 0) ? static_cast(CountFaces(scene)/scene->mNumMeshes) : 0; } // ----------------------------------------------------------------------------------- unsigned int GetAvgVertsPerMesh(const aiScene* scene) { - return static_cast(CountVertices(scene)/scene->mNumMeshes); + return (scene->mNumMeshes != 0) ? static_cast(CountVertices(scene)/scene->mNumMeshes) : 0; } // ----------------------------------------------------------------------------------- From 1bdb31f8aa33f182b8713986abf466e2fb952dfc Mon Sep 17 00:00:00 2001 From: yeonseok-yi <0108981@gmail.com> Date: Mon, 26 Jan 2015 21:09:54 +0900 Subject: [PATCH 10/15] Fixed error of aiQuaterniont::Rotate() The function rotates a point to opposite direction. Conjugate() should be applied to inverse of the quaternion. --- include/assimp/quaternion.inl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/assimp/quaternion.inl b/include/assimp/quaternion.inl index cf1223910..181b6ffcc 100644 --- a/include/assimp/quaternion.inl +++ b/include/assimp/quaternion.inl @@ -273,11 +273,10 @@ template inline aiVector3t aiQuaterniont::Rotate (const aiVector3t& v) { aiQuaterniont q2(0.f,v.x,v.y,v.z), q = *this, qinv = q; - q.Conjugate(); + qinv.Conjugate(); q = q*q2*qinv; return aiVector3t(q.x,q.y,q.z); - } #endif From 1cf81227c4cd96456101212e012faf6147186d47 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Mon, 26 Jan 2015 15:35:38 +0000 Subject: [PATCH 11/15] Simplify behavior of SweepContext::InitEdges --- contrib/poly2tri/poly2tri/sweep/sweep_context.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index c9dd5a8c4..4fd1ac365 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -97,10 +97,10 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { int num_points = polyline.size(); - for (int i = 0; i < num_points; i++) { - int j = i < num_points - 1 ? i + 1 : 0; - edge_list.push_back(new Edge(*polyline[i], *polyline[j])); + for (int i = 0; i < num_points - 1; i++) { + edge_list.push_back(new Edge(*polyline[i], *polyline[i + 1])); } + edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); } Point* SweepContext::GetPoint(const int& index) From 00d561982cdaea71395a000e8de15f96d11fa89d Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Mon, 26 Jan 2015 15:38:12 +0000 Subject: [PATCH 12/15] Use size_t instead of int for number of points This squashes warnings under Visual Studio 12 --- contrib/poly2tri/poly2tri/sweep/sweep_context.cc | 4 ++-- contrib/poly2tri/poly2tri/sweep/sweep_context.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index 4fd1ac365..672303c53 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -96,8 +96,8 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { - int num_points = polyline.size(); - for (int i = 0; i < num_points - 1; i++) { + std::size_t num_points = polyline.size(); + for (std::size_t i = 0; i < num_points - 1; i++) { edge_list.push_back(new Edge(*polyline[i], *polyline[i + 1])); } edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.h b/contrib/poly2tri/poly2tri/sweep/sweep_context.h index 266408dc2..4b098e860 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.h +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.h @@ -64,7 +64,7 @@ void set_tail(Point* p1); Point* tail(); -int point_count(); +std::size_t point_count(); Node& LocateNode(Point& point); @@ -156,7 +156,7 @@ inline AdvancingFront* SweepContext::front() return front_; } -inline int SweepContext::point_count() +inline std::size_t SweepContext::point_count() { return points_.size(); } From 8b55d276e9c636d54d2e54e938e2aff11eb2942d Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Mon, 26 Jan 2015 19:54:02 +0100 Subject: [PATCH 13/15] Revert "Fix warnings under Visual Studio 12" --- contrib/poly2tri/poly2tri/sweep/sweep_context.cc | 8 ++++---- contrib/poly2tri/poly2tri/sweep/sweep_context.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc index 672303c53..c9dd5a8c4 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.cc @@ -96,11 +96,11 @@ void SweepContext::InitTriangulation() void SweepContext::InitEdges(std::vector polyline) { - std::size_t num_points = polyline.size(); - for (std::size_t i = 0; i < num_points - 1; i++) { - edge_list.push_back(new Edge(*polyline[i], *polyline[i + 1])); + int num_points = polyline.size(); + for (int i = 0; i < num_points; i++) { + int j = i < num_points - 1 ? i + 1 : 0; + edge_list.push_back(new Edge(*polyline[i], *polyline[j])); } - edge_list.push_back(new Edge(*polyline.back(), *polyline.front())); } Point* SweepContext::GetPoint(const int& index) diff --git a/contrib/poly2tri/poly2tri/sweep/sweep_context.h b/contrib/poly2tri/poly2tri/sweep/sweep_context.h index 4b098e860..266408dc2 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep_context.h +++ b/contrib/poly2tri/poly2tri/sweep/sweep_context.h @@ -64,7 +64,7 @@ void set_tail(Point* p1); Point* tail(); -std::size_t point_count(); +int point_count(); Node& LocateNode(Point& point); @@ -156,7 +156,7 @@ inline AdvancingFront* SweepContext::front() return front_; } -inline std::size_t SweepContext::point_count() +inline int SweepContext::point_count() { return points_.size(); } From 704e57db4ee640262b8b20f4b687c15231d64354 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Tue, 27 Jan 2015 22:47:05 -0500 Subject: [PATCH 14/15] changed default postprocessing option to triangulate quad meshes --- port/PyAssimp/pyassimp/core.py | 61 ++++++++++++------------------- port/PyAssimp/pyassimp/structs.py | 10 +++++ 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index b5b0441ce..29550eb35 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -1,5 +1,3 @@ -#-*- coding: UTF-8 -*- - """ PyAssimp @@ -21,37 +19,31 @@ logger = logging.getLogger("pyassimp") logger.addHandler(logging.NullHandler()) from . import structs -from .errors import AssimpError from . import helper +from . import postprocess +from .errors import AssimpError +from .formats import available_formats -assimp_structs_as_tuple = ( - structs.Matrix4x4, - structs.Matrix3x3, - structs.Vector2D, - structs.Vector3D, - structs.Color3D, - structs.Color4D, - structs.Quaternion, - structs.Plane, - structs.Texel) +class AssimpLib(object): + """ + Assimp-Singleton + """ + load, load_mem, release, dll = helper.search_library() +_assimp_lib = AssimpLib() def make_tuple(ai_obj, type = None): res = None - if isinstance(ai_obj, structs.Matrix4x4): res = numpy.array([getattr(ai_obj, e[0]) for e in ai_obj._fields_]).reshape((4,4)) - #import pdb;pdb.set_trace() elif isinstance(ai_obj, structs.Matrix3x3): res = numpy.array([getattr(ai_obj, e[0]) for e in ai_obj._fields_]).reshape((3,3)) else: res = numpy.array([getattr(ai_obj, e[0]) for e in ai_obj._fields_]) - return res # It is faster and more correct to have an init function for each assimp class def _init_face(aiFace): aiFace.indices = [aiFace.mIndices[i] for i in range(aiFace.mNumIndices)] - assimp_struct_inits = { structs.Face : _init_face } def call_init(obj, caller = None): @@ -112,7 +104,7 @@ def _init(self, target = None, parent = None): obj = getattr(self, m) # Create tuples - if isinstance(obj, assimp_structs_as_tuple): + if isinstance(obj, structs.assimp_structs_as_tuple): setattr(target, name, make_tuple(obj)) logger.debug(str(self) + ": Added array " + str(getattr(target, name)) + " as self." + name.lower()) continue @@ -142,7 +134,7 @@ def _init(self, target = None, parent = None): try: - if obj._type_ in assimp_structs_as_tuple: + if obj._type_ in structs.assimp_structs_as_tuple: setattr(target, name, numpy.array([make_tuple(obj[i]) for i in range(length)], dtype=numpy.float32)) logger.debug(str(self) + ": Added an array of numpy arrays (type "+ str(type(obj)) + ") as self." + name) @@ -178,19 +170,16 @@ def _init(self, target = None, parent = None): " a post-processing to triangulate your" " faces.") raise e + else: # starts with 'm' but not iterable - setattr(target, name, obj) logger.debug("Added " + name + " as self." + name + " (type: " + str(type(obj)) + ")") if _is_init_type(obj): call_init(obj, target) - - - if isinstance(self, structs.Mesh): _finalize_mesh(self, target) @@ -200,14 +189,6 @@ def _init(self, target = None, parent = None): return self -class AssimpLib(object): - """ - Assimp-Singleton - """ - load, load_mem, release, dll = helper.search_library() - -#the loader as singleton -_assimp_lib = AssimpLib() def pythonize_assimp(type, obj, scene): """ This method modify the Assimp data structures @@ -247,17 +228,16 @@ def recur_pythonize(node, scene): pythonize the assimp datastructures. ''' node.meshes = pythonize_assimp("MESH", node.meshes, scene) - for mesh in node.meshes: mesh.material = scene.materials[mesh.materialindex] - for cam in scene.cameras: pythonize_assimp("ADDTRANSFORMATION", cam, scene) - for c in node.children: recur_pythonize(c, scene) -def load(filename, processing=0, file_type=None): +def load(filename, + file_type = None, + processing = postprocess.aiProcess_Triangulate): ''' Load a model into a scene. On failure throws AssimpError. @@ -267,12 +247,17 @@ def load(filename, processing=0, file_type=None): If a file object is passed, file_type MUST be specified Otherwise Assimp has no idea which importer to use. This is named 'filename' so as to not break legacy code. - processing: assimp processing parameters - file_type: string, such as 'stl' + processing: assimp postprocessing parameters. Verbose keywords are imported + from postprocessing, and the parameters can be combined bitwise to + generate the final processing value. Note that the default value will + triangulate quad faces. Example of generating other possible values: + processing = (pyassimp.postprocess.aiProcess_Triangulate | + pyassimp.postprocess.aiProcess_OptimizeMeshes) + file_type: string of file extension, such as 'stl' Returns --------- - Scene object with model-data + Scene object with model data ''' if hasattr(filename, 'read'): diff --git a/port/PyAssimp/pyassimp/structs.py b/port/PyAssimp/pyassimp/structs.py index 9d8f5a5a1..39ed8267a 100644 --- a/port/PyAssimp/pyassimp/structs.py +++ b/port/PyAssimp/pyassimp/structs.py @@ -897,3 +897,13 @@ class Scene(Structure): # the scene. ("mCameras", POINTER(POINTER(Camera))), ] + +assimp_structs_as_tuple = (Matrix4x4, + Matrix3x3, + Vector2D, + Vector3D, + Color3D, + Color4D, + Quaternion, + Plane, + Texel) From 25012f7b8afb5f1f441958bd3f19b86528b94323 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Tue, 27 Jan 2015 22:53:31 -0500 Subject: [PATCH 15/15] added list of supported formats, pulled from webpage and test/models --- port/PyAssimp/pyassimp/formats.py | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 port/PyAssimp/pyassimp/formats.py diff --git a/port/PyAssimp/pyassimp/formats.py b/port/PyAssimp/pyassimp/formats.py new file mode 100644 index 000000000..baba1645c --- /dev/null +++ b/port/PyAssimp/pyassimp/formats.py @@ -0,0 +1,41 @@ +FORMATS = ["CSM", + "LWS", + "B3D", + "COB", + "PLY", + "IFC", + "OFF", + "SMD", + "IRRMESH", + "3D", + "DAE", + "MDL", + "HMP", + "TER", + "WRL", + "XML", + "NFF", + "AC", + "OBJ", + "3DS", + "STL", + "IRR", + "Q3O", + "Q3D" + "MS3D", + "Q3S", + "ZGL", + "MD2", + "X", + "BLEND", + "XGL", + "MD5MESH", + "MAX", + "LXO", + "DXF", + "BVH", + "LWO", + "NDO"] + +def available_formats(): + return FORMATS