Created
February 13, 2024 13:31
-
-
Save isXander/929db41de73f40494cedb6b7a8d7fb60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn create_face( | |
x: f32, y: f32, z: f32, | |
face: Face, | |
) -> Vec<engine::model::ModelVertex> { | |
let mut vertices = Vec::new(); | |
println!("Creating face: {:?}", face); | |
let (x_axis, y_axis, z_axis, x_off, y_off, z_off, norm_x, norm_y, norm_z) = match face { | |
Face::Top => (1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0), | |
Face::Bottom => (1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0), | |
Face::North => (1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.0), | |
Face::South => (1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0), | |
Face::East => (0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0), | |
Face::West => (0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0), | |
}; | |
let top_left = (x + x_off, y + y_off, z + z_off, 0.0, 0.0); | |
let top_right = (x + x_off + x_axis, y + y_off, z + z_off, 0.0, 1.0); | |
let bottom_left = (x + x_off, y + y_off + y_axis, z + z_off + z_axis, 1.0, 0.0); | |
let bottom_right = (x + x_off + x_axis, y + y_off + y_axis, z + z_off + z_axis, 1.0, 1.0); | |
let vertices_data = [ | |
top_left, bottom_left, bottom_right, | |
top_left, bottom_right, top_right, | |
]; | |
for (x, y, z, u, v) in vertices_data.iter() { | |
vertices.push(engine::model::ModelVertex { | |
position: [*x, *y, *z], | |
normal: [norm_x, norm_y, norm_z], | |
tex_coords: [*u, *v], | |
bitangent: [0.0, 0.0, 0.0], | |
tangent: [0.0, 0.0, 0.0], | |
}); | |
} | |
vertices | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment