39 releases

0.7.1 Mar 30, 2023
0.7.0 Sep 30, 2021
0.6.4 Sep 30, 2021
0.6.3 Jun 22, 2021
0.0.5 Dec 28, 2014

#7 in Data formats

Download history 549/week @ 2023-12-08 2170/week @ 2023-12-15 1036/week @ 2023-12-22 3870/week @ 2023-12-29 4942/week @ 2024-01-05 4769/week @ 2024-01-12 3590/week @ 2024-01-19 3349/week @ 2024-01-26 3218/week @ 2024-02-02 5212/week @ 2024-02-09 6268/week @ 2024-02-16 5716/week @ 2024-02-23 4648/week @ 2024-03-01 5554/week @ 2024-03-08 3802/week @ 2024-03-15 2198/week @ 2024-03-22

16,876 downloads per month
Used in 12 crates (8 directly)

Apache-2.0 OR MIT

775KB
1K SLoC

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 model: 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.5–11MB
~95K SLoC