|
|
@@ -111,3 +111,34 @@ pub fn very_simple_plane(divisions: u32, width: f32) -> Vec<Vertex> {
|
|
|
|
|
|
plane
|
|
|
}
|
|
|
+
|
|
|
+//Gemini version
|
|
|
+pub fn generate_vertices_and_colors(
|
|
|
+ largeur: u32,
|
|
|
+ hauteur: u32,
|
|
|
+ subdivisions: u32,
|
|
|
+) -> Vec<Vertex> {
|
|
|
+ let total_vertices = (subdivisions + 1) * (subdivisions + 1);
|
|
|
+
|
|
|
+ let mut vertices: Vec<Vertex> = Vec::with_capacity(total_vertices as usize);
|
|
|
+
|
|
|
+ for i in 0..=subdivisions {
|
|
|
+ for j in 0..=subdivisions {
|
|
|
+ let step_x = largeur as f32 / (subdivisions as f32 + 1.0);
|
|
|
+ let step_y = hauteur as f32 / (subdivisions as f32 + 1.0);
|
|
|
+ let x = step_x * i as f32;
|
|
|
+ let y = step_y * j as f32;
|
|
|
+
|
|
|
+ let gray = (i as f32 + j as f32) / ((subdivisions + 1) as f32 * 2.0) as f32;
|
|
|
+
|
|
|
+ let vertex = Vertex {
|
|
|
+ position: [x, 0.0, y], // Adjust Z component as needed
|
|
|
+ color: [gray, gray, gray],
|
|
|
+ };
|
|
|
+ vertices.push(vertex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vertices
|
|
|
+}
|
|
|
+
|