Skip to main content

Crate openusd

Crate openusd 

Source
Expand description

Native Rust implementation of Universal Scene Description (USD).

The crate aims for full feature parity with the C++ reference implementation, and is structured to mirror its layout, so developers familiar with the C++ codebase will find roughly the same modules, types, and primitives (sdf, pcp, usd, …).

All major file formats are supported — text (.usda), binary (.usdc), and archives (.usdz) — with no C++ dependencies.

§Modules

ModulePurpose
sdfCore data model — Value, Path, Spec, AbstractData trait, mutable Data, and schema field keys.
usdaText format. TextReader parses and TextWriter emits .usda files.
usdcBinary format. CrateData parses and CrateWriter emits .usdc files.
usdzArchive format. Archive reads and ArchiveWriter emits .usdz packages.
arAsset resolution. Resolver trait maps asset paths (@...@) to physical locations; DefaultResolver searches the filesystem.
layerLayer collection. Collector recursively loads all layers from a root file.
pcpPrim Cache Population — the composition engine. Implements LIVRPS strength ordering, per-prim index caching, and namespace mapping via MapFunction.
usdComposed stage API. Stage merges opinions across layers using LIVERPS strength ordering.
gfGraphics foundations — linear algebra types (Vec3f, Matrix4d, …).
schemasDomain-schema readers (UsdPhysics, UsdSkel, …) — non-core extensions, feature-gated.

§Quick start

Open a stage and walk its composed prims (DEFAULT prunes inactive, unloaded, and abstract subtrees):

use openusd::usd;

let stage = usd::Stage::open("scene.usda")?;
stage.traverse(usd::PrimPredicate::DEFAULT, |prim_path| {
    println!("{prim_path}");
})?;

Query the composed scene through UsdPrim / UsdAttribute-style handles and resolve an attribute’s value across all composition arcs:

use openusd::usd;

let stage = usd::Stage::open("scene.usda")?;

let sphere = stage.prim_at("/World/Sphere");
println!("type: {:?}", sphere.type_name()?);

let radius = stage.attribute_at("/World/Sphere.radius");
if let Some(r) = radius.get::<f64>()? {
    println!("radius = {r}");
}

Author a scene in memory, then read a value back — no files involved:

use openusd::usd;

let stage = usd::Stage::builder().in_memory("root.usda")?;

stage.define_prim("/World")?.set_type_name("Xform")?;
stage.define_prim("/World/Sphere")?.set_type_name("Sphere")?;
stage.set_default_prim("World")?;

stage.create_attribute("/World/Sphere.radius", "double")?.set(2.5_f64)?;
let radius = stage.attribute_at("/World/Sphere.radius").get::<f64>()?;
assert_eq!(radius, Some(2.5));

Configure how a stage is opened through StageBuilder — restrict population to a subtree, leave payloads unloaded, and inspect any recoverable composition errors collected while loading:

use openusd::usd;

let stage = usd::Stage::builder()
    .mask(usd::StagePopulationMask::new(["/World/Hero"]))
    .load(usd::InitialLoadSet::LoadNone)
    .open("scene.usda")?;

for err in stage.composition_errors() {
    eprintln!("warning: {err}");
}

Re-exports§

pub use layer::Collector;
pub use layer::DependencyKind;

Modules§

ar
Asset resolution framework.
gf
Graphics foundations — linear algebra types used by the schema layer.
layer
Layer stack collection.
pcp
Prim Cache Population (PCP) — the composition engine.
schemas
Domain-schema readers — the non-core extensions that ride on top of the spec-level sdf / usd machinery.
sdf
Scene description foundations.
usd
High-level USD composition and authoring APIs.
usda
Text file format (usda) reader.
usdc
Binary file format (usdc) implementation.
usdz
USDZ archive format reader and writer.