Update Rust generate example

Former-commit-id: 83df1a3f0c9771c6e61056160ebf7d5a6a3c15dd
This commit is contained in:
David Harvey-Macaulay 2017-09-12 11:11:05 +01:00
parent 18fab51991
commit e9573cc6f3

View File

@ -6,7 +6,6 @@ use cgmath::prelude::*;
pub type Face = [u32; 3];
pub type Vec2 = [f32; 2];
pub type Vec3 = [f32; 3];
pub type Vec4 = [f32; 4];
#[derive(Debug)]
struct Vertex {
@ -15,14 +14,6 @@ struct Vertex {
tex_coord: Vec2,
}
#[derive(Debug)]
struct NewVertex {
position: Vec3,
normal: Vec3,
tex_coord: Vec2,
tangent: Vec4,
}
fn make_cube() -> (Vec<Face>, Vec<Vertex>) {
struct ControlPoint {
uv: Vec2,
@ -142,17 +133,20 @@ fn main() {
let normal = |face, vert| &vertex(face, vert).normal;
let tex_coord = |face, vert| &vertex(face, vert).tex_coord;
let mut new_vertices = Vec::new();
{
let mut i = 0;
let mut set_tangent = |face, vert, tangent| {
new_vertices.push(NewVertex {
position: *position(face, vert),
normal: *normal(face, vert),
tex_coord: *tex_coord(face, vert),
tangent: tangent,
});
println!(
"{index}: v: {v:?}, vn: {vn:?}, vt: {vt:?}, vx: {vx:?}",
index = i,
v = position(face, vert),
vn = normal(face, vert),
vt = tex_coord(face, vert),
vx = tangent,
);
i += 1;
};
let ret = mikktspace::generate(
let ret = mikktspace::generate_tangents(
&vertices_per_face,
&face_count,
&position,
@ -162,6 +156,4 @@ fn main() {
);
assert_eq!(true, ret);
}
println!("{:#?}", new_vertices);
}