diff options
author | Joshua Rowe <17525998+omnisci3nce@users.noreply.github.com> | 2024-05-20 10:50:11 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-20 10:50:11 +1000 |
commit | e904c22003c3a134201b222e6619e782fbe63947 (patch) | |
tree | 5295c8ce5f855ca4a0f1bebe50beee80bae66682 /src/systems/terrain.h | |
parent | 02e84ee4d18e705e3362be1e327fdb6f1397a032 (diff) | |
parent | 73d4145f46d2305f45761b8e456df692d1962dfb (diff) |
Merge pull request #14 from omnisci3nce/realign
Realign
Diffstat (limited to 'src/systems/terrain.h')
-rw-r--r-- | src/systems/terrain.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/systems/terrain.h b/src/systems/terrain.h new file mode 100644 index 0000000..bfd90b5 --- /dev/null +++ b/src/systems/terrain.h @@ -0,0 +1,55 @@ +/** + * @file terrain.h + * @author your name (you@domain.com) + * @brief + * @version 0.1 + * @date 2024-04-27 + * + * @copyright Copyright (c) 2024 + * + */ + +/* +Future: + - Chunked terrain + - Dynamic LOD +*/ + +#include "defines.h" +#include "maths_types.h" +#include "mem.h" +#include "render_types.h" +#include "str.h" + +typedef struct heightmap { + str8 filepath; + u32x2 size; + void* image_data; + bool is_uploaded; +} heightmap; + +typedef struct terrain_state { + arena terrain_allocator; + heightmap* heightmap; // NULL = no heightmap +} terrain_state; + +bool terrain_system_init(terrain_state* state); +void terrain_system_shutdown(terrain_state* state); +void terrain_system_render_hmap(renderer* rend, terrain_state* state); + +heightmap heightmap_from_image(str8 filepath); +heightmap heightmap_from_perlin(/* TODO: perlin noise generation parameters */); + +/** @brief Get the height (the Y component) for a vertex at a particular coordinate in the heightmap + */ +f32 heightmap_height_at_xz(heightmap* hmap, f32 x, f32 z); + +/** @brief Calculate the normal vector of a vertex at a particular coordinate in the heightmap */ +vec3 heightmap_normal_at_xz(heightmap* hmap, f32 x, f32 z); + +/** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */ +geometry_data geo_heightmap(arena* a, heightmap heightmap); + +// somewhere there will be an easy way to add a heightmap + +// scene_add_heightmap
\ No newline at end of file |