-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmod.rs
More file actions
30 lines (27 loc) · 870 Bytes
/
mod.rs
File metadata and controls
30 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Minimal helpers for loading Wavefront OBJ assets.
//!
//! These functions are thin wrappers around the `obj` crate used by examples
//! and tooling to import meshes.
use std::{
fs::File,
io::BufReader,
};
use obj::{
load_obj,
Obj,
TexturedVertex,
};
/// Loads a untextured obj file from the given path. Wrapper around the obj crate.
pub fn load_obj_from_file(path: &str) -> Obj {
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
let obj = load_obj(reader).expect("Failed to load the OBJ file.");
return obj;
}
/// Loads a textured obj file from the given path. Wrapper around the obj crate.
pub fn load_textured_obj_from_file(path: &str) -> Obj<TexturedVertex> {
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
let obj = load_obj(reader).expect("Failed to load obj file.");
return obj;
}