Code Monkey home page Code Monkey logo

fbx-gltf's Introduction

glTF is the runtime asset format for WebGL, OpenGL ES, and OpenGL.

glTF is a draft specification, it may change before ratification. Everyone is encouraged to provide feedback on the specification and contribute to the open-source converter. Please create issues with your feedback.

Specification

glTF Specification 1.0

Converter

glTF is an open-source command-line pipeline tool that converts FBX file (and any file format that FBX can read such as obj, collada, ...) to glTF.

FBX importer/exporter plug-in

IO-glTF is an open-source FBX importer/exporter plug-in that converts FBX file (and any file format that FBX can read such as obj, collada, ...) to glTF.
This plug-in can be used by any FBX based application to import/export glTF files.

Dependencies

This sample is dependent of the following 3rd party extension:

  • The Casablanca C++ RESTful SDK - version 2.4.0.1

  • The FBX C++ SDK - version 2015.1

  • For building on Mac OSX, and Linux, you also need cmake which is also required for the Casablanca C++ RESTful SDK.
    However, Casablanca requires version 2.8 (or later), while the glTF converter is setup to use version 3.1, you may install version 3.1 or change the cmake files header back to 2.8.

Build the solution

Windows

Required: Visual Studio 2013 (should work with Visual Studio 2012 too, but not tested)

  1. Download and install the FBX SDK

  2. Clone or download the FBX-glTF source code

  3. Load the glTF.sln solution file in Visual Studio 2013

  4. Optional: if you did not install FBX at the standard location or use a version different from 2015.1, open the solution Property Manager and edit the User Macro FBX_SDK to point to the root of your FBX SDK. Another way is to edit the Fbx.props file and manually change the path before step 2.

  5. Build the FBX-glTF solution. NuGet will install 'casablanca' for you upon building.

Mac OSX

Required: Mac OSX Maverick or Yosemite, Xcode 6.1.1

  1. Download and install the FBX SDK

  2. Clone or download the FBX-glTF source code

  3. Download and compile 'casablanca' on your machine. Instructions here

  4. Install ‘casablanca’ on your system by running ‘sudo make install’

  5. Recommended: Create a folder with the name you want, and go in that directory

  6. Optional: Copy the CMakeConfigExample.txt file and rename it as CMakeCache.txt in your build folder, and edit the FBX path entry. That will avoid you to type the parameters below.

  7. Execute:

    a. For a release build: cmake .. -DCMAKE_BUILD_TYPE=Release -DFBX_SDK=<path to FBX>

    b. For a debug build: cmake .. -DCMAKE_BUILD_TYPE=Debug -DFBX_SDK=<path to FBX>

    or simply ‘cmake ..’ if you followed step 6.

Note: on Mac OSX, the FBX SDK installs by default in /Applications/Autodesk/FBX SDK/2015.1

Linux

Required: gcc 4.8+ (tested on Ubuntu Linux 14.04 Desktop)

  1. Download and install the FBX SDK

  2. Clone or download the FBX-glTF source code

  3. Download and compile 'casablanca' on your machine. Instructions here

  4. Install ‘casablanca’ on your system by running ‘sudo make install’

  5. Recommended: Create a folder with the name you want, and go in that directory

  6. Optional: Copy the CMakeConfigExample.txt file and rename it as CMakeCache.txt in your build folder, and edit the FBX path entry. That will avoid you to type the parameters below.

  7. Execute:

    a. For a release build: cmake .. -DCMAKE_BUILD_TYPE=Release -DFBX_SDK=<path to FBX>

    b. For a debug build: cmake .. -DCMAKE_BUILD_TYPE=Debug -DFBX_SDK=<path to FBX>

    or simply ‘cmake ..’ if you followed step 6.

Usage Instructions

For Windows, the files will be located in FBX-glTF\x64\Release or FBX-glTF\x64\Debug

For both Mac OXS and Linux, the files will be located in FBX-glTF/<your cmake folder>/Release or FBX-glTF//Debug

Usage: glTF [-h] [-v] [-t] [-l] [-e] [-o ] -f <input file>

-f/--file        - file to convert to glTF [string] 
-o/--output      - path of output directory [string]
-n/--name        - override the scene name [string]
-c/--copy        - copy all media to the target directory (cannot be combined with --embed)
-e/--embed       - embed all resources as Data URIs (cannot be combined with --copy)
-h/--help        - this message
-v/--version     - version

