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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
//! 3d mesh library. //! //! # Loading meshes //! //! ``` //! use mash::{load, Model, Vector}; //! use mash::load::wavefront; //! use std::cmp::PartialOrd; //! use std::path::Path; //! //! type Index = u16; //! //! #[derive(Clone, Debug, PartialEq, PartialOrd)] //! pub struct Vertex { //! pub position: Vector, //! // .. more fields //! } //! //! impl mash::Vertex for Vertex { //! fn position(&self) -> Vector { self.position } //! } //! //! impl From<wavefront::Vertex> for Vertex { //! fn from(v: wavefront::Vertex) -> Self { //! Vertex { position: v.position } //! } //! } //! //! let model: Model<Vertex, Index> = Model::new(load::wavefront::from_path("res/cube.obj").unwrap()).unwrap(); //! ``` //! //! # Preprocessing meshes //! //! ``` //! use mash::{load, Vector}; //! //! type Model = mash::Model<Vector, u32>; //! //! let wavefront = load::wavefront::from_path("res/lighthouse.obj").unwrap(); //! //! let pylon_obj = wavefront.objects().find(|o| o.name() == "pylon_rectangle").unwrap(); //! let light_obj = wavefront.objects().find(|o| o.name() == "rotating_lights_cylinder").unwrap(); //! //! // Can render the two models separately, with different transforms if necessary. //! let pylon: Model = Model::new(pylon_obj).unwrap(); //! let lights: Model = Model::new(light_obj).unwrap(); //! ``` #[macro_use] extern crate error_chain; #[cfg(feature = "wavefront")] extern crate tobj; pub use self::errors::{Error, ErrorKind, ResultExt, Result}; pub use self::geometry::{Vertex, Vector, Triangle, Color}; pub use self::index::Index; pub use self::model::{Model, TriangularMesh, BuildModel}; pub mod errors; pub mod geometry; pub mod index; pub mod model; pub mod load; pub mod build;