From 8f5b525e37e82d260601e7052a49a6515b6100d8 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Sun, 23 Jul 2017 00:14:27 -0400 Subject: [PATCH] Remove the wavefront object loader for now... I'd rather convert the vertexes to binary and then include_bytes! --- Cargo.toml | 2 -- support/mod.rs | 46 ---------------------------------------------- 2 files changed, 48 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4d56af3..36dedd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,8 @@ opt-level = 3 cgmath = "*" glium = "0.16.0" glutin = "0.7.4" -genmesh = "0.4.1" image = { version = "0.14.0", features = ["png_codec"], optional = true } libxm = "1.0.0" -obj = { version = "0.5", features = ["usegenmesh"] } rust-rocket = { path = "rust-rocket", optional = true } rand = "*" sdl2 = "*" diff --git a/support/mod.rs b/support/mod.rs index b71f50d..add172f 100644 --- a/support/mod.rs +++ b/support/mod.rs @@ -1,8 +1,5 @@ #![allow(dead_code)] -extern crate genmesh; -extern crate obj; - use glium::{self, Display}; use glium::vertex::VertexBufferAny; @@ -22,46 +19,3 @@ pub fn start_loop(mut callback: F) where F: FnMut() -> Action { }; } } - -/// Returns a vertex buffer that should be rendered as `TrianglesList`. -pub fn load_wavefront(display: &Display, data: &[u8]) -> VertexBufferAny { - #[derive(Copy, Clone)] - struct Vertex { - position: [f32; 3], - normal: [f32; 3], - texture: [f32; 2], - } - - implement_vertex!(Vertex, position, normal, texture); - - let mut data = ::std::io::BufReader::new(data); - let data = obj::Obj::load(&mut data); - - let mut vertex_data = Vec::new(); - - for object in data.object_iter() { - for shape in object.group_iter().flat_map(|g| g.indices().iter()) { - match shape { - &genmesh::Polygon::PolyTri(genmesh::Triangle { x: v1, y: v2, z: v3 }) => { - for v in [v1, v2, v3].iter() { - let position = data.position()[v.0]; - let texture = v.1.map(|index| data.texture()[index]); - let normal = v.2.map(|index| data.normal()[index]); - - let texture = texture.unwrap_or([0.0, 0.0]); - let normal = normal.unwrap_or([0.0, 0.0, 0.0]); - - vertex_data.push(Vertex { - position: position, - normal: normal, - texture: texture, - }) - } - }, - _ => unimplemented!() - } - } - } - - glium::vertex::VertexBuffer::new(display, &vertex_data).unwrap().into_vertex_buffer_any() -} -- 2.25.1