License: MIT Apache License 2.0 docs.rs crates.io Download numbers Github CI Minimum rustc version

Collada parser

This is a parser for the Collada (.dae) format, used for interchange between 3D renderers and games. Compared to the collada crate, this crate attempts to more directly represent the Collada data model, and it is also significantly more complete.

Currently it only supports reading, but writing is a planned addition.

Usage

The main entry point is the [Document] type, which has a [FromStr] implementation to convert literal strings / slices, or [Document::from_file] to read from a .dae file on disk.

Collada documents are parsed eagerly, validating everything according to the COLLADA schema. Once parsed, the data structures (structs and enums) can be navigated directly, as all the data structures are public, and reflect the XML schema closely.

This library implements only version 1.4.1 of the Collada spec, although it may be expanded in the future. (Please open an issue or PR if you find anything missing from the spec, or if you have a use case for a later version.)

```rust use std::str::FromStr; use dae_parser::*;

let dae_file = r##"\ 1970-01-01T00:00:00 1970-01-01T00:00:00 1 1 1 1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1

3 1 0 1 5 2 3 4 1 1 4 5

"##;

let document = Document::fromstr(daefile).unwrap(); let cube = document.localmap::().unwrap().getstr("Cube-mesh").unwrap(); let sourcesmap = document.localmap::().unwrap(); let verticesmap = document.localmap::().unwrap(); // sources.get("Cube-mesh-positions").unwrap(); asserteq!(cube.id.asref().unwrap(), "Cube-mesh"); let mesh = cube.element.asmesh().unwrap(); let tris = mesh.elements[0].astriangles().unwrap(); asserteq!( tris.data.asderef().unwrap(), &[3, 1, 0, 1, 5, 2, 3, 4, 1, 1, 4, 5] ); asserteq!(tris.inputs[0].semantic, Semantic::Vertex); let vertices = verticesmap.getraw(&tris.inputs[0].source).unwrap(); asserteq!(vertices.id, "Cube-mesh-vertices"); let source = sourcesmap .getraw(&vertices.positioninput().source) .unwrap(); asserteq!(source.id.as_deref(), Some("Cube-mesh-positions")); ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.