1use std::slice::from_raw_parts;
23use ffi::AiNode;
45use math::Matrix4x4;
67define_type_and_iterator_indirect! {
8/// The `Node` type represents a node in the imported scene hierarchy.
9struct Node(&AiNode)
10/// Node iterator type.
11struct NodeIter
12}
1314impl<'a> Node<'a> {
15/// Returns the name of the node.
16pub fn name(&self) -> &str {
17self.name.as_ref()
18 }
1920/// Returns the node's transformation matrix.
21pub fn transformation(&self) -> Matrix4x4 {
22 Matrix4x4::from_raw(&self.transformation)
23 }
2425/// Return the parent of this node. Returns `None` if this node is the root node.
26pub fn parent(&self) -> Option<Node> {
27if !self.parent.is_null() {
28Some(Node::from_raw(self.parent))
29 } else {
30None
31}
32 }
3334/// Returns the number of child nodes.
35pub fn num_children(&self) -> u32 {
36self.num_children
37 }
3839/// Returns a vector containing all of the child nodes under this node.
40pub fn child_iter(&self) -> NodeIter {
41 NodeIter::new(self.children as *const *const AiNode,
42self.num_children as usize)
43 }
4445/// Returns the number of meshes under this node.
46pub fn num_meshes(&self) -> u32 {
47self.num_meshes
48 }
4950/// Returns a vector containing all of the meshes under this node. These are indices into
51 /// the meshes contained in the `Scene` struct.
52pub fn meshes(&self) -> &[u32] {
53let len = self.num_meshes as usize;
54unsafe { from_raw_parts(self.meshes, len) }
55 }
5657// TODO metadata
58}