Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.63 KB

Readme.md

File metadata and controls

64 lines (47 loc) · 1.63 KB

Rust-MeshLoad

Rust-MeshLoad is a small library which provides functionality for loading common 3d file formats, including:

  • WaveFront Obj
  • possible others: blend, fbx, collada, etc

Rust-MeshLoad makes no assumptions about the internal representation of your mesh data, and leaves you free to define your own mesh structures for your app/game. All it requires is that you implement:

trait VertexColor<T: Float> {
    pub fn new_with_rgba(r: T, g: T, b: T, a: T) -> Self;
    pub fn new_with_rgb(r: T, g: T, b: T)        -> Self;
}

for your color type;

pub trait VertexPoint<T: Float> {
		fn new_with_xyzw(x: T, y: T, z: T, w: T) -> Self;
		fn new_with_xyz(x: T, y: T, z: T)        -> Self;
}

for your vertex position type;

pub trait VertexNormal<T: Float> {
	fn new_with_xyz(x: T, y: T, z: T) -> Self;
}

for your normal type;

pub trait VertexUvCoord<T: Float> {
	fn new_with_uv(u: T, v: T) -> Self;
}

for your Uv-Coordinate type; and

pub trait Mesh<T0: Float, T1: Float, T2: Float, T3: Float> {
	fn new(colors:    &[&VertexColor<T0>],
		   points:    &[&VertexPoint<T1>],
		   normals:   &[&VertexNormal<T2>],
		   uv_coords: &[&VertexUvCoord<T3>]) -> Self;
}

for your mesh type. In addition, it is easy to extend Rust-MeshLoad with your own custom file loaders, simply by implementing the trait:

pub trait FileLoader<T0: Float,
					 T1: Float,
					 T2: Float,
					 T3: Float> {
	fn load_mesh_file(file_name: &str) -> &Mesh<T0, T1, T2, T3>;
}

For your own file loaders (technically, this could be its own function).

TODO:

  • Bones
  • More formats...
  • Tests
  • Flesh out API