#736: import FBX 3D models (binary and ASCII)
Problem: After Effects 26 imports FBX models into Advanced 3D comps; File > Import rejected .fbx, so FBX product shots and scenes could not be used. Fix: a clean-room FBX 7.x reader in effectcraft-model (binary node records with 32/64-bit offsets and zlib arrays, ASCII syntax) and a scene builder: meshes with normals, UVs and per-polygon materials, the Model hierarchy with the SDK transform (pivots, offsets, pre/post rotation, rotation order, geometric transform), Lambert/Phong materials onto metallic-roughness with embedded or relative textures, and GlobalSettings axes turned to Y-up. Wired into import, probing, the media browser and the file dialog. Hostile input (truncation, corruption, huge arrays, deep nesting) fails with an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9a7d3e7699
commit
977532f135
@@ -5,6 +5,8 @@
|
||||
//! metallic-roughness, normal, occlusion and emissive maps), the node hierarchy, skins and
|
||||
//! animations.
|
||||
//! - [`obj`]: Wavefront OBJ geometry with MTL materials (mapped onto the metallic-roughness model).
|
||||
//! - [`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.
|
||||
@@ -15,6 +17,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;
|
||||
@@ -720,13 +723,14 @@ 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`), by extension.
|
||||
/// Which loader handles a file name (`gltf`, `glb`, `obj`, `fbx`), by extension.
|
||||
pub fn format_of(path: &str) -> Option<&'static str> {
|
||||
let ext = path.rsplit('.').next()?.to_ascii_lowercase();
|
||||
match ext.as_str() {
|
||||
"gltf" => Some("gltf"),
|
||||
"glb" => Some("glb"),
|
||||
"obj" => Some("obj"),
|
||||
"fbx" => Some("fbx"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -736,9 +740,11 @@ pub fn format_of(path: &str) -> Option<&'static str> {
|
||||
pub fn load(path: &str, bytes: &[u8], resolve: &dyn Fn(&str) -> Option<Vec<u8>>) -> Result<Model> {
|
||||
match format_of(path) {
|
||||
Some("obj") => obj::parse(bytes, resolve),
|
||||
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 or OBJ file"))),
|
||||
None if bytes.starts_with(fbx::BINARY_MAGIC) => fbx::parse(bytes, resolve),
|
||||
None => Err(ModelError::Unsupported(format!("{path}: not a glTF, OBJ or FBX file"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user