diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf5a09..5cb1fbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,11 @@ find_package(Threads REQUIRED) list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_BINARY_DIR}") # stuff we get from Conan -find_package(boost_filesystem MODULE REQUIRED) -find_package(boost_optional MODULE REQUIRED) -find_package(libxml2 MODULE REQUIRED) -find_package(zlib MODULE REQUIRED) +find_package(Boost REQUIRED COMPONENTS filesystem) +find_package(LibXml2 MODULE REQUIRED) +find_package(ZLIB MODULE REQUIRED) find_package(fmt MODULE REQUIRED) +find_package(libiconv MODULE REQUIRED) # create a compilation database for e.g. clang-tidy set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -201,25 +201,21 @@ endif() target_link_libraries(libFBX2glTF ${FRAMEWORKS} - boost_filesystem::boost_filesystem - boost_optional::boost_optional + Boost::filesystem ${DRACO_LIB} optimized ${FBXSDK_LIBRARY} debug ${FBXSDK_LIBRARY_DEBUG} fmt::fmt - libxml2::libxml2 - zlib::zlib + ${LIBXML2_LIBRARIES} + ${ZLIB_LIBRARIES} + ${ICONV_LIBRARIES} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ) -if (APPLE) - find_package(Iconv MODULE REQUIRED) - target_link_libraries(libFBX2glTF Iconv) -else() - find_package(libiconv MODULE REQUIRED) - target_link_libraries(libFBX2glTF libiconv::libiconv) -endif() + #find_package(libiconv MODULE REQUIRED) + #target_link_libraries(libFBX2glTF libiconv) + target_include_directories(libFBX2glTF PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src @@ -244,3 +240,4 @@ install (TARGETS libFBX2glTF appFBX2glTF RUNTIME DESTINATION bin ARCHIVE DESTINATION lib ) + diff --git a/conanfile.py b/conanfile.py index be675d0..956b402 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,17 +9,17 @@ from conans import ConanFile, CMake class FBX2glTFConan(ConanFile): settings = "os", "compiler", "build_type", "arch" requires = ( - ("boost_filesystem/1.69.0@bincrafters/stable"), - ("libiconv/1.15@bincrafters/stable"), - ("zlib/1.2.11@conan/stable"), - ("libxml2/2.9.9@bincrafters/stable"), - ("fmt/5.3.0@bincrafters/stable"), + ("boost/1.81.0"), + ("libiconv/1.15"), + ("zlib/1.2.13"), + ("libxml2/2.9.9"), + ("fmt/5.3.0"), ) generators = "cmake_find_package", "cmake_paths" - + def configure(self): if ( - self.settings.compiler == "gcc" + self.settings.get_safe("compiler") == "gcc" and self.settings.compiler.libcxx == "libstdc++" ): raise Exception( @@ -31,3 +31,4 @@ class FBX2glTFConan(ConanFile): cmake.definitions["FBXSDK_SDKS"] = os.getenv("FBXSDK_SDKS", "sdk") cmake.configure() cmake.build() + diff --git a/src/FBX2glTF.cpp b/src/FBX2glTF.cpp index 7c8948d..50ee004 100644 --- a/src/FBX2glTF.cpp +++ b/src/FBX2glTF.cpp @@ -21,6 +21,7 @@ #include "utils/String_Utils.hpp" bool verboseOutput = false; +bool optAnimation = false; int main(int argc, char* argv[]) { GltfOptions gltfOptions; @@ -34,6 +35,7 @@ int main(int argc, char* argv[]) { "-v,--verbose", verboseOutput, "Include blend shape tangents, if reported present by the FBX SDK."); + app.add_flag("--optAni", optAnimation, "Delete the curve that hasn't changed"); app.add_flag_function("-V,--version", [&](size_t count) { fmt::printf("FBX2glTF version %s\nCopyright (c) 2016-2018 Oculus VR, LLC.\n", FBX2GLTF_VERSION); @@ -47,6 +49,7 @@ int main(int argc, char* argv[]) { std::string outputPath; app.add_option("-o,--output", outputPath, "Where to generate the output, without suffix."); + app.add_flag( "-e,--embed", gltfOptions.embedResources, diff --git a/src/FBX2glTF.h b/src/FBX2glTF.h index 56c7c2c..56a6074 100644 --- a/src/FBX2glTF.h +++ b/src/FBX2glTF.h @@ -41,6 +41,8 @@ using workaround_fifo_map = nlohmann::fifo_map; extern bool verboseOutput; +extern bool optAnimation; + /** * Centralises all the laborious downcasting from your OS' 64-bit diff --git a/src/fbx/Fbx2Raw.cpp b/src/fbx/Fbx2Raw.cpp index 351bd85..9c363ae 100644 --- a/src/fbx/Fbx2Raw.cpp +++ b/src/fbx/Fbx2Raw.cpp @@ -753,7 +753,7 @@ static void ReadAnimations(RawModel& raw, FbxScene* pScene, const GltfOptions& o eMode = FbxTime::eFrames60; break; } - const double epsilon = 1e-5f; + const double epsilon = 1e-5f; const int animationCount = pScene->GetSrcObjectCount(); for (size_t animIx = 0; animIx < animationCount; animIx++) { @@ -847,20 +847,26 @@ static void ReadAnimations(RawModel& raw, FbxScene* pScene, const GltfOptions& o const FbxQuaternion localRotation = localTransform.GetQ(); const FbxVector4 localScale = computeLocalScale(pNode, pTime); - hasTranslation |= - (fabs(localTranslation[0] - baseTranslation[0]) > epsilon || - fabs(localTranslation[1] - baseTranslation[1]) > epsilon || - fabs(localTranslation[2] - baseTranslation[2]) > epsilon); - hasRotation |= - (fabs(localRotation[0] - baseRotation[0]) > epsilon || - fabs(localRotation[1] - baseRotation[1]) > epsilon || - fabs(localRotation[2] - baseRotation[2]) > epsilon || - fabs(localRotation[3] - baseRotation[3]) > epsilon); - hasScale |= - (fabs(localScale[0] - baseScaling[0]) > epsilon || - fabs(localScale[1] - baseScaling[1]) > epsilon || - fabs(localScale[2] - baseScaling[2]) > epsilon); + if (!optAnimation) { + hasTranslation = true; + hasRotation = true; + hasScale = true; + } else { + hasTranslation |= + (fabs(localTranslation[0] - baseTranslation[0]) > epsilon || + fabs(localTranslation[1] - baseTranslation[1]) > epsilon || + fabs(localTranslation[2] - baseTranslation[2]) > epsilon); + hasRotation |= + (fabs(localRotation[0] - baseRotation[0]) > epsilon || + fabs(localRotation[1] - baseRotation[1]) > epsilon || + fabs(localRotation[2] - baseRotation[2]) > epsilon || + fabs(localRotation[3] - baseRotation[3]) > epsilon); + hasScale |= + (fabs(localScale[0] - baseScaling[0]) > epsilon || + fabs(localScale[1] - baseScaling[1]) > epsilon || + fabs(localScale[2] - baseScaling[2]) > epsilon); + } channel.translations.push_back(toVec3f(localTranslation) * scaleFactor); channel.rotations.push_back(toQuatf(localRotation)); channel.scales.push_back(toVec3f(localScale)); @@ -1148,9 +1154,11 @@ bool LoadFBXFile( } // this is always 0.01, but let's opt for clarity. scaleFactor = FbxSystemUnit::m.GetConversionFactorFrom(FbxSystemUnit::cm); - - ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, ""); - ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations); +FbxNode* rootNode = pScene->GetRootNode(); + ReadNodeHierarchy(raw, pScene, rootNode->GetChild(0), 0, ""); + ReadNodeAttributes(raw, pScene, rootNode->GetChild(0), textureLocations); + // ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, ""); + // ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations); ReadAnimations(raw, pScene, options); pScene->Destroy();