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
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;
}