Skip to main content

Animation

Struct Animation 

Source
pub struct Animation {
    pub header: AnimationHeader,
    pub joints: Vec<JointData>,
    pub constraints: Vec<Constraint>,
}

Fields§

§header: AnimationHeader§joints: Vec<JointData>§constraints: Vec<Constraint>

Implementations§

Source§

impl Animation

Source

pub fn new() -> Self

Source

pub fn set_priority(&mut self, priority: i32) -> &mut Self

Source

pub fn set_duration(&mut self, duration: f32) -> &mut Self

Source

pub fn set_joint_priority(&mut self, priority: i32) -> &mut Self

Source

pub fn drop_empty_joints(&mut self) -> &mut Self

Source

pub fn drop_position_keys(&mut self) -> &mut Self

Source

pub fn drop_position( &mut self, joints: impl Fn(&JointData) -> bool, ) -> &mut Self

Source

pub fn drop_zero_position_keys(&mut self, epsilon: f32) -> &mut Self

Source

pub fn drop_rotation_keys(&mut self) -> &mut Self

Source

pub fn drop_rotation( &mut self, joints: impl Fn(&JointData) -> bool, ) -> &mut Self

Source

pub fn cleanup_keys(&mut self) -> &mut Self

Source

pub fn cleanup_keys_with(&mut self, strategy: DuplicateKeyStrategy) -> &mut Self

Cleanup duplicate keyframe times with a customizable strategy.

Source

pub fn joint(&self, name: &str) -> Option<&JointData>

Source

pub fn joint_mut(&mut self, name: &str) -> Option<&mut JointData>

Source

pub fn position_reset_from_skeleton<'a>( skeleton: &SkeletonDefinition, joint_names: impl IntoIterator<Item = &'a str>, priority: i32, ) -> Result<Self>

Source

pub fn position_reset_from_bones<'a>( bones: impl IntoIterator<Item = &'a SkeletonBone>, priority: i32, ) -> Result<Self>

Source

pub fn add_skeleton_positions( &mut self, skeleton: &SkeletonDefinition, ) -> Result<&mut Self>

Source

pub fn from_llsd(llsd: &Llsd, check_enabled: bool) -> Result<Self>

Creates an animation from LLSD data, typically from Firestorm poser files.

This function parses LLSD-XML data exported by Firestorm’s poser system and converts it into an animation structure. Firestorm stores pose data in LLSD-XML format in the user’s configuration directory.

§Arguments
  • llsd - The parsed LLSD data containing joint poses
  • check_enabled - If true, only includes joints where the “enabled” field is true
§File Locations

Firestorm poser files are typically found at:

  • Linux: ~/.firestorm_x64/user_settings/poses/
  • Windows: %APPDATA%/Firestorm_x64/user_settings/poses/
  • macOS: ~/Library/Application Support/Firestorm_x64/user_settings/poses/
§Example
use std::fs::File;
use std::io::BufReader;
use avatar_anim::Animation;

// Load LLSD-XML file from Firestorm poses directory
let file = BufReader::new(File::open("my_pose.xml")?);
let llsd = llsd_rs::xml::from_reader(file).map_err(|e| avatar_anim::AnimError::Llsd(e.to_string()))?;

// Convert to animation, including only enabled joints
let animation = Animation::from_llsd(&llsd, true)?;
Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>

Load an animation from a .anim file

§Example
use avatar_anim::Animation;

let animation = Animation::from_file("my_animation.anim")?;
Source

pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Save an animation to a .anim file

§Example
use avatar_anim::Animation;

let animation = Animation::default();
animation.to_file("output.anim")?;
Source

pub fn from_llsd_file<P: AsRef<Path>>( path: P, check_enabled: bool, ) -> Result<Self>

Load LLSD-XML data from a Firestorm pose file

§Example
use avatar_anim::Animation;

let animation = Animation::from_llsd_file("pose.xml", true)?;

Trait Implementations§

Source§

impl BinRead for Animation

Source§

type Args<'a> = ()

The type used for the args parameter of read_args() and read_options(). Read more
Source§

fn read_options<R: Read + Seek>( reader: &mut R, endian: Endian, _args: Self::Args<'_>, ) -> BinResult<Self>

Read Self from the reader using the given Endian and arguments. Read more
Source§

fn read_be<R>(reader: &mut R) -> Result<Self, Error>
where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read Self from the reader using default arguments and assuming big-endian byte order. Read more
Source§

fn read_le<R>(reader: &mut R) -> Result<Self, Error>
where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read Self from the reader using default arguments and assuming little-endian byte order. Read more
Source§

fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read T from the reader assuming native-endian byte order. Read more
Source§

fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
where R: Read + Seek,

Read Self from the reader, assuming big-endian byte order, using the given arguments. Read more
Source§

fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
where R: Read + Seek,

Read Self from the reader, assuming little-endian byte order, using the given arguments. Read more
Source§

fn read_ne_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
where R: Read + Seek,

Read T from the reader, assuming native-endian byte order, using the given arguments. Read more
Source§

impl BinWrite for Animation

Source§

type Args<'a> = ()

The type used for the args parameter of write_args() and write_options(). Read more
Source§

fn write_options<W: Write + Seek>( &self, writer: &mut W, endian: Endian, _args: Self::Args<'_>, ) -> BinResult<()>

Write Self to the writer using the given Endian and arguments. Read more
Source§

fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + Seek, Self::Args<'a>: for<'a> Required,

Write Self to the writer assuming big-endian byte order. Read more
Source§

fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + Seek, Self::Args<'a>: for<'a> Required,

Write Self to the writer assuming little-endian byte order. Read more
Source§

fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + Seek, Self::Args<'a>: for<'a> Required,

Write Self to the writer assuming native-endian byte order. Read more
Source§

fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
where W: Write + Seek,

Write Self to the writer, assuming big-endian byte order, using the given arguments. Read more
Source§

fn write_le_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
where W: Write + Seek,

Write Self to the writer, assuming little-endian byte order, using the given arguments. Read more
Source§

fn write_ne_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
where W: Write + Seek,

Write Self to the writer, assuming native-endian byte order, using the given arguments. Read more
Source§

impl Clone for Animation

Source§

fn clone(&self) -> Animation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Animation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Animation

Source§

fn default() -> Animation

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

impl PartialEq for Animation

Source§

fn eq(&self, other: &Animation) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Animation

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.