Try shifting chunks with uniform
This commit is contained in:
+2
-1
@@ -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
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user