Merge pull request #742 from vangel76/gap-fbx-import
#736: import FBX 3D models (binary and ASCII) # Conflicts: # crates/engine/src/commands/app_more.rs # crates/engine/src/commands/model3d.rs # crates/engine/src/media_browser.rs # crates/media/src/lib.rs # crates/media/src/probe.rs # crates/model/Cargo.toml # crates/model/src/lib.rs # crates/ui-egui/src/menus.rs # docs/file-format-parity.md # docs/gaps.md
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
//! animations.
|
||||
//! - [`obj`]: Wavefront OBJ geometry with MTL materials (mapped onto the metallic-roughness model).
|
||||
//! - [`stl`]: STL meshes (binary and ASCII, with the binary per-facet and part colours).
|
||||
//! - [`fbx`]: FBX 7.x scenes, binary and ASCII: meshes, the Model hierarchy, Lambert/Phong
|
||||
//! materials and their textures.
|
||||
//! - [`prim`]: parametric primitives (cube, sphere, plane, torus, cone, cylinder).
|
||||
//! - [`extrude`]: extruded, bevelled meshes from 2D outlines (text and shape layers), with
|
||||
//! [`triangulate`] for the caps.
|
||||
@@ -16,6 +18,7 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
pub mod extrude;
|
||||
pub mod fbx;
|
||||
pub mod gltf;
|
||||
pub mod obj;
|
||||
pub mod prim;
|
||||
@@ -722,7 +725,7 @@ pub fn skin_point(inst: &Instance, p: &Primitive, k: usize, v: [f32; 3]) -> [f64
|
||||
[q.x, q.y, q.z]
|
||||
}
|
||||
|
||||
/// Which loader handles a file name (`gltf`, `glb`, `obj`, `stl`), by extension.
|
||||
/// Which loader handles a file name (`gltf`, `glb`, `obj`, `stl`, `fbx`), by extension.
|
||||
pub fn format_of(path: &str) -> Option<&'static str> {
|
||||
let ext = path.rsplit('.').next()?.to_ascii_lowercase();
|
||||
match ext.as_str() {
|
||||
@@ -730,6 +733,7 @@ pub fn format_of(path: &str) -> Option<&'static str> {
|
||||
"glb" => Some("glb"),
|
||||
"obj" => Some("obj"),
|
||||
"stl" => Some("stl"),
|
||||
"fbx" => Some("fbx"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -740,9 +744,11 @@ pub fn load(path: &str, bytes: &[u8], resolve: &dyn Fn(&str) -> Option<Vec<u8>>)
|
||||
match format_of(path) {
|
||||
Some("obj") => obj::parse(bytes, resolve),
|
||||
Some("stl") => stl::parse(bytes),
|
||||
Some("fbx") => fbx::parse(bytes, resolve),
|
||||
Some(_) => gltf::parse(bytes, resolve),
|
||||
None if bytes.starts_with(b"glTF") => gltf::parse(bytes, resolve),
|
||||
None => Err(ModelError::Unsupported(format!("{path}: not a glTF, OBJ or STL file"))),
|
||||
None if bytes.starts_with(fbx::BINARY_MAGIC) => fbx::parse(bytes, resolve),
|
||||
None => Err(ModelError::Unsupported(format!("{path}: not a glTF, OBJ, STL or FBX file"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user