![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
How a terrain is cut into meshes: square chunks, each at levels that take every vertex, then every second, fourth and eighth, for the cull to pick by distance. More...
Functions | |
| uint32_t | perSide (const TerrainAsset &terrain) |
How many chunks terrain is cut into along a side. | |
| MeshAsset | build (const TerrainAsset &terrain, uint32_t cx, uint32_t cz, uint32_t level) |
Chunk cx, cz of terrain at level, in the terrain's local space. | |
| uint32_t | levelAt (float distance, float chunkWidth) |
The level a chunk takes at distance from the eye. | |
How a terrain is cut into meshes: square chunks, each at levels that take every vertex, then every second, fourth and eighth, for the cull to pick by distance.
Each level hangs a skirt from each rim it shares with another chunk, so where two neighbours meet at different levels the gap between their edges shows the skirt, not the sky. A vertex's uv is the centre of its texel of a map with a texel a grid vertex (the layer weights), so a share painted at a vertex is read there.
| uint32_t Vkm::Engine::TerrainChunks::perSide | ( | const TerrainAsset & | terrain | ) |
How many chunks terrain is cut into along a side.
| terrain | A terrain of a valid resolution. |
| MeshAsset Vkm::Engine::TerrainChunks::build | ( | const TerrainAsset & | terrain, |
| uint32_t | cx, | ||
| uint32_t | cz, | ||
| uint32_t | level ) |
Chunk cx, cz of terrain at level, in the terrain's local space.
Each grid square is two triangles split along its diagonal from (i, j) to (i + 1, j + 1), as TerrainAsset::heightAt reads them; a coarser level's square is the same over its larger span.
| terrain | Its grid. |
| cx | Along X, below perSide(). |
| cz | Along Z, below perSide(). |
| level | Below LEVELS. |
| uint32_t Vkm::Engine::TerrainChunks::levelAt | ( | float | distance, |
| float | chunkWidth ) |
The level a chunk takes at distance from the eye.
Each level holds twice as far as the one before: the finest within REACH chunk widths.
| distance | Metres from the eye to the chunk's box. |
| chunkWidth | Metres a chunk spans. |