### Example Usage Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Demonstrates how to install and build the project using Conan. ```bash mkdir -p build_debug conan install . -i build_debug -s build_type=Debug -e FBXSDK_SDKS=/home/zell/FBXSDK conan build . -bf build_debug ``` -------------------------------- ### Example Usage Source: https://github.com/facebookincubator/fbx2gltf/blob/main/npm/fbx2gltf/README.md An example demonstrating how to use the convert function to convert an FBX file to a GLB file, including handling success and error cases. ```javascript const convert = require('fbx2gltf'); convert('path/to/some.fbx', 'path/to/target.glb', ['--khr-materials-unlit']).then( destPath => { // yay, do what we will with our shiny new GLB file! }, error => { // ack, conversion failed: inspect 'error' for details } ); ``` -------------------------------- ### Executable Linking and Installation Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Links the appFBX2glTF executable against the libFBX2glTF library and defines installation rules for targets. ```cmake target_link_libraries(appFBX2glTF libFBX2glTF) install (TARGETS libFBX2glTF appFBX2glTF RUNTIME DESTINATION bin ARCHIVE DESTINATION lib ) ``` -------------------------------- ### Linux and MacOS X Build Instructions Source: https://github.com/facebookincubator/fbx2gltf/blob/main/README.md Steps to build the fbx2gltf project on Linux and MacOS X, including setting environment variables, cloning the repository, fetching and unpacking the FBX SDK, installing and configuring Conan, and running the build. ```bash # 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 ``` -------------------------------- ### MathFu External Project Configuration Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Configures the MathFu library as an external project, skipping configure, build, and install steps. ```cmake set(mathfu_build_benchmarks OFF CACHE BOOL "") set(mathfu_build_tests OFF CACHE BOOL "") ExternalProject_Add(MathFu PREFIX mathfu GIT_REPOSITORY https://github.com/google/mathfu GIT_TAG v1.1.0 CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu configure step." BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu build step." INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu install step." ) ``` -------------------------------- ### FiFoMap External Project Configuration Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Configures the FiFoMap library as an external project, skipping configure, build, and install steps. ```cmake 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." ) ``` -------------------------------- ### ExternalProject_Add for CPPCodec Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Defines the CPPCodec external project, specifying its Git repository and placeholder commands for configure, build, and install steps. ```cmake 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." ) ``` -------------------------------- ### FBX2glTF Help Output Source: https://github.com/facebookincubator/fbx2gltf/blob/main/README.md This is the output of running the FBX2glTF binary with the --help flag, showing all available positional arguments and options. ```bash FBX2glTF 0.9.7: Generate a glTF 2.0 representation of an FBX model. Usage: FBX2glTF [OPTIONS] [FBX Model] Positionals: FBX Model FILE The FBX model to convert. Options: -h,--help Print this help message and exit -v,--verbose Include blend shape tangents, if reported present by the FBX SDK. -V,--version -i,--input FILE The FBX model to convert. -o,--output TEXT Where to generate the output, without suffix. -e,--embed Inline buffers as data:// URIs within generated non-binary glTF. -b,--binary Output a single binary format .glb file. --long-indices (never|auto|always) Whether to use 32-bit indices. --compute-normals (never|broken|missing|always) When to compute vertex normals from mesh geometry. --anim-framerate (bake24|bake30|bake60) Select baked animation framerate. --flip-u Flip all U texture coordinates. --no-flip-u Don't flip U texture coordinates. --flip-v Flip all V texture coordinates. --no-flip-v Don't flip V texture coordinates. --no-khr-lights-punctual Don't use KHR_lights_punctual extension to export FBX lights. --user-properties Transcribe FBX User Properties into glTF node and material 'extras'. --blend-shape-normals Include blend shape normals, if reported present by the FBX SDK. --blend-shape-tangents Include blend shape tangents, if reported present by the FBX SDK. -k,--keep-attribute (position|normal|tangent|binormial|color|uv0|uv1|auto) ... Used repeatedly to build a limiting set of vertex attributes to keep. --fbx-temp-dir DIR Temporary directory to be used by FBX SDK. Materials: --pbr-metallic-roughness Try to glean glTF 2.0 native PBR attributes from the FBX. --khr-materials-unlit Use KHR_materials_unlit extension to request an unlit shader. Draco: -d,--draco Apply Draco mesh compression to geometries. --draco-compression-level INT in [0 - 10]=7 The compression level to tune Draco to. --draco-bits-for-position INT in [1 - 32]=14 How many bits to quantize position to. --draco-bits-for-uv INT in [1 - 32]=10 How many bits to quantize UV coordinates to. --draco-bits-for-normals INT in [1 - 32]=10 How many bits to quantize nornals to. --draco-bits-for-colors INT in [1 - 32]=8 How many bits to quantize colors to. --draco-bits-for-other INT in [1 - 32]=8 How many bits to quantize all other vertex attributes to. ``` -------------------------------- ### Include Directories Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Configures public and system include directories for the libFBX2glTF and appFBX2glTF targets. ```cmake 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} ) target_include_directories(appFBX2glTF PUBLIC "third_party/CLI11" ) ``` -------------------------------- ### Basic Usage Source: https://github.com/facebookincubator/fbx2gltf/blob/main/README.md The tool can be invoked with the path to the FBX file. ```bash > FBX2glTF ~/models/butterfly.fbx ``` -------------------------------- ### Library and Executable Definitions Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Defines the static library 'libFBX2glTF' and the executable 'appFBX2glTF', listing their source files and setting output names. ```cmake set(LIB_SOURCE_FILES src/FBX2glTF.h src/fbx/materials/3dsMaxPhysicalMaterial.cpp src/fbx/materials/FbxMaterials.cpp src/fbx/materials/FbxMaterials.hpp src/fbx/materials/RoughnessMetallicMaterials.hpp src/fbx/materials/StingrayPBSMaterial.cpp src/fbx/materials/TraditionalMaterials.cpp src/fbx/materials/TraditionalMaterials.hpp src/fbx/Fbx2Raw.cpp src/fbx/Fbx2Raw.hpp src/fbx/FbxBlendShapesAccess.cpp src/fbx/FbxBlendShapesAccess.hpp src/fbx/FbxLayerElementAccess.hpp src/fbx/FbxSkinningAccess.cpp src/fbx/FbxSkinningAccess.hpp src/gltf/Raw2Gltf.cpp src/gltf/Raw2Gltf.hpp src/gltf/GltfModel.cpp src/gltf/GltfModel.hpp src/gltf/TextureBuilder.cpp src/gltf/TextureBuilder.hpp src/gltf/properties/AccessorData.cpp src/gltf/properties/AccessorData.hpp src/gltf/properties/AnimationData.cpp src/gltf/properties/AnimationData.hpp src/gltf/properties/BufferData.cpp src/gltf/properties/BufferData.hpp src/gltf/properties/BufferViewData.cpp src/gltf/properties/BufferViewData.hpp src/gltf/properties/CameraData.cpp src/gltf/properties/CameraData.hpp src/gltf/properties/ImageData.cpp src/gltf/properties/ImageData.hpp src/gltf/properties/LightData.cpp src/gltf/properties/LightData.hpp src/gltf/properties/MaterialData.cpp src/gltf/properties/MaterialData.hpp src/gltf/properties/MeshData.cpp src/gltf/properties/MeshData.hpp src/gltf/properties/NodeData.cpp src/gltf/properties/NodeData.hpp src/gltf/properties/PrimitiveData.cpp src/gltf/properties/PrimitiveData.hpp src/gltf/properties/SamplerData.hpp src/gltf/properties/SceneData.cpp src/gltf/properties/SceneData.hpp src/gltf/properties/SkinData.cpp src/gltf/properties/SkinData.hpp src/gltf/properties/TextureData.cpp src/gltf/properties/TextureData.hpp src/mathfu.hpp src/raw/RawModel.cpp src/raw/RawModel.hpp src/utils/File_Utils.cpp src/utils/File_Utils.hpp src/utils/Image_Utils.cpp src/utils/Image_Utils.hpp src/utils/String_Utils.hpp third_party/CLI11/CLI11.hpp ) add_library(libFBX2glTF STATIC ${LIB_SOURCE_FILES}) set_target_properties(libFBX2glTF PROPERTIES OUTPUT_NAME "FBX2glTF") add_executable(appFBX2glTF src/FBX2glTF.cpp) set_target_properties(appFBX2glTF PROPERTIES OUTPUT_NAME "FBX2glTF") ``` -------------------------------- ### Advanced Usage Source: https://github.com/facebookincubator/fbx2gltf/blob/main/README.md The tool can be invoked with several options for more complex pipelines, including binary output, Draco compression, verbosity, and specifying input/output paths. ```bash > FBX2glTF --binary --draco --verbose \ --input ~/models/source/butterfly.fbx \ --output ~/models/target/butterfly.glb ``` -------------------------------- ### Iconv/libiconv Linking Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Conditionally links the Iconv framework on Apple platforms and libiconv on other platforms. ```cmake 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() ``` -------------------------------- ### Draco External Project Configuration Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Configures the Draco library as an external project. ```cmake ExternalProject_Add(Draco GIT_REPOSITORY https://github.com/google/draco GIT_TAG 1.3.4 PREFIX draco INSTALL_DIR CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DBUILD_FOR_GLTF=1 ) ``` -------------------------------- ### Linking Libraries Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Specifies the libraries to be linked with the libFBX2glTF target, including frameworks, Boost libraries, Draco, FBX SDK, fmt, libxml2, zlib, and system libraries. ```cmake target_link_libraries(libFBX2glTF ${FRAMEWORKS} boost_filesystem::boost_filesystem boost_optional::boost_optional ${DRACO_LIB} optimized ${FBXSDK_LIBRARY} debug ${FBXSDK_LIBRARY_DEBUG} fmt::fmt libxml2::libxml2 zlib::zlib ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ) ``` -------------------------------- ### Compile Options for Non-MSVC Source: https://github.com/facebookincubator/fbx2gltf/blob/main/CMakeLists.txt Disables specific compiler warnings for the libFBX2glTF and appFBX2glTF targets when not using MSVC. ```cmake if (NOT MSVC) # Disable annoying & spammy warning from FBX SDK header file target_compile_options(libFBX2glTF PRIVATE "-Wno-null-dereference" "-Wunused" ) target_compile_options(appFBX2glTF PRIVATE "-Wno-null-dereference" "-Wunused" ) endif() ``` -------------------------------- ### Convert Function Signature Source: https://github.com/facebookincubator/fbx2gltf/blob/main/npm/fbx2gltf/README.md Defines the signature for the convert function, which takes source and destination file paths, and optional arguments, returning a Promise of the converted file path. ```javascript convert(srcPath :string, destPath :string, args :?string[]) :Promise ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.