#graphics #obj #WaveFront #3D #parser

obj-rs

Wavefront obj parser for Rust. It handles both ‘obj’ and ‘mtl’ formats.

36 releases

✓ Uses Rust 2018 edition

0.6.1 May 10, 2020
0.6.0 Mar 21, 2020
0.5.0 Mar 5, 2019
0.4.20 Jan 23, 2018
0.0.5 Dec 28, 2014

#6 in Data formats

Download history 55/week @ 2020-02-08 14/week @ 2020-02-15 227/week @ 2020-02-22 43/week @ 2020-02-29 104/week @ 2020-03-07 61/week @ 2020-03-14 226/week @ 2020-03-21 72/week @ 2020-03-28 124/week @ 2020-04-04 235/week @ 2020-04-11 48/week @ 2020-04-18 38/week @ 2020-04-25 27/week @ 2020-05-02 38/week @ 2020-05-09 37/week @ 2020-05-16 60/week @ 2020-05-23

423 downloads per month
Used in bvh

Apache-2.0 OR MIT

780KB
963 lines

obj-rs version

Wavefront .obj parser for Rust. It handles both .obj and .mtl formats. See Documentation for the further details.

[dependencies]
obj-rs = "0.6"
use std::fs::File;
use std::io::BufReader;
use obj::{load_obj, Obj};

let input = BufReader::new(File::open("tests/fixtures/dome.obj"))?;
let mobel: Obj = load_obj(input)?;

// Do whatever you want
model.vertices;
model.indices;

Rendered image of cute Rilakkuma


Glium support

obj-rs supports glium out of the box.

[dependencies]
glium = "0.26"
obj-rs = { version = "0.6", features = ["glium"] }
use std::fs::File;
use std::io::BufReader;
use obj::{load_obj, Obj};

let input = BufReader::new(File::open("rilakkuma.obj")?);
let obj: Obj = load_obj(input)?;

let vb = obj.vertex_buffer(&display)?;
let ib = obj.index_buffer(&display)?;

Please see the working sample for the further details. Use can execute it with the command below.

cargo run -p sampleapp


obj-rs is primarily distributed under the terms of both the Apache License (Version 2.0) and the MIT license. See COPYRIGHT for details.

Dependencies

~0.7–1.6MB
~35K SLoC