GithubHelp home page GithubHelp logo

fbxcel's Introduction

fbxcel

Build Status Latest version Documentation Minimum rustc version: 1.56

fbxcel is an FBX library for Rust programming language.

fbxcel is relatively low-level library. If you want to interpret and render FBX data, use fbxcel-dom crate.

Features

  • Pull parser for FBX binary (pull_parser module)
    • FBX 7.4 and 7.5 is explicitly supported.
  • Writer for FBX binary (writer module)
    • FBX 7.4 and 7.5 is explicitly supported.
    • This is optional and enabled by writer feature.
  • Types and functions for low-level FBX tree access
    • This is optional and enabled by tree feature.
    • Provides arena-based tree type.

FBX versions

  • FBX 6 or below is not supported.
  • FBX 7.0 to 7.3 is not explicitly supported, but you can try FBX 7.4 feature to load them.
  • FBX 7.4 and 7.5 is supported.

FBX format

Only FBX binary format is supported.

Currently there is no plan to support FBX ASCII format.

Rust version

Latest stable compiler (currently 1.52) is supported.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

fbxcel's People

Contributors

lo48576 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

Watchers

 avatar  avatar

fbxcel's Issues

Invalid encoding error

Hello,
I'm trying to parse some FBX files and getting the following error:

FBX version: 7.4
Failed to parse FBX file, Data error: Invalid node name encoding: FromUtf8Error { bytes: [105, 110, 97, 114, 121, 32, 32, 0, 26, 0, 232, 28, 0, 0, 98, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 70, 66, 88, 72, 101, 97, 100, 101, 114, 69, 120, 116, 101, 110, 115, 105, 111, 110, 92, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 16, 70, 66, 88, 72, 101, 97, 100, 101], error: Utf8Error { valid_up_to: 10, error_len: Some(1) } }

I'm using the (almost) exact same code as the example, with FBX files generated by Blender2.8.
Only noticeable difference is that I use the from_reader function cause I'm in a web-assembly context, so I can't use any io::*.

Tested with 2 files, both of them load properly in other softwares (not only Blender).

I'd be happy to contribute if you have a clue that can point me to the right direction :)

hello, does it able to rename SMPL fbx model and save it?

Hi, this lib looks like only one active fbx parse lib in rust, however, does there demos on how can I rename all bone names inside a fbx and save it without change anything else?

Meanwhile it would be better to retarget the animations as well

Unable to import fbx from blender 2.79/2.8

Hello, so I've been playing around with fbxcel and fbxcel_dom to try and import fbx files from blender

I encountered an error during an import of a test scene

Tree(Tree(Parser(Error { repr: Repr { error: Data(NodeLengthMismatch(9687, None)), position: Some(SyntacticPosition { byte_pos: 9687, component_byte_pos: 9662, node_path: [(8, "Objects"), (0, "NodeAttribute"), (1, "Properties70")], attribute_index: None }) } })))
thread 'example::fbx::load_fbx_rigged' panicked at 'Fail to load rigged fbx: BadParsing', src\libcore\result.rs:1165:5
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.37\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:76
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:60
   3: core::fmt::write
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\fmt\mod.rs:1030
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\io\mod.rs:1412
   5: std::sys_common::backtrace::_print
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:64
   6: std::sys_common::backtrace::print
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:49
   7: std::panicking::default_hook::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:196
   8: std::panicking::default_hook
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:210
   9: std::panicking::rust_panic_with_hook
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:473
  10: std::panicking::continue_panic_fmt
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:380
  11: std::panicking::rust_begin_panic
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:307
  12: core::panicking::panic_fmt
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\panicking.rs:85
  13: core::result::unwrap_failed
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\result.rs:1165
  14: core::result::Result<fbxcel_dom::v7400::document::Document, alers::resource::fbx::LoadError>::expect<fbxcel_dom::v7400::document::Document,alers::resource::fbx::LoadError>
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libcore\result.rs:960
  15: bin::example::fbx::load_fbx_rigged
             at .\src\app\example\fbx.rs:25
  16: bin::example::fbx::load_fbx_rigged::{{closure}}
             at .\src\app\example\fbx.rs:22
  17: core::ops::function::FnOnce::call_once<closure-0,()>
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libcore\ops\function.rs:227
  18: alloc::boxed::{{impl}}::call_once<(),FnOnce<()>>
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\liballoc\boxed.rs:922
  19: panic_unwind::__rust_maybe_catch_panic
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libpanic_unwind\lib.rs:80
  20: std::panicking::try
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libstd\panicking.rs:271
  21: std::panic::catch_unwind
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libstd\panic.rs:394
  22: test::run_test::run_test_inner::{{closure}}
             at /rustc/4560ea788cb760f0a34127156c78e25

