From 85b20197671e142044e471df603debd0faf08baf Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Sun, 26 Jan 2014 02:05:24 -0700 Subject: [PATCH 1/5] Better feature detection for assimp version The unified headers were introduced in Assimp 2.0.1150, so checking for Assimp 3.0.0 is not quite the best solution. See https://github.com/assimp/assimp/commit/6fa251c2f2e7a142bb861227dce0c26362927fbc --- collada_urdf/CMakeLists.txt | 6 ++---- collada_urdf/src/collada_urdf.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/collada_urdf/CMakeLists.txt b/collada_urdf/CMakeLists.txt index 05217be..54a1e05 100644 --- a/collada_urdf/CMakeLists.txt +++ b/collada_urdf/CMakeLists.txt @@ -24,9 +24,8 @@ if ( NOT ASSIMP_FOUND ) endif() endif() if( ASSIMP_FOUND ) - if( ${ASSIMP_VERSION} STRGREATER "2.0.0" ) - set(IS_ASSIMP3 1) - add_definitions(-DIS_ASSIMP3) + if( ${ASSIMP_VERSION} STRGREATER "2.0.1150" ) + add_definitions(-DASSIMP_UNIFIED_HEADER_NAMES) endif() include_directories(${ASSIMP_INCLUDE_DIRS}) link_directories(${ASSIMP_LIBRARY_DIRS}) @@ -38,7 +37,6 @@ else() set(ASSIMP_CFLAGS_OTHER) set(ASSIMP_LINK_FLAGS) set(ASSIMP_INCLUDE_DIRS) - set(IS_ASSIMP3 0) # most likely not endif() find_package(COLLADA_DOM 2.3 COMPONENTS 1.5) diff --git a/collada_urdf/src/collada_urdf.cpp b/collada_urdf/src/collada_urdf.cpp index 7301049..aae003d 100644 --- a/collada_urdf/src/collada_urdf.cpp +++ b/collada_urdf/src/collada_urdf.cpp @@ -62,7 +62,7 @@ #include #include -#if defined(IS_ASSIMP3) +#if defined(ASSIMP_UNIFIED_HEADER_NAMES) #include #include #include From dbe46ddfc44f9448ce42cb0eea3d1a34d597e676 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Sun, 26 Jan 2014 02:29:46 -0700 Subject: [PATCH 2/5] Updated Assimp defines to be more flexible This commit is a follow-up to 85b20197671e142044e471df603debd0faf08baf Why was export.h removed from assimp < 3.0.0? --- collada_urdf/src/collada_to_urdf.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/collada_urdf/src/collada_to_urdf.cpp b/collada_urdf/src/collada_to_urdf.cpp index 02798c9..0a0d08f 100644 --- a/collada_urdf/src/collada_to_urdf.cpp +++ b/collada_urdf/src/collada_to_urdf.cpp @@ -5,8 +5,7 @@ #include #include -#if IS_ASSIMP3 -// assimp 3 (assimp_devel) +#if defined(ASSIMP_UNIFIED_HEADER_NAMES) #include #include #include @@ -14,9 +13,8 @@ #include #include #else -// assimp 2 #include -//#include +#include #include #include #endif @@ -69,7 +67,6 @@ os << "xyz: " << origin.position.x << " " << origin.position.y << " " << origin. void assimp_file_export(std::string fname, std::string ofname, std::string mesh_type = "collada") { -#if IS_ASSIMP3 if (fname.find("file://") == 0) { fname.erase(0, strlen("file://")); } @@ -103,7 +100,6 @@ void assimp_file_export(std::string fname, std::string ofname, std::string str( "assimp error" ); std::cerr << ";; " << str << std::endl; } -#endif } // assimp bounding box calculation @@ -597,9 +593,7 @@ int main(int argc, char** argv) cerr << ";; Adding gazebo description" << endl; } if (vm.count("use_assimp_export")) { -#if IS_ASSIMP3 use_assimp_export = true; -#endif cerr << ";; Use assimp export" << endl; } if (vm.count("original_inertia_rotation")) { From d0ecf85b531e4318c2c5db82905f96d876b4535b Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Sun, 26 Jan 2014 02:34:55 -0700 Subject: [PATCH 3/5] Invert Assimp version detect logic for greater accuracy --- collada_urdf/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collada_urdf/CMakeLists.txt b/collada_urdf/CMakeLists.txt index 54a1e05..ee25ed3 100644 --- a/collada_urdf/CMakeLists.txt +++ b/collada_urdf/CMakeLists.txt @@ -24,7 +24,7 @@ if ( NOT ASSIMP_FOUND ) endif() endif() if( ASSIMP_FOUND ) - if( ${ASSIMP_VERSION} STRGREATER "2.0.1150" ) + if( NOT ${ASSIMP_VERSION} STRLESS "2.0.1150" ) add_definitions(-DASSIMP_UNIFIED_HEADER_NAMES) endif() include_directories(${ASSIMP_INCLUDE_DIRS}) From 049aa4ef3eae92bf6f7a55e5423f3b6fa7b32cb7 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 5 Feb 2014 23:48:00 -0700 Subject: [PATCH 4/5] Fix export API detection (for assimp < 2.0.885) It looks like this API was added in Assimp 2.0.885: https://github.com/assimp/assimp/commit/ae23c03bd9a0b5f1227dc0042fd98f7206c770a8 --- collada_urdf/CMakeLists.txt | 3 +++ collada_urdf/src/collada_to_urdf.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/collada_urdf/CMakeLists.txt b/collada_urdf/CMakeLists.txt index ee25ed3..bca56e9 100644 --- a/collada_urdf/CMakeLists.txt +++ b/collada_urdf/CMakeLists.txt @@ -27,6 +27,9 @@ if( ASSIMP_FOUND ) if( NOT ${ASSIMP_VERSION} STRLESS "2.0.1150" ) add_definitions(-DASSIMP_UNIFIED_HEADER_NAMES) endif() + if( NOT ${ASSIMP_VERSION} STRLESS "2.0.885" ) + add_definitions(-DASSIMP_EXPORT_API) + endif() include_directories(${ASSIMP_INCLUDE_DIRS}) link_directories(${ASSIMP_LIBRARY_DIRS}) else() diff --git a/collada_urdf/src/collada_to_urdf.cpp b/collada_urdf/src/collada_to_urdf.cpp index 0a0d08f..3a4d6e6 100644 --- a/collada_urdf/src/collada_to_urdf.cpp +++ b/collada_urdf/src/collada_to_urdf.cpp @@ -14,7 +14,9 @@ #include #else #include +#if defined(ASSIMP_EXPORT_API) #include +#endif #include #include #endif @@ -67,6 +69,7 @@ os << "xyz: " << origin.position.x << " " << origin.position.y << " " << origin. void assimp_file_export(std::string fname, std::string ofname, std::string mesh_type = "collada") { +#if defined(ASSIMP_EXPORT_API) if (fname.find("file://") == 0) { fname.erase(0, strlen("file://")); } @@ -100,6 +103,7 @@ void assimp_file_export(std::string fname, std::string ofname, std::string str( "assimp error" ); std::cerr << ";; " << str << std::endl; } +#endif } // assimp bounding box calculation @@ -593,7 +597,9 @@ int main(int argc, char** argv) cerr << ";; Adding gazebo description" << endl; } if (vm.count("use_assimp_export")) { +#if defined(ASSIMP_EXPORT_API) use_assimp_export = true; +#endif cerr << ";; Use assimp export" << endl; } if (vm.count("original_inertia_rotation")) { From 767a1a2af53349c63e95c4bae3312ca712a0246c Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Thu, 6 Feb 2014 00:02:22 -0700 Subject: [PATCH 5/5] Use VERSION_LESS instead of STRLESS The version comparison routines were added in cmake 2.8.0 --- collada_urdf/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collada_urdf/CMakeLists.txt b/collada_urdf/CMakeLists.txt index bca56e9..fc93e4c 100644 --- a/collada_urdf/CMakeLists.txt +++ b/collada_urdf/CMakeLists.txt @@ -24,10 +24,10 @@ if ( NOT ASSIMP_FOUND ) endif() endif() if( ASSIMP_FOUND ) - if( NOT ${ASSIMP_VERSION} STRLESS "2.0.1150" ) + if( NOT ${ASSIMP_VERSION} VERSION_LESS "2.0.1150" ) add_definitions(-DASSIMP_UNIFIED_HEADER_NAMES) endif() - if( NOT ${ASSIMP_VERSION} STRLESS "2.0.885" ) + if( NOT ${ASSIMP_VERSION} VERSION_LESS "2.0.885" ) add_definitions(-DASSIMP_EXPORT_API) endif() include_directories(${ASSIMP_INCLUDE_DIRS})