diff --git a/code/beginner/tutorial9-models/Cargo.toml b/code/beginner/tutorial9-models/Cargo.toml index a5ceb2ec..5cb0c88c 100644 --- a/code/beginner/tutorial9-models/Cargo.toml +++ b/code/beginner/tutorial9-models/Cargo.toml @@ -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" diff --git a/code/beginner/tutorial9-models/src/model.rs b/code/beginner/tutorial9-models/src/model.rs index 95375d36..de0d288e 100644 --- a/code/beginner/tutorial9-models/src/model.rs +++ b/code/beginner/tutorial9-models/src/model.rs @@ -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 { - 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")?;