52949f734\/src\libtest\lib.rs:1413

The scene in question is a simple cylinder with a rigged bone
https://github.com/andreasterrius/alers/blob/debug/fbx-loader/cylinder_rig.blend

This is the exported fbx
https://github.com/andreasterrius/alers/blob/debug/fbx-loader/cylinder_rig.fbx

Weirdly, when I imported the fbx back into blender it works and I noticed that blender added an extra bone on top of the existing one. I am not entirely sure why since I'm not well versed in this field. Maybe it added an extra bone during the import process ?
If I export the scene that was imported by blender as fbx again, I can load it using fbxcel_dom, which leads me to to think that it might be the blender exporter that didn't write the fbx properly during the first export.

Video Content attribute missing for 7.7 model

Hi, I'm trying to load a model, which when loaded with blender does have textures, but when I'm loading it with fbxcel I'm missing a texture. When doing a dump I can see that one of the video nodes is missing a binary attribute on the content node:

     Video I64(88248016), String("vanguard_vanguard_diffuse_tga\0\u{1}Video"), String("Clip")
       Type String("Clip")
       Properties70 
         P String("Path"), String("KString"), String("XRefUrl"), String(""), String("/home/app/mixamo-mini/tmp/skins_7dd7371a-8200-435c-9d7d-9d7ab1caebc2.fbm/vanguard_diffuse1.png")
         P String("RelPath"), String("KString"), String("XRefUrl"), String(""), String("../../../../home/app/mixamo-mini/tmp/skins_7dd7371a-8200-435c-9d7d-9d7ab1caebc2.fbm/vanguard_diffuse1.png")
       UseMipMap I32(0)
       Filename String("/home/app/mixamo-mini/tmp/skins_7dd7371a-8200-435c-9d7d-9d7ab1caebc2.fbm/vanguard_diffuse1.png")
       RelativeFilename String("../../../../home/app/mixamo-mini/tmp/skins_7dd7371a-8200-435c-9d7d-9d7ab1caebc2.fbm/vanguard_diffuse1.png")
       Content 

(I.e. there are no attributes after Content. It should look something like this: Content Binary([137, 80, 78, 71, 13,...)

Some of the other ones do seem to work though. I'm not sure if this is because it's 7.7 (rather than 7.5)? I've attached the model and a dump of the model.

Vanguard By T. Choonyung Binary.fbx.txt.zip
Vanguard By T. Choonyung Binary.fbx.zip

External tree crates support

Just an idea.

Currently, fbxcel provides its own tree and node types to disconnect updates from breaking changes in dependencies. Internally these types are thin wrapper over types of indextree (v4) crate and some internal caching added, and they exports the methods from indextree crate again.

The idea is, this crate can optionally support (possibly) multiple crates for tree structure, and let users use them instead. This will reduce maintainance burden of the custom wrapper types, and will make the data manipulation more flexible. For example, some may share arena-style tree among multiple threads, or some may use reference-counted node types.

Modifying `Tree`

My workflow involves reading a FBX file into a Tree, traversing through it and making some modifications(adding nodes,changing attributes) to the Tree and writing this modified tree into a new FBX file. Right now there's only a method to add new attributes, but none to change the existing ones.

Ideal way to go about this would be something like,

for node in tree.traverse_mut() {
  if node.name() == "Count" {
      let attrs: &mut Vec<AttributeValues> = node.get_mut_attributes();
      // Update the attributes
      attrs[1] = AttributeValue::I32(260);
  }
}

I would like to implement this, but I am not sure how to go about it.

  • For traversal, there's indextree::Traverse but it doesn't allow for mutation.
  • For attributes, a function similar to append_attribute() could be added. But that wouldn't work with the traverse_mut() in the above example, as both would require a &mut Tree

example error

the example's code can not be build in my proejct:

error[E0433]: failed to resolve: could not find `tree` in `fbxcel`
 --> src/fbx_parser.rs:4:13
  |
4 | use fbxcel::tree::any::AnyTree;
  |             ^^^^ could not find `tree` in `fbxcel`

load an FBX, modify it, then export it

I see that there is a reader and a writer, but it seems like the reader and writer are detached and cannot be converted. This means that for the writer you have to start from a blank object and then perhaps copy across each node or something?

Is there an easy way to read in an FBX file, modify it slightly, then output it again?

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.