Struct rusty_spine::Bone
source · pub struct Bone { /* private fields */ }
Expand description
A bone within the Skeleton
hierarchy.
Bones can be acquired from a Skeleton
and a safe BoneHandle
can be obtained using the
Bone::handle
method to store long-term references to a specific
bone.
The hierarchy can be traversed using Bone::parent
and Bone::children
, and specific
bones can be located using Skeleton::find_bone
.
Implementations§
source§impl Bone
impl Bone
sourcepub fn set_to_setup_pose(&mut self)
pub fn set_to_setup_pose(&mut self)
Sets this bone’s local transform to the setup pose.
sourcepub fn update(&mut self)
pub fn update(&mut self)
Computes the world transform using the parent bone and this bone’s local applied transform.
sourcepub fn update_world_transform(&mut self)
pub fn update_world_transform(&mut self)
Computes the world transform using the parent bone and this bone’s local transform.
sourcepub fn update_world_transform_with(
&mut self,
x: f32,
y: f32,
rotation: f32,
scale_x: f32,
scale_y: f32,
shear_x: f32,
shear_y: f32
)
pub fn update_world_transform_with( &mut self, x: f32, y: f32, rotation: f32, scale_x: f32, scale_y: f32, shear_x: f32, shear_y: f32 )
Computes the world transform using the parent bone and the specified local transform. The applied transform is set to the specified local transform. Child bones are not updated.
See
World transforms
in the Spine Runtimes Guide.
sourcepub fn update_applied_transform(&mut self)
pub fn update_applied_transform(&mut self)
Computes the applied transform values from the world transform.
If the world transform is modified (by a constraint, rotate_world
,
etc) then this method should be called so the applied transform matches the world transform.
The applied transform may be needed by other code (eg to apply another constraint).
Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. The applied transform after calling this method is equivalent to the local transform used to compute the world transform, but may not be identical.
sourcepub fn world_rotation_x(&self) -> f32
pub fn world_rotation_x(&self) -> f32
sourcepub fn world_rotation_y(&self) -> f32
pub fn world_rotation_y(&self) -> f32
sourcepub fn world_scale_x(&self) -> f32
pub fn world_scale_x(&self) -> f32
sourcepub fn world_scale_y(&self) -> f32
pub fn world_scale_y(&self) -> f32
sourcepub fn world_to_local(&self, world_x: f32, world_y: f32) -> (f32, f32)
pub fn world_to_local(&self, world_x: f32, world_y: f32) -> (f32, f32)
Transforms a point from world coordinates to the bone’s local coordinates.
sourcepub fn local_to_world(&self, local_x: f32, local_y: f32) -> (f32, f32)
pub fn local_to_world(&self, local_x: f32, local_y: f32) -> (f32, f32)
Transforms a point from the bone’s local coordinates to world coordinates.
sourcepub fn world_to_local_rotation(&self, world_rotation: f32) -> f32
pub fn world_to_local_rotation(&self, world_rotation: f32) -> f32
Transforms a world rotation to a local rotation.
sourcepub fn local_to_world_rotation(&self, local_rotation: f32) -> f32
pub fn local_to_world_rotation(&self, local_rotation: f32) -> f32
Transforms a local rotation to a world rotation.
sourcepub fn rotate_world(&self, degrees: f32)
pub fn rotate_world(&self, degrees: f32)
Rotates the world transform the specified amount.
After changes are made to the world transform,
update_applied_transform
should be called and update
will need to be called on any child bones, recursively.
sourcepub fn handle(&self) -> BoneHandle
pub fn handle(&self) -> BoneHandle
Create a persistent BoneHandle
to this Bone
.
sourcepub fn set_rotation(&mut self, value: f32)
pub fn set_rotation(&mut self, value: f32)
Set the local rotation in degrees, counter clockwise.
sourcepub fn set_scale_x(&mut self, value: f32)
pub fn set_scale_x(&mut self, value: f32)
Set the local scaleX.
sourcepub fn set_scale_y(&mut self, value: f32)
pub fn set_scale_y(&mut self, value: f32)
Set the local scaleY.
sourcepub fn set_shear_x(&mut self, value: f32)
pub fn set_shear_x(&mut self, value: f32)
Set the local shearX.
sourcepub fn set_shear_y(&mut self, value: f32)
pub fn set_shear_y(&mut self, value: f32)
Set the local shearY.
sourcepub fn set_applied_x(&mut self, value: f32)
pub fn set_applied_x(&mut self, value: f32)
Set the applied local x translation.
sourcepub fn set_applied_y(&mut self, value: f32)
pub fn set_applied_y(&mut self, value: f32)
Set the applied local y translation.
sourcepub fn applied_rotation(&self) -> f32
pub fn applied_rotation(&self) -> f32
The applied local rotation in degrees, counter clockwise.
sourcepub fn set_applied_rotation(&mut self, value: f32)
pub fn set_applied_rotation(&mut self, value: f32)
Set the applied local rotation in degrees, counter clockwise.
sourcepub fn applied_scale_x(&self) -> f32
pub fn applied_scale_x(&self) -> f32
The applied local scaleX.
sourcepub fn set_applied_scale_x(&mut self, value: f32)
pub fn set_applied_scale_x(&mut self, value: f32)
Set the applied local scaleX.
sourcepub fn applied_scale_y(&self) -> f32
pub fn applied_scale_y(&self) -> f32
The applied local scaleY.
sourcepub fn set_applied_scale_y(&mut self, value: f32)
pub fn set_applied_scale_y(&mut self, value: f32)
Set the applied local scaleY.
sourcepub fn applied_shear_x(&self) -> f32
pub fn applied_shear_x(&self) -> f32
The applied local shearX.
sourcepub fn set_applied_shear_x(&mut self, value: f32)
pub fn set_applied_shear_x(&mut self, value: f32)
Set the applied local shearX.
sourcepub fn applied_shear_y(&self) -> f32
pub fn applied_shear_y(&self) -> f32
The applied local shearY.
sourcepub fn set_applied_shear_y(&mut self, value: f32)
pub fn set_applied_shear_y(&mut self, value: f32)
Set the applied local shearY.
sourcepub fn set_a(&mut self, value: f32)
pub fn set_a(&mut self, value: f32)
Set part of the world transform matrix for the X axis. If changed,
update_applied_transform
should be called.
sourcepub fn set_b(&mut self, value: f32)
pub fn set_b(&mut self, value: f32)
Set part of the world transform matrix for the Y axis. If changed,
update_applied_transform
should be called.
sourcepub fn set_c(&mut self, value: f32)
pub fn set_c(&mut self, value: f32)
Set part of the world transform matrix for the X axis. If changed,
update_applied_transform
should be called.
sourcepub fn set_d(&mut self, value: f32)
pub fn set_d(&mut self, value: f32)
Set part of the world transform matrix for the Y axis. If changed,
update_applied_transform
should be called.
sourcepub fn set_world_x(&mut self, value: f32)
pub fn set_world_x(&mut self, value: f32)
The world X position. If changed,
update_applied_transform
should be called.
sourcepub fn set_world_y(&mut self, value: f32)
pub fn set_world_y(&mut self, value: f32)
Set the world Y position. If changed,
update_applied_transform
should be called.
pub fn sorted(&self) -> bool
pub fn active(&self) -> bool
pub fn parent(&self) -> Option<CTmpRef<'_, Self, Bone>>
pub fn parent_mut(&mut self) -> Option<CTmpMut<'_, Self, Bone>>
pub fn children_count(&self) -> usize
sourcepub fn children(&self) -> CTmpPtrIterator<'_, Bone, Bone, spBone> ⓘ
pub fn children(&self) -> CTmpPtrIterator<'_, Bone, Bone, spBone> ⓘ
An iterator over the children of this bone.
use rusty_spine::{BoneHandle, Skeleton};
fn traverse_bones(
bone_handle: BoneHandle,
skeleton: &Skeleton,
ident: usize,
) {
if let Some(bone) = bone_handle.get(skeleton) {
println!(
"{:ident$}{name}",
"",
ident = ident,
name = bone.data().name()
);
for child in bone.children() {
traverse_bones(child.handle(), skeleton, ident + 2);
}
}
}
// Traverse all bones in a skeleton
let root_bone = skeleton.bone_root().handle();
traverse_bones(root_bone, &skeleton, 0);
pub fn children_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Bone>>
pub fn children_mut(&mut self) -> CTmpMutIterator<'_, Bone, Bone, spBone> ⓘ
pub fn children_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Bone>>
pub fn set_y_down(y_down: bool)
pub fn is_y_down() -> bool
source§impl Bone
impl Bone
Functions available if using the mint
feature.
sourcepub fn set_position(&mut self, position: impl Into<Vector2<f32>>)
pub fn set_position(&mut self, position: impl Into<Vector2<f32>>)
Set the local translation.
sourcepub fn world_position(&self) -> Vector2<f32>
pub fn world_position(&self) -> Vector2<f32>
The world translation.
sourcepub fn set_world_position(&mut self, position: impl Into<Vector2<f32>>)
pub fn set_world_position(&mut self, position: impl Into<Vector2<f32>>)
Set the world translation.
sourcepub fn applied_position(&self) -> Vector2<f32>
pub fn applied_position(&self) -> Vector2<f32>
The applied translation.
sourcepub fn set_applied_position(&mut self, position: impl Into<Vector2<f32>>)
pub fn set_applied_position(&mut self, position: impl Into<Vector2<f32>>)
Set the applied translation.
sourcepub fn world_scale(&self) -> Vector2<f32>
pub fn world_scale(&self) -> Vector2<f32>
The world scale.
sourcepub fn applied_scale(&self) -> Vector2<f32>
pub fn applied_scale(&self) -> Vector2<f32>
The applied scale.
sourcepub fn set_applied_scale(&mut self, scale: impl Into<Vector2<f32>>)
pub fn set_applied_scale(&mut self, scale: impl Into<Vector2<f32>>)
Set the applied scale.
sourcepub fn applied_shear(&self) -> Vector2<f32>
pub fn applied_shear(&self) -> Vector2<f32>
The applied shear.
sourcepub fn set_applied_shear(&mut self, shear: impl Into<Vector2<f32>>)
pub fn set_applied_shear(&mut self, shear: impl Into<Vector2<f32>>)
Set the applied shear.