|
@@ -52,19 +52,18 @@ pub fn generate_square()->Vec<Vertex>{
|
|
|
//Simple plane from Jamie King video: OpenGL Plane Code
|
|
//Simple plane from Jamie King video: OpenGL Plane Code
|
|
|
|
|
|
|
|
pub fn generate_jamie_plane(dimensions:u32)->Vec<Vertex>{
|
|
pub fn generate_jamie_plane(dimensions:u32)->Vec<Vertex>{
|
|
|
- let mut vertices: Vec<Vertex> = vec![Vertex{position: [0.0, 0.0, 0.0], color: [1.0, 1.0, 1.0]}; dimensions as usize * dimensions as usize];
|
|
|
|
|
|
|
+ let mut vertices: Vec<Vertex> = vec![];
|
|
|
let nombre_de_points = dimensions * dimensions;
|
|
let nombre_de_points = dimensions * dimensions;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
let moitie = dimensions / 2;
|
|
let moitie = dimensions / 2;
|
|
|
let mut row = 0;
|
|
let mut row = 0;
|
|
|
let mut column = 0;
|
|
let mut column = 0;
|
|
|
while row < (dimensions){
|
|
while row < (dimensions){
|
|
|
while column < (dimensions ){
|
|
while column < (dimensions ){
|
|
|
- vertices[(row * dimensions + column) as usize] = Vertex{
|
|
|
|
|
- position: [((column as f32) - moitie as f32), 0.0, ((row as f32) - moitie as f32)],
|
|
|
|
|
- color: [1.0, 1.0, 1.0]
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ let x = (column as f32) - moitie as f32;
|
|
|
|
|
+ let z = (row as f32) - moitie as f32;
|
|
|
|
|
+ let y = 0.0;
|
|
|
|
|
+
|
|
|
println!("row: {}, column: {}, first call", row, column);
|
|
println!("row: {}, column: {}, first call", row, column);
|
|
|
|
|
|
|
|
column += 1;
|
|
column += 1;
|
|
@@ -74,4 +73,41 @@ pub fn generate_jamie_plane(dimensions:u32)->Vec<Vertex>{
|
|
|
row += 1;
|
|
row += 1;
|
|
|
}
|
|
}
|
|
|
return vertices;
|
|
return vertices;
|
|
|
-}
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//Not jamie, Victor Gordan
|
|
|
|
|
+pub fn very_simple_plane(divisions: u32, width: f32) -> Vec<Vertex> {
|
|
|
|
|
+ let triangle_side = width / divisions as f32;
|
|
|
|
|
+
|
|
|
|
|
+ let mut plane: Vec<Vertex> = Vec::new();
|
|
|
|
|
+
|
|
|
|
|
+ for row in 0..=divisions {
|
|
|
|
|
+ for col in 0..=divisions {
|
|
|
|
|
+ let x = col as f32 * triangle_side;
|
|
|
|
|
+ let z = row as f32 * triangle_side;
|
|
|
|
|
+
|
|
|
|
|
+ // Calculate next and last vertex positions (assuming a flat plane on Y axis)
|
|
|
|
|
+ let next_vert = Vertex {
|
|
|
|
|
+ position: [x + triangle_side, 0.0, z],
|
|
|
|
|
+ color: [1.0, 0.0, 0.0], // Replace with desired color
|
|
|
|
|
+ };
|
|
|
|
|
+ let last_vert = Vertex {
|
|
|
|
|
+ position: [x, 0.0, z + triangle_side],
|
|
|
|
|
+ color: [0.0, 1.0, 0.0], // Replace with desired color
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // Current vertex (modify color as needed)
|
|
|
|
|
+ let current_vert = Vertex {
|
|
|
|
|
+ position: [x, 0.0, z],
|
|
|
|
|
+ color: [0.0, 0.0, 1.0], // Replace with desired color
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // Push vertices in triangle order (counter-clockwise)
|
|
|
|
|
+ plane.push(current_vert);
|
|
|
|
|
+ plane.push(next_vert);
|
|
|
|
|
+ plane.push(last_vert);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ plane
|
|
|
|
|
+}
|