pub struct Context<'a> { /* private fields */ }Expand description
The playback state of one animated object: a stack of tracks, each playing an
animation of the bound resource, layered onto the setup pose. Bind a resource
with Self::bind_resource and select an animation with
Self::setup_animation before playing.
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn get_frame_data_ptr(&self) -> *const u8
pub fn get_frame_data_ptr(&self) -> *const u8
Pointer to the frame data built by the last get_frame_data call,
without re-evaluating it. Null until the first call, and again after
reset / bind_resource; valid until the next get_frame_data.
Sourcepub fn get_frame_data_len(&self) -> usize
pub fn get_frame_data_len(&self) -> usize
Byte length of the buffer get_frame_data_ptr points at.
pub fn get_world_matrices_ptr(&self) -> *const f32
pub fn get_world_matrices_len(&self) -> usize
pub fn get_local_uvs_ptr(&self) -> *const f32
pub fn get_local_uvs_len(&self) -> usize
pub fn get_shape_vertices_ptr(&self) -> *const f32
pub fn get_shape_vertices_len(&self) -> usize
pub fn get_shape_vertex_box_coords_ptr(&self) -> *const f32
pub fn get_shape_vertex_box_coords_len(&self) -> usize
pub fn get_shape_vertex_counts_ptr(&self) -> *const i32
pub fn get_mesh_vertices_x_ptr(&self) -> *const f32
pub fn get_mesh_vertices_x_len(&self) -> usize
pub fn get_mesh_vertices_y_ptr(&self) -> *const f32
pub fn get_mesh_vertices_y_len(&self) -> usize
pub fn get_mesh_vertex_offsets_ptr(&self) -> *const u32
pub fn get_mesh_vertex_offsets_len(&self) -> usize
pub fn get_mesh_uvs_ptr(&self) -> *const f32
pub fn get_mesh_uvs_len(&self) -> usize
pub fn get_mesh_indices_ptr(&self) -> *const i32
pub fn get_mesh_indices_len(&self) -> usize
pub fn get_mesh_index_offsets_ptr(&self) -> *const u32
pub fn get_mesh_index_offsets_len(&self) -> usize
pub fn get_nines_vertices_ptr(&self) -> *const f32
pub fn get_nines_vertices_len(&self) -> usize
pub fn get_nines_uvs_ptr(&self) -> *const f32
pub fn get_nines_uvs_len(&self) -> usize
pub fn get_nines_box_coords_ptr(&self) -> *const f32
pub fn get_nines_box_coords_len(&self) -> usize
pub fn get_nines_indices_ptr(&self) -> *const i32
pub fn get_nines_indices_len(&self) -> usize
pub fn get_nines_vertex_offsets_ptr(&self) -> *const u32
pub fn get_nines_vertex_offsets_len(&self) -> usize
pub fn get_nines_index_offsets_ptr(&self) -> *const u32
pub fn get_nines_index_offsets_len(&self) -> usize
pub fn get_shape_vertex_counts_len(&self) -> usize
pub fn get_cell_meta_ptr(&self) -> *const f32
pub fn get_cell_meta_len(&self) -> usize
pub fn get_local_vertices_ptr(&self) -> *const f32
pub fn get_local_vertices_len(&self) -> usize
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn get_passed_event_indices(&self) -> &[i32]
pub fn get_passed_event_indices(&self) -> &[i32]
The events the last Self::update passed. They stay until the next one,
Self::setup_animation, Self::bind_resource or Self::reset.
Sourcepub fn get_passed_event_source_handles(&self) -> &[u32]
pub fn get_passed_event_source_handles(&self) -> &[u32]
Parallel to Self::get_passed_event_indices: source handle that fired
each collected event. With every source and every track’s outgoing side
at the default event threshold (+∞), entries are uniformly
Self::get_track_main_source of track 0. Diverges once secondaries opt
in to event firing via Self::set_source_event_threshold, or a
crossfade’s outgoing side via Self::set_track_outgoing_event_threshold.
Sourcepub fn get_active_event_instance(
&self,
slot_index: u32,
) -> ss_event_instance_info
pub fn get_active_event_instance( &self, slot_index: u32, ) -> ss_event_instance_info
Resolve the most-recent EventInstance whose frame_index <= current frame
for slot_index on the currently selected animation. Returns
synthetic_default() when no event has fired yet (SS6 default semantics).
Designed to live behind the ss_runtime_get_active_event_instance FFI.
Sourcepub fn get_active_effect_event(&self, slot_index: u32) -> ss_effect_event_info
pub fn get_active_effect_event(&self, slot_index: u32) -> ss_effect_event_info
Resolve the most-recent EventEffect whose frame_index <= current frame
for slot_index on the currently selected animation. When no event has
fired yet, falls back to InitialEvents.effect for that slot (still flagged
is_synthetic_default = true); if neither exists returns full SS6 defaults.
Designed to live behind the ss_runtime_get_active_effect_event FFI.
Sourcepub fn resolve_label_time(&self, label_hash: u32, fallback: i32) -> i32
pub fn resolve_label_time(&self, label_hash: u32, fallback: i32) -> i32
Look up label_hash in the currently selected animation’s labels
table and return its time. Returns fallback when label_hash == 0
(caller convention for “unset”), no animation is bound, or the hash
is not found. Linear scan — labels per animation are typically <50.
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn get_frame_data(&mut self, frame_no: f32) -> Result<&[u8], SSRuntimeError>
pub fn get_frame_data(&mut self, frame_no: f32) -> Result<&[u8], SSRuntimeError>
Build the FrameData of frame_no, which is in
[first frame, last frame + 1) of the animation. See SCHEMA.md for how to
read it. Fails with NotLoaded with no resource bound, AnimationNotFound
with no animation set up, and InvalidParameter for a frame_no out of
range.
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn find_part_index(&self, name: &str) -> i32
pub fn find_part_index(&self, name: &str) -> i32
Resolve a part name to its part_index in the current primary animation,
or -1 if not loaded / not found. Indices are stable within an SSAB, so
callers can resolve once and reuse the index across animation changes.
Sourcepub fn set_part_visibility_override(
&mut self,
part: u32,
force: u8,
cascade: bool,
) -> Result<(), SSRuntimeError>
pub fn set_part_visibility_override( &mut self, part: u32, force: u8, cascade: bool, ) -> Result<(), SSRuntimeError>
Set or clear a per-part visibility override.
force: 0 = clear/revert to animation, 1 = force-hide,
2 = force-visible (reserved, not implemented — rejected).
cascade propagates a force-hide to descendants.
Sourcepub fn clear_part_visibility_override(
&mut self,
part: u32,
) -> Result<(), SSRuntimeError>
pub fn clear_part_visibility_override( &mut self, part: u32, ) -> Result<(), SSRuntimeError>
Clear the visibility override on a part (revert to animation).
Sourcepub fn set_part_color_override(
&mut self,
part: u32,
blend_op: u8,
rgba: u32,
priority: u8,
) -> Result<(), SSRuntimeError>
pub fn set_part_color_override( &mut self, part: u32, blend_op: u8, rgba: u32, priority: u8, ) -> Result<(), SSRuntimeError>
Set a per-part color override with a single RGBA (fills all four corners).
blend_op: 0=Mix 1=Mul 2=Add 3=Sub. rgba: packed 0xRRGGBBAA.
priority: 0=OverwriteOnNextKeyframe 1=HoldUntilNextAnimation 2=Permanent.
Normal parts only.
Sourcepub fn set_part_color_override_corners(
&mut self,
part: u32,
blend_op: u8,
corners_rgba: [[u8; 4]; 4],
priority: u8,
) -> Result<(), SSRuntimeError>
pub fn set_part_color_override_corners( &mut self, part: u32, blend_op: u8, corners_rgba: [[u8; 4]; 4], priority: u8, ) -> Result<(), SSRuntimeError>
Set a per-part color override with distinct corners in ssruntime order
lt, rt, lb, rb, each [r, g, b, a].
Sourcepub fn clear_part_color_override(
&mut self,
part: u32,
) -> Result<(), SSRuntimeError>
pub fn clear_part_color_override( &mut self, part: u32, ) -> Result<(), SSRuntimeError>
Clear the color override on a part.
Sourcepub fn set_part_cell_override(
&mut self,
part: u32,
cellmap_name_hash: u32,
cell_name_hash: u32,
priority: u8,
) -> Result<(), SSRuntimeError>
pub fn set_part_cell_override( &mut self, part: u32, cellmap_name_hash: u32, cell_name_hash: u32, priority: u8, ) -> Result<(), SSRuntimeError>
Set a per-part cell override, identified by (cellmap_name_hash, cell_name_hash) (FNV-1a of the cellmap name without .ssce and the cell
name). (0, 0) reverts to the animation. priority:
0=OverwriteOnNextKeyframe 1=HoldUntilNextAnimation 2=Permanent. Normal + Mask parts only. The cell is resolved against the
bound SSAB now and cached; errors if it cannot be resolved.
Sourcepub fn clear_part_cell_override(
&mut self,
part: u32,
) -> Result<(), SSRuntimeError>
pub fn clear_part_cell_override( &mut self, part: u32, ) -> Result<(), SSRuntimeError>
Clear the cell override on a part.
Sourcepub fn clear_all_part_overrides(&mut self)
pub fn clear_all_part_overrides(&mut self)
Clear every per-part override.
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
pub fn get_frame_no(&self) -> f32
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
true once the configured loops have completed, and sticky until the
next play / setup_animation. Never true under an infinite loop
count, and never raised by stop.
This is a state, not a pulse: to notify once, take its rising edge.
pub fn just_looped(&self) -> bool
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
true while the clock runs and track 0 has not finished. A held
character is still playing.
pub fn is_playing_forward(&self) -> bool
Sourcepub fn is_pausing(&self) -> bool
pub fn is_pausing(&self) -> bool
true while a playing character is held. Implies Self::is_playing,
so the pair reads as three states. Once track 0 has finished, a pause
still holds the other tracks and the fades, but this reads false
along with is_playing.
Sourcepub fn is_clock_playing(&self) -> bool
pub fn is_clock_playing(&self) -> bool
true from play until stop or the next setup: the character’s
clock, which Self::is_playing reads only while track 0 has not
finished. A host that stops ticking a character with nothing to move
reads this, since the other tracks and the fades run on after track 0
ends. A held clock is still playing.
Sourcepub fn is_clock_pausing(&self) -> bool
pub fn is_clock_pausing(&self) -> bool
true while Self::pause holds a playing clock. Implies
Self::is_clock_playing, so the pair reads as three states, as
Self::is_playing and Self::is_pausing do; unlike is_pausing,
it still reads the hold after track 0 has finished.
Sourcepub fn is_stack_in_motion(&self) -> bool
pub fn is_stack_in_motion(&self) -> bool
true while the track stack would move the pose on a running clock for a
reason other than track 0’s own animation stepping: a fade on any track,
or a source — other than track 0’s main one — that plays, at a speed above
0 and a weight above 0, on a track that is heard. A cleared, finished or
silenced track does not count, nor does one at speed 0 moved by hand, nor
a source a crossfade has retired; one a cancelled crossfade left behind
does.
It does not read the clock: a Player that skips ticks while nothing moves
still runs one while the clock runs unheld (Self::is_clock_playing
and not Self::is_clock_pausing) and either track 0 plays
(Self::is_playing) or this holds. Read it before update: the
update a fade ends on clears the fade, so a read after it skips the
fade’s last frame. With this, a Player keeps no copy of which tracks and
sources it has laid, which goes wrong the moment one is released inside
the runtime.
Sourcepub fn get_skip_frames(&self) -> bool
pub fn get_skip_frames(&self) -> bool
Track 0’s Self::get_track_skip_frames.
Sourcepub fn get_playback_direction(&self) -> PlaybackDirection
pub fn get_playback_direction(&self) -> PlaybackDirection
Track 0’s Self::get_track_playback_direction.
Sourcepub fn get_playback_style(&self) -> PlaybackStyle
pub fn get_playback_style(&self) -> PlaybackStyle
Track 0’s Self::get_track_playback_style.
pub fn get_loop_count(&self) -> i32
pub fn get_remaining_loops(&self) -> i32
pub fn get_start_frame(&self) -> i32
pub fn get_end_frame(&self) -> i32
pub fn get_anime_data_start_frame(&self) -> i32
pub fn get_anime_data_end_frame(&self) -> i32
Sourcepub fn get_frame_rate(&self) -> i32
pub fn get_frame_rate(&self) -> i32
Track 0’s Self::get_track_frame_rate.
Sourcepub fn get_speed_scale(&self) -> f32
pub fn get_speed_scale(&self) -> f32
Track 0’s Self::get_track_speed.
Sourcepub fn set_skip_frames(&mut self, skip: bool)
pub fn set_skip_frames(&mut self, skip: bool)
Track 0’s Self::set_track_skip_frames.
pub fn set_loop_count(&mut self, loop_count: i32)
Sourcepub fn set_frame_rate(&mut self, frame_rate: i32)
pub fn set_frame_rate(&mut self, frame_rate: i32)
Track 0’s Self::set_track_frame_rate.
Sourcepub fn set_playback_direction(
&mut self,
direction: PlaybackDirection,
style: PlaybackStyle,
)
pub fn set_playback_direction( &mut self, direction: PlaybackDirection, style: PlaybackStyle, )
Track 0’s Self::set_track_playback_direction.
Sourcepub fn set_speed_scale(&mut self, speed_scale: f32)
pub fn set_speed_scale(&mut self, speed_scale: f32)
Track 0’s Self::set_track_speed.
Sourcepub fn set_animation_section(
&mut self,
start_frame: i32,
end_frame: i32,
) -> Result<(), SSRuntimeError>
pub fn set_animation_section( &mut self, start_frame: i32, end_frame: i32, ) -> Result<(), SSRuntimeError>
Track 0’s playback section, as
eval::playback_controller::PlaybackController::set_animation_section
sets it. An end before the start, both in range, is refused with
SSRuntimeError::InvalidParameter, and the section and the playhead
stay as they were.
pub fn set_coordinate_system(&mut self, coordinate_system: SsCoordinateSystem)
pub fn get_coordinate_system(&self) -> SsCoordinateSystem
pub fn set_origin(&mut self, origin: SsOrigin)
pub fn get_origin(&self) -> SsOrigin
pub fn set_unit(&mut self, unit: SsUnit)
pub fn get_unit(&self) -> SsUnit
Sourcepub fn update(&mut self, delta: f32) -> f32
pub fn update(&mut self, delta: f32) -> f32
Advance every source’s controller by delta milliseconds and return the
frame to hand to Self::get_frame_data: that of track 0’s main
animation, which get_frame_data validates against. A crossfade on
track 0 hands that role over when it begins, so across one this is the
incoming animation’s frame.
Nothing moves while the character’s clock is stopped or held, fades included. The controllers are still updated with no elapsed time, which is what reports a frame a seek has just landed on.
Sourcepub fn play(&mut self)
pub fn play(&mut self)
Heads track 0 out — back to its section start, loop count re-armed — and starts the character’s clock. The other tracks keep their playheads, as they do when track 0 loops or ends on its own.
pub fn play_with_start_frame(&mut self, frame_no: f32)
Sourcepub fn pause(&mut self)
pub fn pause(&mut self)
Holds the whole character in place: every track and every fade.
Idempotent, and ignored while the clock is stopped; is_playing stays
true.
Sourcepub fn resume(&mut self)
pub fn resume(&mut self)
Lifts a Self::pause. Idempotent, and not a way to start a stopped
animation — play rewinds, so it cannot serve as a resume.
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stops the whole character where it stands: every track and every fade.
Nothing rewinds; only play starts it again.
pub fn set_frame_no(&mut self, frame: f32)
Sourcepub fn set_frame_relative(&mut self, diff: f32)
pub fn set_frame_relative(&mut self, diff: f32)
Sets the playback position based on diff (frames elapsed since
playback started, with per-instance speed already applied), applying
the configured section / loops / style / direction. Used by parent
Players to drive child Instance Players deterministically
across reverse, seek, and frame-skip operations.
pub fn next_frame(&mut self)
pub fn prev_frame(&mut self)
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn set_track_animation(
&mut self,
track: u32,
name: &str,
) -> Result<(), SSRuntimeError>
pub fn set_track_animation( &mut self, track: u32, name: &str, ) -> Result<(), SSRuntimeError>
Put name on track, replacing whatever it was playing.
Tracks are addressed by index and grow on demand: setting track 3 creates
0..=3, the new ones silent. Track 0 is the structure track — its animation
supplies every discrete attribute and drives events — so it must be set up
first (setup_animation does exactly that), and this errors with
AnimationNotFound until it has been.
The animation must live in the currently bound AnimationResource
(same-SSAB constraint). Cancels any fade in flight on the track.
pub fn set_track_animation_by_hash( &mut self, track: u32, hash: u32, ) -> Result<(), SSRuntimeError>
Sourcepub fn set_track_alpha(
&mut self,
track: u32,
alpha: f32,
) -> Result<(), SSRuntimeError>
pub fn set_track_alpha( &mut self, track: u32, alpha: f32, ) -> Result<(), SSRuntimeError>
The strength of a track, i.e. how much of it survives onto the pose the
tracks below produced. This is the knob that always means something: a
source’s weight only decides proportions among the sources sharing one
track, and is silent when a source is the only one animating an attribute.
Alpha is not clamped: values above 1 extrapolate, which is occasionally
what an overlay wants. At 0 the track contributes nothing. Track 0 at
alpha 0 resolves to the setup pose, which is how an animation fades out to
rest.
pub fn get_track_alpha(&self, track: u32) -> Option<f32>
Sourcepub fn set_track_blend(
&mut self,
track: u32,
blend: TrackBlend,
) -> Result<(), SSRuntimeError>
pub fn set_track_blend( &mut self, track: u32, blend: TrackBlend, ) -> Result<(), SSRuntimeError>
How the track folds onto what is below: TrackBlend::Mix lerps toward
the track’s pose, TrackBlend::Additive adds the track’s offset from the
setup pose. Additive is for overlays that displace a performance rather
than replace it.
pub fn get_track_blend(&self, track: u32) -> Option<TrackBlend>
Sourcepub fn set_track_sync(
&mut self,
track: u32,
sync: TrackSync,
) -> Result<(), SSRuntimeError>
pub fn set_track_sync( &mut self, track: u32, sync: TrackSync, ) -> Result<(), SSRuntimeError>
Where the animations laid on track start: TrackSync::Free from the
head of their section, TrackSync::Start at the phase track 0 stands
at. It applies to everything laid on the track from then on —
set_track_animation, crossfade and add_track_source — so set it
before laying, and a track with nothing on it yet is created for it.
Like the rest of a track it goes with the stack on the next setup.
pub fn get_track_sync(&self, track: u32) -> Option<TrackSync>
Sourcepub fn get_track_count(&self) -> u32
pub fn get_track_count(&self) -> u32
Number of tracks that exist, including silent ones. Always at least 1.
Sourcepub fn clear_track(&mut self, track: u32) -> Result<(), SSRuntimeError>
pub fn clear_track(&mut self, track: u32) -> Result<(), SSRuntimeError>
Silence a track: every source on it is deactivated and its fade cancelled. Track 0 cannot be cleared — it carries the structure, and an instance with no structure has no pose to emit. Fade it to alpha 0 instead.
Sourcepub fn crossfade(
&mut self,
track: u32,
name: &str,
duration_ms: f32,
) -> Result<(), SSRuntimeError>
pub fn crossfade( &mut self, track: u32, name: &str, duration_ms: f32, ) -> Result<(), SSRuntimeError>
Fade track to name over duration_ms (the same time unit as
Context::update’s delta). The fade starts from whatever the track is
already playing, so there are no handles to pair up and nothing to clean up
afterwards: on completion the outgoing sources are deactivated.
The incoming animation becomes the track’s main one the moment the fade
begins, at weight 0 — on track 0 that makes it the primary, so the
frame, is_playing / is_finished / just_looped, the playback settings,
the discrete attributes and the events all speak for it from the call on.
The host has said where the character is going, and the outgoing side is
only its pose fading away: it neither reports state nor fires events
(unless its event threshold is lowered). Handing over on completion would
let an outgoing animation that runs out mid-fade report the character
finished, and then playing again once the fade completes.
Everything the track carries fades out together, in the proportions it
carries them: the main animation, any add_track_source sources, and
whatever a cancelled fade left behind. Their weights are normalised to sum
to 1 when the fade begins and scaled down by 1 - t from there, so the
pose does not jump when the fade begins or when it completes.
Starting a crossfade while one is running on the same track folds the one in flight into the new outgoing side, at the weights it has reached. There is never more than one outgoing side, so fades restarted faster than they run do not pile up, and every outgoing source is released on completion.
pub fn crossfade_by_hash( &mut self, track: u32, hash: u32, duration_ms: f32, ) -> Result<(), SSRuntimeError>
Sourcepub fn fade_track(
&mut self,
track: u32,
target: f32,
duration_ms: f32,
) -> Result<(), SSRuntimeError>
pub fn fade_track( &mut self, track: u32, target: f32, duration_ms: f32, ) -> Result<(), SSRuntimeError>
Drive a track’s alpha to target over duration_ms. Fading track 0 to 0
resolves the instance to its setup pose, which is what “fade out to rest”
means here — no placeholder animation required.
Sourcepub fn get_track_fade_progress(&self, track: u32) -> Option<f32>
pub fn get_track_fade_progress(&self, track: u32) -> Option<f32>
Progress of the fade in flight on track, in [0.0, 1.0]; None when the
track is not fading.
Sourcepub fn cancel_track_fade(&mut self, track: u32) -> Result<(), SSRuntimeError>
pub fn cancel_track_fade(&mut self, track: u32) -> Result<(), SSRuntimeError>
Cancel the fade on track, leaving alpha and weights where they stand.
Sourcepub fn set_track_frame(
&mut self,
track: u32,
frame: f32,
) -> Result<(), SSRuntimeError>
pub fn set_track_frame( &mut self, track: u32, frame: f32, ) -> Result<(), SSRuntimeError>
Seek the track’s current animation. This is how a modulation axis is driven: author the axis as an animation and scrub it with the tracked value.
pub fn get_track_frame(&self, track: u32) -> Option<f32>
Sourcepub fn set_track_speed(
&mut self,
track: u32,
speed: f32,
) -> Result<(), SSRuntimeError>
pub fn set_track_speed( &mut self, track: u32, speed: f32, ) -> Result<(), SSRuntimeError>
The speed of track, as a multiple of each animation’s frame rate. Kept
by the track: it reaches every source on it now and every one laid on it
later, so a crossfade or a set_track_animation does not reset it.
Track 0’s is Self::set_speed_scale. Like every track setting it goes
with the track when setup_animation collapses the stack, except on
track 0.
Sourcepub fn get_track_speed(&self, track: u32) -> Option<f32>
pub fn get_track_speed(&self, track: u32) -> Option<f32>
What Self::set_track_speed stored: a negative speed reads back as 0.
Sourcepub fn set_track_frame_rate(
&mut self,
track: u32,
frame_rate: i32,
) -> Result<(), SSRuntimeError>
pub fn set_track_frame_rate( &mut self, track: u32, frame_rate: i32, ) -> Result<(), SSRuntimeError>
The frame rate track plays its animations at instead of the rate they
were authored at; 0 or a negative rate clears it. Kept by the track,
as Self::set_track_speed is.
Sourcepub fn get_track_frame_rate(&self, track: u32) -> Option<i32>
pub fn get_track_frame_rate(&self, track: u32) -> Option<i32>
The rate track’s animation plays at: the override when one is set,
otherwise the rate it was authored at. None for a track that does not
exist; 0 for one with no animation and no override.
Sourcepub fn set_track_skip_frames(
&mut self,
track: u32,
skip: bool,
) -> Result<(), SSRuntimeError>
pub fn set_track_skip_frames( &mut self, track: u32, skip: bool, ) -> Result<(), SSRuntimeError>
Whether track skips frames to keep up. Kept by the track, as
Self::set_track_speed is.
pub fn get_track_skip_frames(&self, track: u32) -> Option<bool>
Sourcepub fn set_track_playback_direction(
&mut self,
track: u32,
direction: PlaybackDirection,
style: PlaybackStyle,
) -> Result<(), SSRuntimeError>
pub fn set_track_playback_direction( &mut self, track: u32, direction: PlaybackDirection, style: PlaybackStyle, ) -> Result<(), SSRuntimeError>
The direction and style track plays its animations in. Kept by the
track, as Self::set_track_speed is.
pub fn get_track_playback_direction( &self, track: u32, ) -> Option<PlaybackDirection>
pub fn get_track_playback_style(&self, track: u32) -> Option<PlaybackStyle>
Sourcepub fn set_track_loop_count(
&mut self,
track: u32,
loop_count: i32,
) -> Result<(), SSRuntimeError>
pub fn set_track_loop_count( &mut self, track: u32, loop_count: i32, ) -> Result<(), SSRuntimeError>
How many times track’s animation plays before it holds its last frame;
0 or a negative count loops forever. Unlike the speed this belongs to
the animation on the track, not the track: laying another animation
there starts it looping forever again, so state the count after laying
it. Track 0’s is Self::set_loop_count.
Sourcepub fn get_track_loop_count(&self, track: u32) -> Option<i32>
pub fn get_track_loop_count(&self, track: u32) -> Option<i32>
-1 for a track that loops forever; None for one with no animation.
Sourcepub fn is_track_finished(&self, track: u32) -> bool
pub fn is_track_finished(&self, track: u32) -> bool
true once track’s animation has played its loop count out and holds
its last frame, as Self::is_finished is for track 0. A finished track
keeps mixing that frame in until the host fades or clears it. false for
a track with no animation.
Sourcepub fn track_just_looped(&self, track: u32) -> bool
pub fn track_just_looped(&self, track: u32) -> bool
true for the update in which track’s animation wrapped back to its
start, as Self::just_looped is for track 0.
Sourcepub fn get_track_main_source(&self, track: u32) -> Option<u32>
pub fn get_track_main_source(&self, track: u32) -> Option<u32>
Handle of the source carrying track’s animation. Needed to give that
animation a weight of its own once a track holds several — the animation
put there by set_track_animation starts at weight 1.
Sourcepub fn add_track_source(
&mut self,
track: u32,
name: &str,
weight: f32,
) -> Result<u32, SSRuntimeError>
pub fn add_track_source( &mut self, track: u32, name: &str, weight: f32, ) -> Result<u32, SSRuntimeError>
Add another weighted source to track, for the case a track needs several
animations blended by proportion (locomotion: walk + run). Returns a stable
handle for Self::set_source_weight.
Most tracks never need this — one animation plus the track’s alpha
covers layering, and crossfade covers transitions.
pub fn add_track_source_by_hash( &mut self, track: u32, hash: u32, weight: f32, ) -> Result<u32, SSRuntimeError>
Sourcepub fn set_source_weight(
&mut self,
handle: u32,
weight: f32,
) -> Result<(), SSRuntimeError>
pub fn set_source_weight( &mut self, handle: u32, weight: f32, ) -> Result<(), SSRuntimeError>
Proportion of one source within its track. See Self::set_track_alpha
for the strength of the track as a whole.
pub fn get_source_weight(&self, handle: u32) -> Option<f32>
pub fn set_source_frame( &mut self, handle: u32, frame: f32, ) -> Result<(), SSRuntimeError>
Sourcepub fn get_source_animation_index(&self, handle: u32) -> Option<u32>
pub fn get_source_animation_index(&self, handle: u32) -> Option<u32>
Which animation handle plays, as an index into the pack’s animations:
the order of AnimationResource::get_animation_names and of the
ssab’s animations(). None for a handle that names no source.
An index from Self::get_passed_event_indices addresses the events()
of the animation of the source that fired it, so this is how a Player
decodes an event. Track 0’s included: a crossfade on track 0 hands it to
another animation, and a table kept from setup_animation is then the
wrong one.
Sourcepub fn get_current_animation_index(&self) -> Option<u32>
pub fn get_current_animation_index(&self) -> Option<u32>
Which animation track 0’s main source plays, as an index into the pack’s
animations: the one setup_animation set up, until a crossfade or a
set_track_animation on track 0 hands the track to another, from the
call on. None before anything is set up.
pub fn get_source_frame(&self, handle: u32) -> Option<f32>
Sourcepub fn set_source_event_threshold(
&mut self,
handle: u32,
threshold: f32,
) -> Result<(), SSRuntimeError>
pub fn set_source_event_threshold( &mut self, handle: u32, threshold: f32, ) -> Result<(), SSRuntimeError>
Per-source event firing threshold. A source fires events once its weight
reaches the threshold. The default is +∞, so by default no source
fires but track 0’s main source, which always does regardless of this
setting. Distinguish sources with
Self::get_passed_event_source_handles.
pub fn get_source_event_threshold(&self, handle: u32) -> Option<f32>
Sourcepub fn set_track_outgoing_event_threshold(
&mut self,
track: u32,
threshold: f32,
) -> Result<(), SSRuntimeError>
pub fn set_track_outgoing_event_threshold( &mut self, track: u32, threshold: f32, ) -> Result<(), SSRuntimeError>
How far into a crossfade on track the outgoing side keeps firing
events. It fires while its share of the track, 1 - t, is at least
threshold, however many sources it holds: 0.5 keeps it firing for the
first half of the fade. The default, +∞, keeps it silent from the moment
the fade begins, which is where the incoming animation starts firing.
The outgoing sources’ own thresholds are not consulted while they fade.
A setting of the track rather than of a source, since the outgoing side
can be several sources, released when the fade completes; it applies to
every crossfade on the track until it is changed. Track 0 keeps it
across setup_animation, as it keeps its playback settings.
pub fn get_track_outgoing_event_threshold(&self, track: u32) -> Option<f32>
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Back to the just-created state: the resource is unbound, and the overrides and the playback and coordinate settings are cleared.
Sourcepub fn set_render_mode(&mut self, mode: RenderMode)
pub fn set_render_mode(&mut self, mode: RenderMode)
What the frame computes; see RenderMode.
Sourcepub fn render_mode(&self) -> RenderMode
pub fn render_mode(&self) -> RenderMode
What Self::set_render_mode stored.
Sourcepub fn bind_resource(&mut self, resource: &'a AnimationResource<'a>)
pub fn bind_resource(&mut self, resource: &'a AnimationResource<'a>)
Bind resource, dropping the tracks and the overrides. The coordinate
settings stay. Self::setup_animation comes next.
Sourcepub fn get_ssab_data(&self) -> Option<&[u8]>
pub fn get_ssab_data(&self) -> Option<&[u8]>
The bound resource’s .ssab bytes.
Sourcepub fn setup_animation(&mut self, name: &str) -> Result<(), SSRuntimeError>
pub fn setup_animation(&mut self, name: &str) -> Result<(), SSRuntimeError>
Select the animation name and move to its first frame. This does not start
it; Self::play does. It drops every track but 0, the section and the loop
count, and keeps the speed, the frame rate, the frame skip and the direction.
Sourcepub fn setup_animation_by_hash(
&mut self,
hash: u32,
) -> Result<(), SSRuntimeError>
pub fn setup_animation_by_hash( &mut self, hash: u32, ) -> Result<(), SSRuntimeError>
Self::setup_animation by the FNV-1a hash of the name.