assimp/scene/
animation.rs

1use ffi::AiAnimation;
2use ffi::AiNodeAnim;
3use ffi::AiVectorKey;
4use ffi::AiQuatKey;
5
6define_type_and_iterator_indirect! {
7    /// Animation type (not yet implemented)
8    struct Animation(&AiAnimation)
9    /// Animation iterator type.
10    struct AnimationIter
11}
12
13define_type_and_iterator_indirect! {
14    /// NodeAnim type (not yet implemented)
15    struct NodeAnim(&AiNodeAnim)
16    /// NodeAnim iterator type.
17    struct NodeAnimIter
18}
19
20define_type_and_iterator_indirect! {
21    /// VectorKey type (not yet implemented)
22    struct VectorKey(&AiVectorKey)
23    /// VectorKey iterator type.
24    struct VectorKeyIter
25}
26
27define_type_and_iterator_indirect! {
28    /// QuatKey type (not yet implemented)
29    struct QuatKey(&AiQuatKey)
30    /// QuatKey iterator type.
31    struct QuatKeyIter
32}
33
34impl<'a> NodeAnim<'a> {
35    pub fn get_position_key(&self, id: usize) -> Option<VectorKey> {
36        if id < self.num_position_keys as usize {
37            unsafe { Some(VectorKey::from_raw(self.position_keys.offset(id as isize))) }
38        } else {
39            None
40        }
41    }
42    pub fn get_rotation_key(&self, id: usize) -> Option<QuatKey> {
43        if id < self.num_rotation_keys as usize {
44            unsafe { Some(QuatKey::from_raw(self.rotation_keys.offset(id as isize))) }
45        } else {
46            None
47        }
48    }
49    pub fn get_scaling_key(&self, id: usize) -> Option<VectorKey> {
50        if id < self.num_scaling_keys as usize {
51            unsafe { Some(VectorKey::from_raw(self.scaling_keys.offset(id as isize))) }
52        } else {
53            None
54        }
55    }
56}
57
58impl<'a> Animation<'a> {
59    pub fn get_node_anim(&self, id: usize) -> Option<NodeAnim> {
60        if id < self.num_channels as usize {
61            unsafe { Some(NodeAnim::from_raw(*(self.channels.offset(id as isize)))) }
62        } else {
63            None
64        }
65    }
66}