Update model loading tutorial to tobj 3.0.x

pull/185/head
Hugo Woodiwiss 3 years ago
parent 4e7d249943
commit 8a01d0e519
No known key found for this signature in database
GPG Key ID: DA90F48139594E88

@ -12,7 +12,7 @@ env_logger = "0.8"
futures = "0.3"
image = "0.23"
log = "0.4"
tobj = "2.0"
tobj = "3.0"
wgpu = {version = "0.8", features = [ "cross" ]}
winit = "0.24"

@ -1,6 +1,7 @@
use anyhow::*;
use std::ops::Range;
use std::path::Path;
use tobj::LoadOptions;
use wgpu::util::DeviceExt;
use crate::texture;
@ -70,7 +71,14 @@ impl Model {
layout: &wgpu::BindGroupLayout,
path: P,
) -> Result<Self> {
let (obj_models, obj_materials) = tobj::load_obj(path.as_ref(), true)?;
let (obj_models, obj_materials) = tobj::load_obj(path.as_ref(), &LoadOptions {
triangulate: true,
single_index: true,
..Default::default()
},
)?;
let obj_materials = obj_materials?;
// We're assuming that the texture files are stored with the obj file
let containing_folder = path.as_ref().parent().context("Directory has no parent")?;

Loading…
Cancel
Save