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>
impl<'a> Animation<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
Parse a cooked .psxanim blob.
Sourcepub fn joint_count(&self) -> u16
pub fn joint_count(&self) -> u16
Number of joint poses per frame.
Sourcepub fn frame_count(&self) -> u16
pub fn frame_count(&self) -> u16
Number of sampled frames.
Sourcepub fn sample_rate_hz(&self) -> u16
pub fn sample_rate_hz(&self) -> u16
Integer sample rate in Hz.
Sourcepub fn pose_record_size(&self) -> usize
pub fn pose_record_size(&self) -> usize
Byte size of one stored pose record.
Sourcepub fn translation_shift(&self) -> u8
pub fn translation_shift(&self) -> u8
Shared right shift used by compact v2 stored translations.
Sourcepub fn phase_step_q12(&self, playback_hz: u16) -> u32
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).
Sourcepub fn phase_at_tick_q12(&self, playback_tick: u32, playback_hz: u16) -> u32
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.
Sourcepub fn phase_at_tick_scaled_q12(
&self,
playback_tick: u32,
playback_hz: u16,
speed_q8: u16,
) -> u32
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.
Sourcepub fn pose(&self, frame_index: u16, joint_index: u16) -> Option<JointPose>
pub fn pose(&self, frame_index: u16, joint_index: u16) -> Option<JointPose>
Joint pose at frame_index, joint_index.
Sourcepub fn pose_looped_q12(
&self,
frame_q12: u32,
joint_index: u16,
) -> Option<JointPose>
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.
Sourcepub fn looped_pose_sample_q12(
&self,
frame_q12: u32,
) -> Option<AnimationPoseSample<'a>>
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§
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)