Skip to content

Commit 276a0df

Browse files
author
Par Winzell
committed
Initial commit.
0 parents  commit 276a0df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5781
-0
lines changed

CMakeLists.txt

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(FBX2glTF)
3+
4+
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
5+
message(FATAL_ERROR
6+
"Building from within the source tree is not supported.\n"
7+
"Hint: mkdir -p build; cmake -H. -Bbuild; make -Cbuild\n")
8+
endif ()
9+
10+
set(CMAKE_CXX_STANDARD 11)
11+
find_package(Threads REQUIRED)
12+
13+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
14+
include(ExternalProject)
15+
16+
# FBX
17+
find_package(FBX REQUIRED)
18+
if (NOT FBXSDK_FOUND)
19+
message(FATAL_ERROR
20+
"Can't find FBX SDK in either:\n"
21+
" - Mac OS X: ${FBXSDK_APPLE_ROOT}\n"
22+
" - Windows: ${FBXSDK_WINDOWS_ROOT}\n"
23+
" - Linux: ${FBXSDK_LINUX_ROOT}"
24+
)
25+
endif()
26+
27+
# DRACO
28+
ExternalProject_Add(Draco
29+
UPDATE_DISCONNECTED TRUE
30+
GIT_REPOSITORY https://github.com/google/draco
31+
PREFIX draco
32+
INSTALL_DIR
33+
CMAKE_ARGS
34+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
35+
)
36+
set(DRACO_INCLUDE_DIR "${CMAKE_BINARY_DIR}/draco/include")
37+
if (WIN32)
38+
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/dracoenc.lib")
39+
else()
40+
set(DRACO_LIB "${CMAKE_BINARY_DIR}/draco/lib/libdracoenc.a")
41+
endif()
42+
43+
# MATHFU
44+
set(mathfu_build_benchmarks OFF CACHE BOOL "")
45+
set(mathfu_build_tests OFF CACHE BOOL "")
46+
ExternalProject_Add(MathFu
47+
UPDATE_DISCONNECTED TRUE
48+
GIT_REPOSITORY https://github.com/google/mathfu
49+
PREFIX mathfu
50+
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu configure step."
51+
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu build step."
52+
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping MathFu install step."
53+
)
54+
set(MATHFU_INCLUDE_DIRS
55+
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/include/"
56+
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/dependencies/vectorial/include")
57+
58+
# JSON
59+
ExternalProject_Add(Json
60+
UPDATE_DISCONNECTED TRUE
61+
GIT_REPOSITORY https://github.com/nlohmann/json
62+
PREFIX json
63+
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping JSON configure step."
64+
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping JSON build step."
65+
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping JSON install step."
66+
)
67+
set(JSON_INCLUDE_DIR "${CMAKE_BINARY_DIR}/json/src/Json/src")
68+
69+
# cppcodec
70+
ExternalProject_Add(CPPCodec
71+
UPDATE_DISCONNECTED TRUE
72+
GIT_REPOSITORY https://github.com/tplgy/cppcodec
73+
PREFIX cppcodec
74+
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec configure step."
75+
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec build step."
76+
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping CPPCodec install step."
77+
)
78+
set(CPPCODEC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cppcodec/src/CPPCodec")
79+
80+
# CXXOPTS
81+
ExternalProject_Add(CxxOpts
82+
UPDATE_DISCONNECTED TRUE
83+
GIT_REPOSITORY https://github.com/jarro2783/cxxopts
84+
PREFIX cxxopts
85+
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping cxxopts configure step."
86+
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping cxxopts build step."
87+
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping cxxopts install step."
88+
)
89+
set(CXXOPTS_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cxxopts/src/CxxOpts/include")
90+
91+
# FMT
92+
ExternalProject_Add(Fmt
93+
UPDATE_DISCONNECTED TRUE
94+
GIT_REPOSITORY https://github.com/fmtlib/fmt
95+
CMAKE_CACHE_ARGS "-DFMT_DOC:BOOL=OFF" "-DFMT_INSTALL:BOOL=ON" "-DFMT_TEST:BOOL=OFF"
96+
CMAKE_ARGS
97+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
98+
PREFIX fmt
99+
)
100+
set(FMT_INCLUDE_DIR "${CMAKE_BINARY_DIR}/fmt/include")
101+
if (WIN32)
102+
set(FMT_LIB "${CMAKE_BINARY_DIR}/fmt/lib/fmt.lib")
103+
else()
104+
set(FMT_LIB "${CMAKE_BINARY_DIR}/fmt/lib/libfmt.a")
105+
endif()
106+
107+
if (APPLE)
108+
find_library(CF_FRAMEWORK CoreFoundation)
109+
message("CoreFoundation Framework: ${CF_FRAMEWORK}")
110+
set(FRAMEWORKS ${CF_FRAMEWORK})
111+
endif()
112+
113+
set(SOURCE_FILES
114+
src/utils/File_Utils.cpp
115+
src/utils/Image_Utils.cpp
116+
src/utils/String_Utils.cpp
117+
src/main.cpp
118+
src/Fbx2Raw.cpp
119+
src/Raw2Gltf.cpp
120+
src/RawModel.cpp
121+
src/glTF/BufferData.cpp
122+
src/glTF/MaterialData.cpp
123+
src/glTF/MeshData.cpp
124+
src/glTF/NodeData.cpp
125+
src/glTF/PrimitiveData.cpp
126+
src/glTF/BufferViewData.cpp
127+
src/glTF/BufferViewData.h
128+
src/glTF/AccessorData.cpp
129+
src/glTF/AccessorData.h
130+
src/glTF/ImageData.cpp
131+
src/glTF/TextureData.cpp
132+
src/glTF/SkinData.cpp
133+
src/glTF/AnimationData.cpp
134+
src/glTF/CameraData.cpp
135+
src/glTF/SceneData.cpp
136+
)
137+
138+
add_executable(FBX2glTF ${SOURCE_FILES})
139+
140+
add_dependencies(FBX2glTF
141+
Draco
142+
MathFu
143+
Json
144+
CxxOpts
145+
CPPCodec
146+
Fmt
147+
)
148+
149+
if (NOT MSVC)
150+
# Disable annoying & spammy warning from FBX SDK header file
151+
target_compile_options(FBX2glTF PRIVATE
152+
"-Wno-null-dereference"
153+
"-Wunused"
154+
)
155+
endif()
156+
157+
target_link_libraries(FBX2glTF
158+
${FRAMEWORKS}
159+
${CMAKE_DL_LIBS}
160+
${CMAKE_THREAD_LIBS_INIT}
161+
${DRACO_LIB}
162+
${FMT_LIB}
163+
optimized ${FBXSDK_LIBRARY}
164+
debug ${FBXSDK_LIBRARY_DEBUG}
165+
)
166+
167+
target_include_directories(FBX2glTF PUBLIC
168+
${CMAKE_CURRENT_SOURCE_DIR}/src
169+
${FBXSDK_INCLUDE_DIR}
170+
${DRACO_INCLUDE_DIR}
171+
${MATHFU_INCLUDE_DIRS}
172+
${JSON_INCLUDE_DIR}
173+
${CXXOPTS_INCLUDE_DIR}
174+
${CPPCODEC_INCLUDE_DIR}
175+
${FMT_INCLUDE_DIR}
176+
)
177+
178+
install (TARGETS FBX2glTF DESTINATION bin)

CONTRIBUTING.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributing to FBX2glTF
2+
We want to make contributing to this project as easy and transparent as
3+
possible.
4+
5+
## Pull Requests
6+
We actively welcome your pull requests.
7+
8+
1. Fork the repo and create your branch from `master`.
9+
2. Ensure your code matches the style of existing source.
10+
3. In case of behavioural changes, update this documentation.
11+
4. If you haven't already, complete the Contributor License Agreement ("CLA").
12+
13+
## Contributor License Agreement ("CLA")
14+
In order to accept your pull request, we need you to submit a CLA. You only need
15+
to do this once to work on any of Facebook's open source projects.
16+
17+
Complete your CLA here: <https://code.facebook.com/cla>
18+
19+
## Issues
20+
We use GitHub issues to track public bugs. Please ensure your description is
21+
clear and has sufficient instructions to be able to reproduce the issue.
22+
23+
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
24+
disclosure of security bugs. In those cases, please go through the process
25+
outlined on that page and do not file a public issue.
26+
27+
## License
28+
By contributing to FBX2glTF, you agree that your contributions will be licensed
29+
under the LICENSE file in the root directory of this source tree.

FindFBX.cmake

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#
2+
# Helper function for finding the FBX SDK.
3+
# Cribbed & tweaked from https://github.com/floooh/fbxc/
4+
#
5+
# params: FBXSDK_VERSION
6+
# FBXSDK_SDKS
7+
#
8+
# sets: FBXSDK_FOUND
9+
# FBXSDK_DIR
10+
# FBXSDK_LIBRARY
11+
# FBXSDK_LIBRARY_DEBUG
12+
# FBXSDK_INCLUDE_DIR
13+
#
14+
15+
# semi-hack to detect architecture
16+
if( CMAKE_SIZEOF_VOID_P MATCHES 8 )
17+
# void ptr = 8 byte --> x86_64
18+
set(ARCH_32 OFF)
19+
else()
20+
# void ptr != 8 byte --> x86
21+
set(ARCH_32 OFF)
22+
endif()
23+
24+
set(FBXSDK_VERSION "2018.1.1" CACHE STRING "Precise version string of FBX SDK to use.")
25+
26+
set(_fbxsdk_vstudio_version "vs2015")
27+
28+
message("Looking for FBX SDK version: ${FBXSDK_VERSION}")
29+
30+
if (DEFINED FBXSDK_SDKS)
31+
get_filename_component(FBXSDK_SDKS_ABS ${FBXSDK_SDKS} ABSOLUTE)
32+
33+
set(FBXSDK_APPLE_ROOT "${FBXSDK_SDKS_ABS}/Darwin/${FBXSDK_VERSION}")
34+
set(FBXSDK_LINUX_ROOT "${FBXSDK_SDKS_ABS}/Linux/${FBXSDK_VERSION}")
35+
set(FBXSDK_WINDOWS_ROOT "${FBXSDK_SDKS_ABS}/Windows/${FBXSDK_VERSION}")
36+
else()
37+
set(FBXSDK_APPLE_ROOT
38+
"/Applications/Autodesk/FBX SDK/${FBXSDK_VERSION}")
39+
set(FBXSDK_LINUX_ROOT
40+
"/usr")
41+
set(FBXSDK_WINDOWS_ROOT
42+
"C:/Program Files/Autodesk/FBX/FBX SDK/${FBXSDK_VERSION}")
43+
endif()
44+
45+
if (APPLE)
46+
set(_fbxsdk_root "${FBXSDK_APPLE_ROOT}")
47+
set(_fbxsdk_libdir_debug "lib/clang/debug")
48+
set(_fbxsdk_libdir_release "lib/clang/release")
49+
set(_fbxsdk_libname_debug "libfbxsdk.a")
50+
set(_fbxsdk_libname_release "libfbxsdk.a")
51+
elseif (WIN32)
52+
set(_fbxsdk_root "${FBXSDK_WINDOWS_ROOT}")
53+
if (ARCH_32)
54+
set(_fbxsdk_libdir_debug "lib/${_fbxsdk_vstudio_version}/x86/debug")
55+
set(_fbxsdk_libdir_release "lib/${_fbxsdk_vstudio_version}/x86/release")
56+
else()
57+
set(_fbxsdk_libdir_debug "lib/${_fbxsdk_vstudio_version}/x64/debug")
58+
set(_fbxsdk_libdir_release "lib/${_fbxsdk_vstudio_version}/x64/release")
59+
endif()
60+
set(_fbxsdk_libname_debug "libfbxsdk-md.lib")
61+
set(_fbxsdk_libname_release "libfbxsdk-md.lib")
62+
elseif (UNIX)
63+
set(_fbxsdk_root "${FBXSDK_LINUX_ROOT}")
64+
if (ARCH_32)
65+
set(_fbxsdk_libdir_debug "lib/gcc4/x86/debug")
66+
set(_fbxsdk_libdir_release "lib/gcc4/x86/release")
67+
else()
68+
set(_fbxsdk_libdir_debug "lib/gcc4/x64/debug")
69+
set(_fbxsdk_libdir_release "lib/gcc4/x64/release")
70+
endif()
71+
set(_fbxsdk_libname_debug "libfbxsdk.a")
72+
set(_fbxsdk_libname_release "libfbxsdk.a")
73+
else()
74+
message(FATAL_ERROR, "Unknown platform. Can't find FBX SDK.")
75+
endif()
76+
77+
# should point the the FBX SDK installation dir
78+
set(FBXSDK_ROOT "${_fbxsdk_root}")
79+
message("FBXSDK_ROOT: ${FBXSDK_ROOT}")
80+
81+
# find header dir and libs
82+
find_path(FBXSDK_INCLUDE_DIR "fbxsdk.h"
83+
NO_CMAKE_FIND_ROOT_PATH
84+
PATHS ${FBXSDK_ROOT}
85+
PATH_SUFFIXES "include")
86+
message("FBXSDK_INCLUDE_DIR: ${FBXSDK_INCLUDE_DIR}")
87+
88+
find_library(FBXSDK_LIBRARY ${_fbxsdk_libname_release}
89+
NO_CMAKE_FIND_ROOT_PATH
90+
PATHS "${FBXSDK_ROOT}/${_fbxsdk_libdir_release}")
91+
message("FBXSDK_LIBRARY: ${FBXSDK_LIBRARY}")
92+
93+
find_library(FBXSDK_LIBRARY_DEBUG ${_fbxsdk_libname_debug}
94+
NO_CMAKE_FIND_ROOT_PATH
95+
PATHS "${FBXSDK_ROOT}/${_fbxsdk_libdir_debug}")
96+
message("FBXSDK_LIBRARY_DEBUG: ${FBXSDK_LIBRARY_DEBUG}")
97+
98+
if (FBXSDK_INCLUDE_DIR AND FBXSDK_LIBRARY AND FBXSDK_LIBRARY_DEBUG)
99+
set(FBXSDK_FOUND YES)
100+
else()
101+
set(FBXSDK_FOUND NO)
102+
endif()

LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BSD License
2+
3+
For FBX2glTF software
4+
5+
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
* Neither the name Facebook nor the names of its contributors may be used to
18+
endorse or promote products derived from this software without specific
19+
prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PATENTS

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Additional Grant of Patent Rights Version 2
2+
3+
"Software" means the FBX2glTF software contributed by Facebook, Inc.
4+
5+
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
6+
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
7+
(subject to the termination provision below) license under any Necessary
8+
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
9+
transfer the Software. For avoidance of doubt, no license is granted under
10+
Facebook’s rights in any patent claims that are infringed by (i) modifications
11+
to the Software made by you or any third party or (ii) the Software in
12+
combination with any software or other technology.
13+
14+
The license granted hereunder will terminate, automatically and without notice,
15+
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
16+
directly or indirectly, or take a direct financial interest in, any Patent
17+
Assertion: (i) against Facebook or any of its subsidiaries or corporate
18+
affiliates, (ii) against any party if such Patent Assertion arises in whole or
19+
in part from any software, technology, product or service of Facebook or any of
20+
its subsidiaries or corporate affiliates, or (iii) against any party relating
21+
to the Software. Notwithstanding the foregoing, if Facebook or any of its
22+
subsidiaries or corporate affiliates files a lawsuit alleging patent
23+
infringement against you in the first instance, and you respond by filing a
24+
patent infringement counterclaim in that lawsuit against that party that is
25+
unrelated to the Software, the license granted hereunder will not terminate
26+
under section (i) of this paragraph due to such counterclaim.
27+
28+
A "Necessary Claim" is a claim of a patent owned by Facebook that is
29+
necessarily infringed by the Software standing alone.
30+
31+
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
32+
or contributory infringement or inducement to infringe any patent, including a
33+
cross-claim or counterclaim.

0 commit comments

Comments
 (0)