Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Animation

Struct Animation 

Source
pub struct Animation<'a> { /* private fields */ }
Expand description

A parsed rigid-skeletal animation backed by slices into the caller’s cooked .psxanim blob.

Implementations§

Source§

impl<'a> Animation<'a>

Source

pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>

Parse a cooked .psxanim blob.

Source

pub fn joint_count(&self) -> u16

Number of joint poses per frame.

Source

pub fn frame_count(&self) -> u16

Number of sampled frames.

Source

pub fn sample_rate_hz(&self) -> u16

Integer sample rate in Hz.

Source

pub fn pose_record_size(&self) -> usize

Byte size of one stored pose record.

Source

pub fn translation_shift(&self) -> u8

Shared right shift used by compact v2 stored translations.

Source

pub fn phase_step_q12(&self, playback_hz: u16) -> u32

Q12 sampled-frame phase advance for one playback tick.

playback_hz is the caller’s update cadence. For example, a 15 Hz cooked clip played by a 30 Hz update loop advances by half a sampled frame per tick (0x0800).

Source

pub fn phase_at_tick_q12(&self, playback_tick: u32, playback_hz: u16) -> u32

Convert a fixed-rate playback tick to a Q12 sampled-frame phase.

This is a convenience for frame-locked demos. More advanced scenes can accumulate Animation::phase_step_q12 themselves when playback speed, pausing, or elapsed-time correction matters.

Source

pub fn phase_at_tick_scaled_q12( &self, playback_tick: u32, playback_hz: u16, speed_q8: u16, ) -> u32

Like Animation::phase_at_tick_q12 but scales the advance by a Q8 speed multiplier (256 = 1.0x): < 256 plays slower, > 256 faster. Scaling the per-tick step rather than the accumulated phase keeps looping wrap-around identical to unscaled playback.

Source

pub fn pose(&self, frame_index: u16, joint_index: u16) -> Option<JointPose>

Joint pose at frame_index, joint_index.

Source

pub fn pose_looped_q12( &self, frame_q12: u32, joint_index: u16, ) -> Option<JointPose>

Interpolated looping joint pose at a Q12 fixed-point frame phase.

frame_q12 uses sampled animation frames as the integer unit and 12 fractional bits. For example, 1 << 12 samples frame 1 exactly, while 1 << 11 samples halfway between frames 0 and 1. The cooker writes endpoint-inclusive clips, so looping playback treats the final stored frame as the duplicate of frame 0 and blends frame_count - 2 back to frame 0.

Source

pub fn looped_pose_sample_q12( &self, frame_q12: u32, ) -> Option<AnimationPoseSample<'a>>

Precomputed looping frame pair for sampling multiple joints at the same animation phase.

Renderers should prefer this when walking every joint in a model: the expensive loop-frame modulo and alpha calculation happens once per draw instead of once per joint.

Trait Implementations§

Source§

impl<'a> Clone for Animation<'a>

Source§

fn clone(&self) -> Animation<'a>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Animation<'a>

Source§

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

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

impl<'a> Copy for Animation<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Animation<'a>

§

impl<'a> RefUnwindSafe for Animation<'a>

§

impl<'a> Send for Animation<'a>

§

impl<'a> Sync for Animation<'a>

§

impl<'a> Unpin for Animation<'a>

§

impl<'a> UnsafeUnpin for Animation<'a>

§

impl<'a> UnwindSafe for Animation<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.