mittens_engine/engine/ecs/component/
bone_rest_pose.rs1use crate::engine::ecs::ComponentId;
2use crate::engine::ecs::component::Component;
3
4#[derive(Debug, Clone, Copy)]
23pub struct BoneRestPoseComponent {
24 pub translation: [f32; 3],
25 pub rotation: [f32; 4],
26 pub scale: [f32; 3],
27
28 component: Option<ComponentId>,
29}
30
31impl BoneRestPoseComponent {
32 pub fn new(translation: [f32; 3], rotation: [f32; 4], scale: [f32; 3]) -> Self {
33 Self {
34 translation,
35 rotation,
36 scale,
37 component: None,
38 }
39 }
40}
41
42impl Component for BoneRestPoseComponent {
43 fn name(&self) -> &'static str {
44 "bone_rest_pose"
45 }
46
47 fn set_id(&mut self, id: ComponentId) {
48 self.component = Some(id);
49 }
50
51 fn as_any(&self) -> &dyn std::any::Any {
52 self
53 }
54
55 fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
56 self
57 }
58
59 fn to_mms_ast(
60 &self,
61 _world: &crate::engine::ecs::World,
62 ) -> crate::scripting::ast::ComponentExpression {
63 use crate::engine::ecs::component::ce_helpers::*;
64 ce("BoneRestPose").with_call(
65 "translation",
66 vec![
67 num(self.translation[0] as f64),
68 num(self.translation[1] as f64),
69 num(self.translation[2] as f64),
70 ],
71 )
72 }
73}