1 Commits

Author SHA1 Message Date
Benjamin_Loison 57ce3a64ed Try shifting chunks with uniform 2022-10-22 20:43:39 +02:00
2 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -43,7 +43,7 @@ fn main() {
let display = glium::Display::new(wb, cb, &event_loop).unwrap(); let display = glium::Display::new(wb, cb, &event_loop).unwrap();
// building the vertex and index buffers // building the vertex and index buffers
let vertex_buffer = support::load_ground(&display); let (vertex_buffer, chunks) = support::load_ground(&display);
let textures: [SrgbTexture2d; BIOMES_NUMBER] = BIOMES.map(|biome| { let textures: [SrgbTexture2d; BIOMES_NUMBER] = BIOMES.map(|biome| {
println!("{}", biome); println!("{}", biome);
@@ -172,6 +172,7 @@ fn main() {
tex16: &textures[16], tex16: &textures[16],
tex17: &textures[17], tex17: &textures[17],
tex18: &textures[18], tex18: &textures[18],
chunks: &chunks,
}; };
// draw parameters // draw parameters
+8 -3
View File
@@ -74,7 +74,7 @@ fn get_altitude(height_columns: &Vec<&str>, columns_index: usize) -> f32 {
} }
/// Returns a vertex buffer that should be rendered as `TrianglesList`. /// Returns a vertex buffer that should be rendered as `TrianglesList`.
pub fn load_ground(display: &Display) -> VertexBufferAny { pub fn load_ground(display: &Display) -> (VertexBufferAny, Vec<[u32; 2]>) {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct Vertex { struct Vertex {
altitude: f32, altitude: f32,
@@ -86,6 +86,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
implement_vertex!(Vertex, altitude, normal, index, biome); implement_vertex!(Vertex, altitude, normal, index, biome);
let mut vertex_data: Vec<Vertex> = Vec::new(); let mut vertex_data: Vec<Vertex> = Vec::new();
let mut chunks: Vec<[u32; 2]> = Vec::new();
let ground_folder = "Extensions/LemnosLife/Map/Altis/Ground/"; let ground_folder = "Extensions/LemnosLife/Map/Altis/Ground/";
let paths = fs::read_dir(ground_folder).unwrap(); let paths = fs::read_dir(ground_folder).unwrap();
@@ -101,6 +102,10 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
.replace("Extensions/LemnosLife/Map/Altis/Ground/", "") .replace("Extensions/LemnosLife/Map/Altis/Ground/", "")
.replace(".height", ""); .replace(".height", "");
println!("{}", file_name); println!("{}", file_name);
let file_name_parts: Vec<&str> = file_name.split(' ').collect();
chunks.push([file_name_parts[0].parse().unwrap(), file_name_parts[1].parse().unwrap()]);
// have deleted a few height files to make it work // have deleted a few height files to make it work
// TODO: use triangle strip // TODO: use triangle strip
let height_contents = fs::read_to_string(&format!( let height_contents = fs::read_to_string(&format!(
@@ -202,7 +207,7 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
} }
println!("charlie"); println!("charlie");
glium::vertex::VertexBuffer::new(display, &vertex_data) (glium::vertex::VertexBuffer::new(display, &vertex_data)
.unwrap() .unwrap()
.into() .into(), chunks)
} }