Giter VIP home page Giter VIP logo

usdfbx's Introduction

usdFbx

This project is an SdfFileFormat plugin for USD to enable loading and composing of Autodesk Fbx files inside USD layers. The project configures a standalone version and/or a plugin built specifically for Houdini.

MayaUSD is supported, but only a locally built version of MayaUSD has been tested so far. Using the USD libraries that come with published builds of MayaUSD should theoretically work; however, this is uncharted territory.

The plugin is based on the Alembic example bundled with the USD sources so there are a lot of similarities. In the future, this project may receive a refactor to simplify things.

Capabilities and Limitations

  1. Support for the following FBX Node Types
    • FbxNodeAttribute::eNull
    • FbxNodeAttribute::eMesh
    • FbxNodeAttribute::eSkeleton
    • FbxNodeAttribute::eCamera
  2. FBX Phong/Lambert materials are converted to UsdPreviewSurface configurations, hardware shaders are not currently supported
  3. Custom FBX Properties convert into USD properties prefixed with the userProperties: property namespace. The Custom Metadatatum will also be set for these
  4. While access to the fileformat itself by USD is multithreaded, any dealings with the FBX SDK itself is single threaded at the moment
  5. Per bone animated properties are recorded to a set of custom properties onto a UsdSkelAnim prim
  6. The plugin does not and will not support any writing capabilities back into FBX from USD. Editing FBX data is recommended to be done on a new sublayer/edittarget
  7. All FBX scenes will be converted to Y-up, 0.01 metersPerUnit (cm)

Requirements

Software/Library Version
USD 22.08 or later
Python 3.7+
C++ Compiler Visual Studio (Win), Gcc (Linux), Xcode (Mac)
CMAKE 3.20+
Fbx SDK 2017.1+ (2020.x is recommended)
[Tests Only] Fbx Python Bindings Any that works with the Python version used
[Houdini Only] Houdini Developer Kit 19.0+

Compiling

The project has been configured with CMAKE, configuration can be done via command line, CMAKE GUI or inside IDEs with integrated CMAKE support.

The important CMAKE Variables to set are

  • PXR_USD_LOCATION: Root directory of the installed USD distribution
  • ADSK_FBX_LOCATION: Root Directory of the C++ FBX SDK
  • USDFBX_BUILD_TESTS: Setting this to ON will create a unit_tests target
  • SIDEFX_HDK_LOCATION: Root Directory of the Houdini Development Kit. When setting this, a new target called usdFbx_houdini will be added

Note on Python

It is recommended to activate and use a Python Virtual Environment (venv, pipenv, conda, etc.) prior to running the CMAKE configuration. When doing so, it's best to pass -DPython_FIND_VIRTUALENV=ONLY to the CMAKE command to minimize any issues with CMAKE's FindPython

Note on USDFBX_BUILD_TESTS

The configuration will check for the existence of pytest on current path. Therefor it is recommended to use a Python Virtual Environment (pipenv to make it easy) prior to configuring with this flag enabled.

Examples

Basic

cmake -B build -G "Visual Studio 17 2022" -T host=x64 -A x64 -DPXR_USD_LOCATION="C:\USD\23.05" -DADSK_FBX_LOCATION="C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4" -DCMAKE_INSTALL_PREFIX="$(Resolve-Path .)\install"

Using Pipenv

pipenv --python 3.9
pipenv install pytest pytest-order python-dotenv pytest-mock
pipenv install <PATH TO FBX SDK PYTHON PACKAGE>
pipenv shell
cmake -B build -G "Visual Studio 17 2022" -T host=x64 -A x64 -DPXR_USD_LOCATION="C:\USD\23.05" -DADSK_FBX_LOCATION="C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4" -DPython_FIND_VIRTUALENV=ONLY -DUSDFBX_BUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX="$(Resolve-Path .)\install" 

Running Tests

Tests have been written in pytest and requires a Python environment with the following dependencies installed:

With this environment active, running the tests can be done by using CMAKE via the unit_tests target

cmake --build ./build --config RelWithDebInfo --target unit_tests -j 32

Or manually by invoking pytest tests.

When running tests manually however, it is important that you have the following environment variables set correctly:

  • PYTHONPATH: <USD_DIR>/lib/python
  • PATH: <USD_DIR>/lib;<USD_DIR>/bin;${PATH}
  • PXR_PLUGINPATH_NAME: <USDFBX_DIR>/build/plugins/usdFbx/<CONFIG>/resources

Where <USD_DIR> is the location of where USD has been installed to, <USDFBX_DIR> is the local clone of this repository and <CONFIG> is the configuration used to build usdFbx.
The CMAKE unit_tests target does all of the above automatically

📝 NOTE
Most test fixtures generate Fbx data rather than rely on static data. For that, you must have the Fbx python SDK (not the bindings) in PYTHONPATH somewhere or have it installed in your environment.

Using the Plugin

Both examples below use the following USD Layer

#usda 1.0

def "y_up_cm"
(
    prepend references = @./suzanne_y_up_cm.fbx@
)
{
}

Where suzanne_y_up_cm.fbx is a Y-Up, cm scale FBX export of Blender's Suzanne mascot.

When using the Python/C++ API for USD you may also simply use Usd.Stage.Open("suzanne_y_up_cm.fbx")/UsdStage::Open("suzanne_y_up_cm.fbx") rather than wrapping in a native USD layer.

USDVIEW

Add <PATH TO INSTALLED USDFBX/RESOURCES> to your PXR_PLUGINPATH_NAME environment variable in addition to setting up a shell the normal way for using USD. After this run usdview <PATH TO LAYER> where <PATH TO LAYER> points to for example the layer mentioned above.

