#3d #obj #graphics #parser #wave-front

obj-rs

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

42 releases

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

#7 in Data formats

Download history 7392/week @ 2025-01-28 10865/week @ 2025-02-04 10146/week @ 2025-02-11 6882/week @ 2025-02-18 4562/week @ 2025-02-25 4599/week @ 2025-03-04 2743/week @ 2025-03-11 2706/week @ 2025-03-18 2338/week @ 2025-03-25 1544/week @ 2025-04-01 2348/week @ 2025-04-08 1351/week @ 2025-04-15 2476/week @ 2025-04-22 1290/week @ 2025-04-29 2702/week @ 2025-05-06 825/week @ 2025-05-13

7,408 downloads per month
Used in 18 crates (13 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.7"
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.4–10MB
~92K SLoC