geometry/lib.rs
1#![deny(missing_docs)]
2
3//! A structure for storing and look up 3D geometry
4
5extern crate range;
6extern crate wavefront_obj as wobj;
7
8pub use geometry::Geometry;
9pub use object::Object;
10pub use model::Model;
11
12use std::marker::PhantomData;
13
14mod geometry;
15mod object;
16mod model;
17
18/// Add range to object `T`.
19pub struct AddTo<T>(PhantomData<T>);
20
21/// Implemented by vertex types.
22pub trait Vertex {
23 /// Sets position.
24 fn set_position(&mut self, [f32; 3]);
25 /// Sets texture coords.
26 fn set_texture_coords(&mut self, [f32; 2]);
27 /// Sets normal.
28 fn set_normal(&mut self, [f32; 3]);
29}
30
31/// Description of vertex format.
32pub enum VertexFormat {
33 /// Vertex contains position coordinates.
34 Position,
35 /// Vertex contains position and texture coordinates.
36 PositionTexture,
37 /// Vertex contains position and normal coordinates.
38 PositionNormal,
39 /// Vertex contains both position, texture and normal coordinates.
40 PositionTextureNormal,
41}
42
43/// An error with vertex format when adding to index and vertex buffer.
44#[derive(Debug)]
45pub enum VertexFormatError {
46 /// The vertex format must be the same for an entire geometry object.
47 ExpectedSameVertexFormatPerGeometry,
48}