📝 NOTE
If your build of USD has changed the plugin search environment variable, use that instead of PXR_PLUGINPATH_NAME!

📝 WINDOWS ONLY
Currently, the FBX SDK is dynamically linked, meaning that you must also add <PATH TO INSTALLED USDFBX> to your PATH environment variable! Not doing so will result in moduleNotFound errors.

HOUDINI

📝 NOTE
You must have configured CMAKE with SIDEFX_HDK_LOCATION to be able to use the Houdini plugin!

Simply add <PATH TO INSTALLED USDFBX_HOUDINI/RESOURCES> to your PXR_PLUGINPATH_NAME environment variable and launch Houdini from the same shell. You can then add a reference/sublayer/etc... the layer above, or point directly to an fbx.

usdfbx's People

Contributors

kminnaert avatar benoithudson avatar

Stargazers

 avatar thomas avatar  avatar Anton Tutarinov avatar  avatar  avatar wes avatar mcoms avatar  avatar Jonas Sorgenfrei avatar fish avatar BinBinMind avatar AreChen avatar GUOHUI_WU avatar  avatar  avatar  avatar BenzzZX avatar 王健 avatar Adam Lash avatar Nate Allison avatar JT5D avatar Ivan Sharko avatar Steve J. Cai avatar Brian Gyss avatar Benjamin Stanley avatar Antoine Pilote avatar  avatar Alson Entuna avatar Christian Korneck avatar Corentin Demougeot avatar Loïc Pinsard avatar Paul Golter avatar  avatar Ichinose avatar Nicholas Stevenson avatar @racascou avatar Aditia A. Pratama avatar Andre LaBranche avatar King Lew avatar  avatar Mikael K. avatar Wendell avatar Lucas Brown avatar Michael Wolf avatar Nolram avatar Mark Titchener avatar Julien Delezenne avatar Josef Wienerroither avatar hanyangl5 avatar Aleksey Pindrus avatar Thomas Kumlehn avatar  avatar Lucas Morante avatar Alexey Menshikov avatar Andrew Bell avatar Juan Luis Morales Jimenez avatar Johnny Wu avatar John Docter avatar Stelios Petrakis avatar Megumi Ando avatar Matt Johnson avatar Gan Jun Kai avatar sho7noka avatar  avatar  avatar  avatar Shea Richardson avatar Montague Moran avatar Richard Frost avatar  avatar  avatar  avatar Miquel Campos avatar Nick Porcino avatar Jing Zhang avatar jonn avatar  avatar Hasiel Alvarez avatar Chen Tao avatar Hal avatar Tack2 avatar xtvjxk avatar  avatar  avatar Simon avatar Amy "Skye" S.L. avatar Colin Nguyen avatar Mel Massadian avatar Tim Lehr avatar Lee Dunham avatar Erika Tschinkel avatar Frieder Erdmann avatar  avatar Tomás Poveda avatar Fabian Geisler avatar Manuel Köster | shadesoforange avatar  avatar

Watchers

Nick Porcino avatar Megumi Ando avatar  avatar Michael Blain avatar

usdfbx's Issues

If UV set name contains a full stop, it crashes the Python interpreter

We encountered a crash when opening an fbx scene containing a uv set with a "." in the name.

Quick repro:

  • Create a cube in Maya
  • Add a second Uv Set named UvSet.001
  • Make sure it has faces assigned (create an automatic layout)
  • Export the cube as fbx file
  • In Python try to open the fbx from Usd
from pxr import Usd
Usd.Stage.Open("cube.fbx")
  • Observe the interpreter crashing

(slightly) relevant - .binFBX Format

hey hey! is this the same format used for Alan Wake 2 assets? would one (theoretically) be able to use this repository to help reverse engineer the binfbx format to help import/export meshes and assets for the sake of mods? please let me know if this does not belong here or if it violates some copyright laws or something; i wanted to contact Kristof personally but his linked twitter is inactive and has DMs off :(

How to set the CONFIG expression?

Hello,

I am trying to build the project under Windows, and I get this output in the shell:

(.venv) D:\projects\git\usdFBX>cmake -B build -G "Visual Studio 17 2022" -T host=x64 -A x64 -DPXR_USD_LOCATION="D:\projects\git\USD_Test\usd" -DADSK_FBX_LOCATION="C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4" -DPython_FIND_VIRTUALENV=ONLY
 -DUSDFBX_BUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX="$(Resolve-Path .)\install"
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- USD include dir: D:/projects/git/USD_Test/usd/include
-- USD library dir: D:/projects/git/USD_Test/usd/lib
-- USD version: 0.24.3
-- Compiler name: vs2022
-- Search path: C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4/lib/vs2022/x64/$<IF:$<CONFIG:Debug>,debug,release>
-- Looking for FBX in : C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4
-- Fbx Library: C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4/lib/vs2022/x64/$<IF:$<CONFIG:Debug>,debug,release>/libfbxsdk.lib
-- FBX_LIB_PATH: C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4/lib/vs2022/x64/$<IF:$<CONFIG:Debug>,debug,release>
-- FBX DLL: C:\Program Files\Autodesk\FBX\FBX SDK\2020.3.4/lib/vs2022/x64/$<IF:$<CONFIG:Debug>,debug,release>/libfbxsdk.dll
-- POST BUILD COPY TO D:/projects/git/usdFBX/build/src/libfbxsdk.dll
-- PYTEST has been found
-- Configuring done (0.9s)
-- Generating done (0.1s)
-- Build files have been written to: D:/projects/git/usdFBX/build

I am not familiar with cmake, and apart from the forward and backslashes (which can be normalized with cmake_path), I have the following question:

How do I set the CONFIG expression?

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.