Tried implementing lines method
This commit is contained in:
@@ -118,7 +118,7 @@ impl CameraState {
|
||||
s.0 * f.1 - s.1 * f.0,
|
||||
);
|
||||
|
||||
const SPEED: f32 = 100.0; //1.0;
|
||||
const SPEED: f32 = 5.0; //1.0;
|
||||
|
||||
if self.moving_up {
|
||||
self.position.0 += u.0 * SPEED;
|
||||
|
||||
+70
-20
@@ -77,7 +77,7 @@ fn get_altitude(height_columns: &Vec<&str>, columns_index: usize) -> f32 {
|
||||
const SEABED_ALTITUDE: f32 = -100.0;
|
||||
// seabed altitude - biggest drop * tiles in a chunk * (chunks in a row - 1)
|
||||
const ALTITUDE_BETWEEN_CHUNKS: f32 = SEABED_ALTITUDE - 16.17 * 250.0 * 30.0;
|
||||
const BELOW_MAP_BIOME: u32 = 19;
|
||||
const BELOW_MAP_BIOME: u32 = 0;
|
||||
|
||||
/// Returns a vertex buffer that should be rendered as `TrianglesList`.
|
||||
pub fn load_ground(display: &Display) -> VertexBufferAny {
|
||||
@@ -98,14 +98,15 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
||||
|
||||
let mut i: u32 = 0;
|
||||
|
||||
for path in paths {
|
||||
/*for path in paths {
|
||||
let file_name = path
|
||||
.unwrap()
|
||||
.path()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.replace("Extensions/LemnosLife/Map/Altis/Ground/", "")
|
||||
.replace(".height", "");
|
||||
.replace(".height", "");*/
|
||||
for file_name in ["3 13", "4 13"] {
|
||||
println!("{}", file_name);
|
||||
let file_name_parts: Vec<&str> = file_name.split(' ').collect();
|
||||
|
||||
@@ -116,7 +117,6 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
||||
];
|
||||
|
||||
// have deleted a few height files to make it work
|
||||
// TODO: use triangle strip
|
||||
let height_contents = fs::read_to_string(&format!(
|
||||
"Extensions/LemnosLife/Map/Altis/Ground/{}.height",
|
||||
file_name
|
||||
@@ -167,23 +167,38 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
||||
let biome = get_biome(biomes_line, biome_index);
|
||||
|
||||
if lines_index == 0 && columns_index == 0 {
|
||||
// This vertex defines the end of the wall below the ground.
|
||||
// This vertex defines the end of the line below the ground.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome: BELOW_MAP_BIOME,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
// This vertex ends correctly the across chunks triangle under the ground.
|
||||
// It is useful to keep a specific color for the triangle under the ground.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column,
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome: BELOW_MAP_BIOME,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
// This vertex defines the cursor ready to be used.
|
||||
// It resets the specific color for the triangle under the ground.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column,
|
||||
index,
|
||||
@@ -206,21 +221,56 @@ pub fn load_ground(display: &Display) -> VertexBufferAny {
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
|
||||
if lines_index == height_lines.len() - 1 && columns_index == height_columns.len() {
|
||||
// This vertex starts the triangle going vertically down under the first chunk.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column_below,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column_below,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: column_below,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
// This vertex doesn't give width to the triangle going vertically down under the first chunk.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome,
|
||||
chunk,
|
||||
});
|
||||
}
|
||||
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
// This vertex remove the wall across the chunks above the ground.
|
||||
vertex_data.push(Vertex {
|
||||
altitude: ALTITUDE_BETWEEN_CHUNKS,
|
||||
index,
|
||||
biome: BELOW_MAP_BIOME,
|
||||
chunk,
|
||||
});
|
||||
i += 1;
|
||||
// i == 250 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BufferCreationError(OutOfMemory)', src/support/mod.rs:203:10
|
||||
/*if i == 1 {
|
||||
if i == 2 {
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
println!("charlie");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user