Skip to main content

euv_core/game/engine3d/animation/
struct.rs

1use super::*;
2
3/// Single timestamped 3D transform keyframe inside an `AnimationClip3D`.
4#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
5pub struct Keyframe3D {
6    /// Keyframe time offset in seconds.
7    #[get(type(copy))]
8    pub(crate) time_secs: f32,
9    /// Local joint or node transform at `time_secs`.
10    #[get(type(copy))]
11    pub(crate) transform: Transform3D,
12}
13
14/// Named bone joint inside a hierarchical `SkeletonRig3D`.
15#[derive(Clone, Data, Debug, PartialEq)]
16pub struct SkeletonJoint3D {
17    /// Human-readable joint identifier (e.g., `"root"`, `"spine"`, `"turret"`).
18    pub(crate) name: String,
19    /// Optional parent joint index (`None` for root bone).
20    #[get(skip)]
21    pub(crate) parent: Option<usize>,
22    /// Bind-pose local transform relative to parent.
23    #[get(type(copy))]
24    pub(crate) rest_transform: Transform3D,
25}
26
27/// Per-joint keyframe track animating one joint index over time.
28#[derive(Clone, Data, Debug, PartialEq)]
29pub struct JointTrack3D {
30    /// Target joint index inside `SkeletonRig3D::joints`.
31    #[get(type(copy))]
32    pub(crate) joint_index: usize,
33    /// Chronologically sorted keyframes.
34    pub(crate) keyframes: Vec<Keyframe3D>,
35}
36
37/// Reusable skeletal/transform animation clip with duration and looping control.
38#[derive(Clone, Data, Debug, PartialEq)]
39pub struct AnimationClip3D {
40    /// Clip name.
41    pub(crate) name: String,
42    /// Total clip duration in seconds.
43    #[get(type(copy))]
44    pub(crate) duration_secs: f32,
45    /// Whether playback wraps seamlessly at `duration_secs`.
46    #[get(type(copy))]
47    pub(crate) looping: bool,
48    /// Per-joint keyframe tracks.
49    pub(crate) tracks: Vec<JointTrack3D>,
50}
51
52/// Hierarchical 3D skeletal rig evaluating forward kinematics across bone chains.
53#[derive(Clone, Data, Debug, Default, PartialEq)]
54pub struct SkeletonRig3D {
55    /// Ordered joint hierarchy (parents precede children).
56    pub(crate) joints: Vec<SkeletonJoint3D>,
57}