Typical command:

glTF -f MyFBXorDAEfile -o MyOutputDirectory -n NewName -c

Example:

cd FBX-glTF\models\duck
glTF -f duck.fbx -o ..\..\three.js\models\duck -n duck -c
cd ..\au
glTF -f au.fbx -o ..\..\three.js\models\au -c
glTF -f au3.fbx -o ..\..\three.js\models\au3 -e

Viewing results using Three.js

  1. Install Node.js on your computer

  2. Open a node terminal

  3. Go in directory FBX-glTF/Three.js

  4. Execute: npm install

  5. Execute: node serve.js

  6. Launch your internet favourite browser and browse to http://localhost


License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Cyrille Fauvel (Autodesk Developer Network)
http://www.autodesk.com/adn
http://around-the-corner.typepad.com/

fbx-gltf's People

Contributors

cyrillef avatar vijayaprakash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbx-gltf's Issues

won't compile mac OS 10.12.6

cpprestsdk 2.9.1
FBX SDK 2015.1 (also tried 2017.1)
mac OS 10.12.6

cpprest compiles fine but FBX-glTF throws errors after running make:

[  3%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o
In file included from /Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.cpp:21:
In file included from /Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/StdAfx.h:69:
In file included from /Applications/Autodesk/FBX SDK/2017.1/include/fbxsdk.h:98:
In file included from /Applications/Autodesk/FBX SDK/2017.1/include/fbxsdk/core/fbxloadingstrategy.h:20:
In file included from /Applications/Autodesk/FBX SDK/2017.1/include/fbxsdk/core/fbxplugin.h:20:
In file included from /Applications/Autodesk/FBX SDK/2017.1/include/fbxsdk/core/fbxobject.h:21:
/Applications/Autodesk/FBX SDK/2017.1/include/fbxsdk/core/fbxproperty.h:1188:70: warning: binding dereferenced null pointer to reference has undefined behavior [-Wnull-dereference]
                return StaticInit(pObject, pName, FbxGetDataTypeFromEnum(FbxTypeOf(*((FbxReference*)0))), pValue, pForceSet, pFlags);
                                                                                   ^~~~~~~~~~~~~~~~~~~
In file included from /Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.cpp:22:
/Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.h:51:7: error: class member cannot be redeclared
        void appendCode (const utility::char_t *format, ...) ;
             ^
/Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.h:50:7: note: previous declaration is here
        void appendCode (const char *format, ...) ;
             ^
/Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.cpp:96:18: error: redefinition of 'appendCode'
void glslShader::appendCode (const utility::char_t *format, ...) {
                 ^
/Users/shawn/Desktop/freelance/level2d/FBX-glTF/IO-glTF/glslShader.cpp:83:18: note: previous definition is here
void glslShader::appendCode (const char *format, ...) {
                 ^
1 warning and 2 errors generated.
make[2]: *** [IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o] Error 1
make[1]: *** [IO-glTF/CMakeFiles/IO-glTF.dir/all] Error 2
make: *** [all] Error 2

FBX model with chinese characters fails

I have a FBX file with chinese node names etc. The export to glTF results in an invalid gltf file like:

{"accessors":{"Basic Wall

'Wall ' should be followed by a chinese name. Is there an easy way to add support for chinese characters?
Thanks!

How to embed shaders into glTF?

When i export model as FBX, there is no shader in it. Where're sample models' shaders come from?
How to export model with shaders and convert to glTF ?

Linux Make failure

Scanning dependencies of target IO-glTF [ 3%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o In file included from XXX/FBX-glTF-master/IO-glTF/glslShader.cpp:22:0: XXX/FBX-glTF-master/IO-glTF/glslShader.h:51:7: error: ‘void glTF::glslShader::appendCode(const char_t*, ...)’ cannot be overloaded void appendCode (const utility::char_t *format, ...) ; ^ XXX/FBX-glTF-master/IO-glTF/glslShader.h:50:7: error: with ‘void glTF::glslShader::appendCode(const char*, ...)’ void appendCode (const char *format, ...) ; ^ XXX/FBX-glTF-master/IO-glTF/glslShader.cpp:83:54: error: no ‘void glTF::glslShader::appendCode2(const char*, ...)’ member function declared in class ‘glTF::glslShader’ void glslShader::appendCode2 (const char *format, ...) { ^ IO-glTF/CMakeFiles/IO-glTF.dir/build.make:182: recipe for target 'IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o' failed make[2]: *** [IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o] Error 1 CMakeFiles/Makefile2:85: recipe for target 'IO-glTF/CMakeFiles/IO-glTF.dir/all' failed make[1]: *** [IO-glTF/CMakeFiles/IO-glTF.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2
I had installed Casablanca correctly on Ubuntu and I am currently using the 2017 FBX SDK. Not sure why cmake is giving an error because of overloaded functions

glTF command not found error

I installed all the dependencies on my linux machine(Ubuntu 18.04.2 LTS 64-bit) with 16 GB of RAM. Then, I built the solution using the cmake command as specified in the documentation. The build was created successfully. There’s nothing more suggested in the documentation. So then on running the glTF command and providing the FBX file as parameter, I got the “glTF: command not found” error.
I am sending you the screenshots of the commands I ran alongwith the directory structure obtained after running the commands.
Please look into the issue.
Screenshot from 2019-05-01 20-03-49
Screenshot from 2019-05-01 20-05-24

Wrong indexing used for normals, etc. in gltfwriterVBO::GetLayerElements

The resulting glTF has incorrect normals as a result.

To work around the issue, I have changed the macro GetLayerElement to use the MappingMode rather than the ReferenceMode, like so

#define GetLayerElement(layerElt, indexV, T, V, index, lambda)
int indexV =-1 ;
T V ;
if ( layerElt ) {
indexV =(layerElt->GetMappingMode () == FbxLayerElement::eByPolygonVertex ? index : layerElt->GetIndexArray () [index]) ;
V =layerElt->GetDirectArray ().GetAt (indexV) ;
lambda (V) ;
}

Models that demonstrate the problem are here

https://github.com/alinen/FBX-glTF/tree/master/three.js/models/drone_shell (needs updated three.js too)
https://github.com/alinen/FBX-glTF/tree/master/three.js/models/airplane

I would be interested in knowing the proper fix!

Opening model in lmv fails: byte length of Float32Array should be a multiple of 4

I converted a sample model from Revit to FBX and converted it to glTF. When opening this model in lmv I get error:

Uncaught RangeError: byte length of Float32Array should be a multiple of 4

I used:

  • Revit Structure 2014, file rst_advanced_sample_project.rvt (exported a 3D view to FBX with default settings)
  • compiled glTF.exe (release x64) in VS2015 (FBX SDK 2015.1, cpprestsdk v2.8.0)

How can I find the cause of this problem? Is it the compiler, the SDK, the Revit model?

Thanks in advance for your help.

Runtime Exception at - bRet =pExporter->Export (_scene) ;

I am using,

  • Visual studio 2013
  • FBX SDK 2016 as 2015 is not available for download

Built was successful but when I run the program it throws exception at

_// The next line will call the exporter
bRet =pExporter->Export (scene) ;
That,
fbxerror2016

Am I missing something obvious? Will I able to export glTF from FBX

Accessor type mismatch

In file IOglTF.h in function

template<class T>
/*static*/ const utility::char_t *IOglTF::accessorType (int size, int dim)

there is an error in line 194, there should be szIVEC4 instead of szIVEC2.

case 4: return (type == FLOAT ? szVEC4 : (type == INT ? szIVEC4 : szBVEC4)) ;

Provide executable directly usable

I work with 3D graphists and try to argue with them to considerate the gltf format as a usable format and as good choice. As it, it is difficult to say than convert to gltf is a easy choice for them.

If a executable exist, at least for windows (linux specialist can compile easily) this could be easiest.

Unable to make linking configuration

Hello,
I am working on custom plugin in my code , When I tried to follow the steps with the downloaded code.. I am not able to combine the code with x64 configuration,

I have given all the linking lib files, include files correctly.

Could you please help me the following error :

Error LNK1107 invalid or corrupt file: cannot read at 0x2E8 IO-glTF C:\Program Files\Autodesk\FBX\FBX SDK\2020.0.1\lib\vs2017\x86\debug\libfbxsdk.dll 1

Kindly advice..

Thanks
Sonal

Unable to compile on OS X 10.10.5

Hey,

i'm not really sure if you can help me out on this, but i'm having trouble getting the converter to work. Unfortunately my knowledge on building applications via command line is rather limited, as i am a graphic designer.

Here's what i did so far, following your instructions:

  1. Downloaded and installed the MAC version of the FBX SDK from Autodesk (http://usa.autodesk.com/adsk/servlet/pc/item?id=24746731&siteID=123112)
  2. Downloaded and installed Casablanca. This was rather complicated, as the master branch would not compile on OS X 10.10, the dev branch did, with minor tweaks. If this is a possible source of the following problems, i can provide detailed instructions on how i managed to install casablanca.
  3. Cloned the FBX-glTF repository (https://github.com/cyrillef/FBX-glTF). created a new folder named build.release inside FBX-glTF-master.
  4. Followed your optional 6th step, copying CMakeConfigExample.txt to my new folder and renaming it to CMakeCache.txt, and editing it to point to the FBX SDK installation.
  5. Opened my build.release folder in Terminal and ran cmake ..
    I'm getting the following output:
-- The C compiler identification is AppleClang 6.0.0.6000038
-- The CXX compiler identification is AppleClang 6.0.0.6000038
-- Check for working C compiler: /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using Casablanca: 
-- Using FBX: /Applications/Autodesk/FBX SDK/2016.1.2
-- Ouput Directory: /Users/tillhinrichs/Documents/_DEVELOPER/glTF/FBX-glTF-master/build.release/Release
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   random
--   chrono
--   system
--   thread
--   locale
--   regex
--   filesystem
-- Setting clang options
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tillhinrichs/Documents/_DEVELOPER/glTF/FBX-glTF-master/build.release

Looks like everything went ok. The build.release folder now contains lots of subfolders:

But now i'm lost. I see there are folder for glTF and IO-glTF, bit no compiled binaries in the Realease folder so far. Within the glTF and IO-glTF folders i find a Makefile and cmake_install.cmake. What do i have to do?

If i run a simple make within the build.release folder, i get an error.

Scanning dependencies of target IO-glTF
[  4%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/dllmain.cpp.o
[  8%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/glslShader.cpp.o
[ 13%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfReader.cpp.o
[ 17%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Asset.cpp.o
[ 21%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Buffer.cpp.o
[ 26%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Camera.cpp.o
[ 30%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Light.cpp.o
[ 34%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Material.cpp.o
[ 39%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Mesh.cpp.o
[ 43%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Null.cpp.o
[ 47%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Program.cpp.o
[ 52%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Scene.cpp.o
[ 56%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Technique.cpp.o
[ 60%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter-Texture.cpp.o
[ 65%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/gltfWriter.cpp.o
[ 69%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/IOglTF.cpp.o
[ 73%] Building CXX object IO-glTF/CMakeFiles/IO-glTF.dir/StdAfx.cpp.o
[ 78%] Linking CXX shared library ../Release/libIO-glTF.dylib
ld: library not found for -lcpprest.2.4
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Release/libIO-glTF.dylib] Error 1
make[1]: *** [IO-glTF/CMakeFiles/IO-glTF.dir/all] Error 2
make: *** [all] Error 2

Can you make any sense of this? I am out of ideas. Thanks in advance!

Error Building FBX-glTF Release

Building on Mac OSX, I've run into this error...

In file included from /Users/ryanbartley/Documents/glTF/FBX2GLTF/FBX-glTF/IO-glTF/glslShader.cpp:22:
/Users/ryanbartley/Documents/glTF/FBX2GLTF/FBX-glTF/IO-glTF/glslShader.h:51:7: error: class member cannot be redeclared
        void appendCode (const utility::char_t *format, ...) ;
             ^
/Users/ryanbartley/Documents/glTF/FBX2GLTF/FBX-glTF/IO-glTF/glslShader.h:50:7: note: previous declaration is here
        void appendCode (const char *format, ...) ;
             ^
/Users/ryanbartley/Documents/glTF/FBX2GLTF/FBX-glTF/IO-glTF/glslShader.cpp:96:18: error: redefinition of 'appendCode'
void glslShader::appendCode (const utility::char_t *format, ...) {
                 ^
/Users/ryanbartley/Documents/glTF/FBX2GLTF/FBX-glTF/IO-glTF/glslShader.cpp:83:18: note: previous definition is here
void glslShader::appendCode (const char *format, ...) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.