Merge 3d6856b3f8
into 739ee5db94
This commit is contained in:
commit
968c8e5659
112
CMakeLists.txt
112
CMakeLists.txt
|
@ -1,29 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(FBX2glTF)
|
||||
|
||||
set(typical_usage_str
|
||||
"Example usage:\n\
|
||||
> mkdir -p build_debug\n\
|
||||
> conan install . -i build_debug -s build_type=Debug -e FBXSDK_SDKS=/home/zell/FBXSDK\n\
|
||||
> conan build . -bf build_debug")
|
||||
|
||||
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
message(FATAL_ERROR
|
||||
"Building from within the source tree is not supported! ${typical_usage_str}")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include(ExternalProject)
|
||||
|
||||
# FBX
|
||||
foreach (FBXSDK_VERSION "2019.2")
|
||||
foreach (FBXSDK_VERSION "2020.3.7")
|
||||
find_package(FBX)
|
||||
if (FBXSDK_FOUND)
|
||||
break()
|
||||
endif()
|
||||
endforeach(FBXSDK_VERSION)
|
||||
endif ()
|
||||
endforeach (FBXSDK_VERSION)
|
||||
if (NOT FBXSDK_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"Can't find FBX SDK in either:\n"
|
||||
|
@ -31,46 +20,24 @@ if (NOT FBXSDK_FOUND)
|
|||
" - Windows: ${FBXSDK_WINDOWS_ROOT}\n"
|
||||
" - Linux: ${FBXSDK_LINUX_ROOT}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan_paths.cmake")
|
||||
message(FATAL_ERROR
|
||||
"The Conan package manager must run ('install') first. ${typical_usage_str}")
|
||||
endif()
|
||||
include("${CMAKE_BINARY_DIR}/conan_paths.cmake")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_BINARY_DIR}")
|
||||
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
||||
|
||||
# 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(fmt MODULE REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem optional)
|
||||
find_package(nlohmann-fifo-map CONFIG REQUIRED)
|
||||
find_package(LibXml2 REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(draco CONFIG REQUIRED)
|
||||
|
||||
# create a compilation database for e.g. clang-tidy
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# DRACO
|
||||
ExternalProject_Add(Draco
|
||||
GIT_REPOSITORY https://github.com/google/draco
|
||||
GIT_TAG 1.3.4
|
||||
PREFIX draco
|
||||
INSTALL_DIR
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DBUILD_FOR_GLTF=1
|
||||
)
|
||||
set(DRACO_INCLUDE_DIR "${CMAKE_BINARY_DIR}/draco/include")
|
||||
if (WIN32)
|
||||
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/dracoenc.lib")
|
||||
else()
|
||||
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/libdracoenc.a")
|
||||
endif()
|
||||
|
||||
# MATHFU
|
||||
set(mathfu_build_benchmarks OFF CACHE BOOL "")
|
||||
set(mathfu_build_tests OFF CACHE BOOL "")
|
||||
|
@ -86,32 +53,11 @@ set(MATHFU_INCLUDE_DIRS
|
|||
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/include/"
|
||||
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/dependencies/vectorial/include")
|
||||
|
||||
# OrderedMap
|
||||
ExternalProject_Add(FiFoMap
|
||||
PREFIX fifo_map
|
||||
GIT_REPOSITORY https://github.com/nlohmann/fifo_map
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap configure step."
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap build step."
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap install step."
|
||||
)
|
||||
set(FIFO_MAP_INCLUDE_DIR "${CMAKE_BINARY_DIR}/fifo_map/src/FiFoMap/src")
|
||||
|
||||
|
||||
# cppcodec
|
||||
ExternalProject_Add(CPPCodec
|
||||
PREFIX cppcodec
|
||||
GIT_REPOSITORY https://github.com/tplgy/cppcodec
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec configure step."
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec build step."
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec install step."
|
||||
)
|
||||
set(CPPCODEC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cppcodec/src/CPPCodec")
|
||||
|
||||
if (APPLE)
|
||||
find_library(CF_FRAMEWORK CoreFoundation)
|
||||
message("CoreFoundation Framework: ${CF_FRAMEWORK}")
|
||||
set(FRAMEWORKS ${CF_FRAMEWORK})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
set(LIB_SOURCE_FILES
|
||||
src/FBX2glTF.h
|
||||
|
@ -181,10 +127,7 @@ add_executable(appFBX2glTF src/FBX2glTF.cpp)
|
|||
set_target_properties(appFBX2glTF PROPERTIES OUTPUT_NAME "FBX2glTF")
|
||||
|
||||
add_dependencies(libFBX2glTF
|
||||
Draco
|
||||
MathFu
|
||||
FiFoMap
|
||||
CPPCodec
|
||||
)
|
||||
|
||||
if (NOT MSVC)
|
||||
|
@ -197,18 +140,19 @@ if (NOT MSVC)
|
|||
"-Wno-null-dereference"
|
||||
"-Wunused"
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
target_link_libraries(libFBX2glTF
|
||||
${FRAMEWORKS}
|
||||
boost_filesystem::boost_filesystem
|
||||
boost_optional::boost_optional
|
||||
${DRACO_LIB}
|
||||
Boost::filesystem
|
||||
Boost::optional
|
||||
draco::draco
|
||||
optimized ${FBXSDK_LIBRARY}
|
||||
debug ${FBXSDK_LIBRARY_DEBUG}
|
||||
fmt::fmt
|
||||
libxml2::libxml2
|
||||
zlib::zlib
|
||||
fmt::fmt-header-only
|
||||
LibXml2::LibXml2
|
||||
ZLIB::ZLIB
|
||||
nlohmann-fifo-map::nlohmann-fifo-map
|
||||
${CMAKE_DL_LIBS}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
||||
|
@ -216,23 +160,23 @@ target_link_libraries(libFBX2glTF
|
|||
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()
|
||||
else ()
|
||||
find_package(unofficial-iconv CONFIG REQUIRED)
|
||||
target_link_libraries(libFBX2glTF unofficial::iconv::libiconv unofficial::iconv::libcharset)
|
||||
endif ()
|
||||
|
||||
target_include_directories(libFBX2glTF PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(libFBX2glTF SYSTEM PUBLIC
|
||||
"third_party/stb"
|
||||
"third_party/json"
|
||||
${FBXSDK_INCLUDE_DIR}
|
||||
${DRACO_INCLUDE_DIR}
|
||||
${MATHFU_INCLUDE_DIRS}
|
||||
${FIFO_MAP_INCLUDE_DIR}
|
||||
${CPPCODEC_INCLUDE_DIR}
|
||||
${CPPCODEC_INCLUDE_DIRS}
|
||||
${draco_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(appFBX2glTF PUBLIC
|
||||
|
@ -240,7 +184,7 @@ target_include_directories(appFBX2glTF PUBLIC
|
|||
)
|
||||
target_link_libraries(appFBX2glTF libFBX2glTF)
|
||||
|
||||
install (TARGETS libFBX2glTF appFBX2glTF
|
||||
install(TARGETS libFBX2glTF appFBX2glTF
|
||||
RUNTIME DESTINATION bin
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
|
|
@ -24,7 +24,7 @@ else()
|
|||
endif()
|
||||
|
||||
if (NOT DEFINED FBXSDK_VERSION)
|
||||
set(FBXSDK_VERSION "2019.2")
|
||||
set(FBXSDK_VERSION "2020.3.7")
|
||||
endif()
|
||||
|
||||
set(_fbxsdk_vstudio_version "vs2017")
|
||||
|
@ -43,8 +43,8 @@ set(FBXSDK_WINDOWS_ROOT "${FBXSDK_SDKS_ABS}/Windows/${FBXSDK_VERSION}")
|
|||
|
||||
if (APPLE)
|
||||
set(_fbxsdk_root "${FBXSDK_APPLE_ROOT}")
|
||||
set(_fbxsdk_libdir_debug "lib/clang/debug")
|
||||
set(_fbxsdk_libdir_release "lib/clang/release")
|
||||
set(_fbxsdk_libdir_debug "lib/debug")
|
||||
set(_fbxsdk_libdir_release "lib/release")
|
||||
set(_fbxsdk_libname_debug "libfbxsdk.a")
|
||||
set(_fbxsdk_libname_release "libfbxsdk.a")
|
||||
elseif (WIN32)
|
||||
|
@ -61,11 +61,11 @@ elseif (WIN32)
|
|||
elseif (UNIX)
|
||||
set(_fbxsdk_root "${FBXSDK_LINUX_ROOT}")
|
||||
if (ARCH_32)
|
||||
set(_fbxsdk_libdir_debug "lib/gcc/x86/debug")
|
||||
set(_fbxsdk_libdir_release "lib/gcc/x86/release")
|
||||
set(_fbxsdk_libdir_debug "lib/debug")
|
||||
set(_fbxsdk_libdir_release "lib/release")
|
||||
else()
|
||||
set(_fbxsdk_libdir_debug "lib/gcc/x64/debug")
|
||||
set(_fbxsdk_libdir_release "lib/gcc/x64/release")
|
||||
set(_fbxsdk_libdir_debug "lib/debug")
|
||||
set(_fbxsdk_libdir_release "lib/release")
|
||||
endif()
|
||||
set(_fbxsdk_libname_debug "libfbxsdk.a")
|
||||
set(_fbxsdk_libname_release "libfbxsdk.a")
|
||||
|
|
71
README.md
71
README.md
|
@ -144,51 +144,44 @@ We currently depend on the open source projects
|
|||
and [fmt](https://github.com/fmtlib/fmt);
|
||||
all of which are automatically downloaded and/or built.
|
||||
|
||||
**At present, only version 2019.2 of the FBX SDK is supported**. The
|
||||
**At present, only version 2020.3.7 of the FBX SDK is supported**. The
|
||||
build system will not successfully locate any other version.
|
||||
|
||||
### Linux and MacOS X
|
||||
|
||||
Your development environment will need to have:
|
||||
|
||||
- build essentials (gcc for Linux, clang for Mac)
|
||||
- cmake
|
||||
- python 3.\* and associated pip3/pip command
|
||||
- zstd
|
||||
|
||||
Then, compilation on Unix machines will look something like:
|
||||
|
||||
```
|
||||
# Determine SDK location & build settings for Linux vs (Recent) Mac OS X
|
||||
> if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
export CONAN_CONFIG="-s compiler=apple-clang -s compiler.version=10.0 -s compiler.libcxx=libc++"
|
||||
export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Darwin/archive/2019.2.tar.gz"
|
||||
elif [[ "$OSTYPE" == "linux"* ]]; then
|
||||
export CONAN_CONFIG="-s compiler.libcxx=libstdc++11"
|
||||
export FBXSDK_TARBALL="https://github.com/zellski/FBXSDK-Linux/archive/2019.2.tar.gz"
|
||||
else
|
||||
echo "This snippet only handles Mac OS X and Linux."
|
||||
fi
|
||||
|
||||
# Fetch Project
|
||||
> git clone https://github.com/facebookincubator/FBX2glTF.git
|
||||
> cd FBX2glTF
|
||||
|
||||
# Fetch and unpack FBX SDK
|
||||
> curl -sL "${FBXSDK_TARBALL}" | tar xz --strip-components=1 --include */sdk/
|
||||
# Then decompress the contents
|
||||
> zstd -d -r --rm sdk
|
||||
|
||||
# Install and configure Conan, if needed
|
||||
> pip3 install conan # or sometimes just "pip"; you may need to install Python/PIP
|
||||
> conan remote add --force bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
||||
|
||||
# Initialize & run build
|
||||
> conan install . -i build -s build_type=Release ${CONAN_CONFIG}
|
||||
> conan build . -bf build
|
||||
1. Init vcpkg root
|
||||
```shell
|
||||
git clone https://github.com/microsoft/vcpkg
|
||||
export VCPKG_ROOT=/path/to/vcpkg
|
||||
export PATH=${VCPKG_ROOT}:${PATH}
|
||||
```
|
||||
|
||||
If all goes well, you will end up with a statically linked executable in `./build/FBX2glTF`.
|
||||
2. Init Autodesk SDK 2020.3.7
|
||||
```shell
|
||||
wget https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_gcc_linux.tar.gz # Linux
|
||||
wget https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_clang_mac.pkg.tgz # macOS
|
||||
tar -xvf /path/to/AutodeskFBXSDK
|
||||
# Install using pkg if macOS
|
||||
# Install using shell command if Linux
|
||||
echo "yes\n\n" | ./fbx202037_fbxsdk_gcc_linux /path/to/autodeskfbxsdk/install
|
||||
cp /path/to/autodeskfbxsdk/install/include sdk/Linux/2020.3.7
|
||||
cp /path/to/autodeskfbxsdk/install/lib sdk/Linux/2020.3.7
|
||||
```
|
||||
3. Run cmake
|
||||
```shell
|
||||
cmake .
|
||||
```
|
||||
|
||||
4. Run make
|
||||
```shell
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
5. Test
|
||||
```shell
|
||||
# if we prepared fbx in /input.fbx
|
||||
./FBX2glTF ./FBX2glTF --binary --verbose --keep-attribute --draco --input /input.fbx --output /output.glb
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "mathfu.hpp"
|
||||
|
||||
// give all modules access to our tweaked JSON
|
||||
#include <fifo_map.hpp>
|
||||
#include <nlohmann/fifo_map.hpp>
|
||||
#include <json.hpp>
|
||||
|
||||
template <class K, class V, class ignore, class A>
|
||||
|
|
|
@ -41,12 +41,10 @@ struct PrimitiveData {
|
|||
int8_t componentCount = attribute.glType.count;
|
||||
att.Init(
|
||||
attribute.dracoAttribute,
|
||||
nullptr,
|
||||
componentCount,
|
||||
attribute.dracoComponentType,
|
||||
false,
|
||||
componentCount * draco::DataTypeLength(attribute.dracoComponentType),
|
||||
0);
|
||||
componentCount * draco::DataTypeLength(attribute.dracoComponentType));
|
||||
|
||||
const int dracoAttId = dracoMesh->AddAttribute(att, true, to_uint32(attribArr.size()));
|
||||
draco::PointAttribute* attPtr = dracoMesh->attribute(dracoAttId);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"default-registry": {
|
||||
"kind": "git",
|
||||
"baseline": "d7112d1a4fb50410d3639f5f586972591d848beb",
|
||||
"repository": "https://github.com/microsoft/vcpkg"
|
||||
},
|
||||
"registries": [
|
||||
{
|
||||
"kind": "artifact",
|
||||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||
"name": "microsoft"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"boost-filesystem",
|
||||
"boost-optional",
|
||||
"cppcodec",
|
||||
"draco",
|
||||
"fmt",
|
||||
"libiconv",
|
||||
"libxml2",
|
||||
"nlohmann-fifo-map",
|
||||
"zlib"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"name": "fmt",
|
||||
"version": "5.3.0"
|
||||
},
|
||||
{
|
||||
"name": "libiconv",
|
||||
"version": "1.15-6"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue