Skip to main content

UsdaWriter

Struct UsdaWriter 

Source
pub struct UsdaWriter { /* private fields */ }
Expand description

USDA text format writer.

Builds a .usda file incrementally. Call methods in the order dictated by the USD hierarchy you wish to produce, then call finish to obtain the final string.

Implementations§

Source§

impl UsdaWriter

Source

pub fn new() -> Self

Create a new, empty writer.

Source

pub fn write_header(&mut self, up_axis: &str, meters_per_unit: f64)

Write the USDA file header with layer metadata.

up_axis should be "Y" or "Z".

Source

pub fn begin_def(&mut self, kind: &str, name: &str)

Open a def <kind> "<name>" { ... } block.

Source

pub fn end_def(&mut self)

Close the most recent def block.

Source

pub fn write_mesh(&mut self, mesh: &UsdMesh) -> Result<()>

Write a complete Mesh prim.

Source

pub fn write_material(&mut self, mat: &UsdMaterial) -> Result<()>

Write a Material prim with a UsdPreviewSurface shader.

Source

pub fn write_skeleton(&mut self, skel: &UsdSkeleton) -> Result<()>

Write a Skeleton prim.

Source

pub fn write_skin_binding( &mut self, mesh_path: &str, binding: &UsdSkinBinding, ) -> Result<()>

Write skin binding properties on an existing mesh prim.

This writes a SkelBindingAPI block that should appear inside or adjacent to the mesh prim identified by mesh_path.

Source

pub fn write_blend_shapes( &mut self, mesh_path: &str, shapes: &[UsdBlendShape], ) -> Result<()>

Write blend shape prims under the given mesh path scope.

Source

pub fn write_xform(&mut self, name: &str, matrix: &[f64; 16]) -> Result<()>

Write an Xform prim with a 4x4 transform matrix.

Source

pub fn finish(self) -> String

Consume the writer and return the complete USDA string.

Any unclosed def blocks are closed automatically.

Source§

impl UsdaWriter

Source

pub fn write_blend_shape_animation( &mut self, mesh_path: &str, samples: &[BlendShapeTimeSamples], ) -> Result<()>

Write a SkelAnimation prim with blendShapeWeights.timeSamples.

The prim is named "BodyAnim" and contains:

  • uniform token purpose = "default"
  • uniform token[] blendShapes — ordered by first appearance across all BlendShapeTimeSamples entries.
  • float[] blendShapeWeights.timeSamples — every unique time code from all samples, sorted ascending; shapes absent at a given time emit 0.0.
  • rel skelTargets = <{mesh_path}> — where mesh_path is the USD scene path passed as the second argument (e.g. "/Root/Body").
§Errors

Returns an error if formatting the output buffer fails (highly unlikely in practice because String::write_fmt is infallible for in-memory buffers, but the method signature is anyhow::Result<()> for consistency with the rest of the writer API).

Trait Implementations§

Source§

impl Default for UsdaWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.