1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extern crate bytepack;
extern crate flate2;
use std::io::{Read, Result, Error, ErrorKind, Seek};
use std::u64;
use bytepack::LEUnpacker;
pub mod types;
use types::{Node, decode_node_list};
pub fn decode_fbx<R: Read + Seek>(r: &mut R) -> Result<Vec<Node>> {
let mut header = [0u8; 23];
r.read_exact(&mut header[..])?;
if &header != b"Kaydara FBX Binary \x00\x1a\x00" {
return Err(Error::new(ErrorKind::InvalidData, "Invalid FBX header magic"));
}
let version = r.unpack::<u32>()?;
if version >= 7500 {
return Err(Error::new(ErrorKind::InvalidData, "Unsuported FBX version"));
}
return decode_node_list(r, u64::MAX);
}
#[cfg(test)]
mod tests;