vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ocean.h
1#pragma once
2
3#include <array>
4#include <cstdint>
5
6#include <glm/glm.hpp>
7
8#include "core/reflect.h"
9#include "ecs/entity.h"
10
11namespace Vkm::Engine {
12
13class Scene;
14
22struct OceanSurge {
23 glm::vec2 centre = glm::vec2(0.0f);
24 glm::vec2 direction = {0.0f, 1.0f};
25 float height = 0.0f;
26 float halfWidth = 1.0f;
27 float halfLength = 4.0f;
28};
29
40struct Ocean {
41 static constexpr uint32_t MAX_WAVES = 64;
42 static constexpr uint32_t MAX_SURGES = 4;
44 static constexpr float WATERLINE_SQUARE = 128.0f;
45
46 float windSpeed = 8.0f;
47 float windDirection = 0.0f;
48 float fetch = 100.0f;
50 float depth = 0.0f;
51 float spread = 0.5f;
52 float choppiness = 0.7f;
53 float heightScale = 1.0f;
54 float minWavelength = 2.0f;
55 float maxWavelength = 200.0f;
56 uint32_t waveCount = 32;
57 uint32_t seed = 1;
60 float shortestRipple = 0.03f;
61
62 float calmRadius = 0.0f;
63 float stillRadius = 0.0f;
64
65 float foam = 0.5f;
68 float waterlineFoam = 0.6f;
69 glm::vec3 foamColor = glm::vec3(0.9f, 0.94f, 0.96f);
71 float detailScale = 8.0f;
72
75 std::array<OceanSurge, MAX_SURGES> surges{};
76};
77
86EntityId findOcean(const Scene& scene);
87
88} // namespace Vkm::Engine
89
90VKM_REFLECT_BEGIN(::Vkm::Engine::Ocean)
91 VKM_F(windSpeed)
92 VKM_F(windDirection)
93 VKM_F(fetch)
94 VKM_F(depth)
95 VKM_F(spread)
96 VKM_F(choppiness)
97 VKM_F(heightScale)
98 VKM_F(minWavelength)
99 VKM_F(maxWavelength)
100 VKM_F(waveCount)
101 VKM_F(seed)
102 VKM_F(shortestRipple)
103 VKM_F(calmRadius)
104 VKM_F(stillRadius)
105 VKM_F(foam)
106 VKM_F(waterlineFoam)
107 VKM_F(foamColor)
108 VKM_F(detailScale)
109VKM_REFLECT_END()
Central registry managing entities and an open set of component types.
Definition scene.h:29
A ridge of water rolling across the sea, raised by gameplay: a straight crest of finite length,...
Definition ocean.h:22
glm::vec2 centre
World X and Z: the crest's middle.
Definition ocean.h:23
float halfLength
Metres from its middle to each end, along its crest.
Definition ocean.h:27
float height
Metres over the water's rest at the crest; 0 is none.
Definition ocean.h:25
float halfWidth
Metres from the crest to the sea, along its roll.
Definition ocean.h:26
glm::vec2 direction
On the XZ plane: the way it rolls; zero is no surge.
Definition ocean.h:24
The scene's sea: wind-driven waves moving every surface whose material is waves.
Definition ocean.h:40
float depth
Metres of water under the waves: shallower slows them and flattens the long ones. 0 is deep.
Definition ocean.h:50
float choppiness
0 round swells; 1 crests drawn to a point.
Definition ocean.h:52
static constexpr float WATERLINE_SQUARE
Metres across the square of sea ahead of the eye where the water meets what stands in it.
Definition ocean.h:44
float detailScale
Metres across one repeat of the material's maps, laid over the water and drifting with the wind.
Definition ocean.h:71
glm::vec3 foamColor
Definition ocean.h:69
float windDirection
Degrees round from +Z toward +X: the way the waves roll.
Definition ocean.h:47
float foam
Definition ocean.h:65
float fetch
Definition ocean.h:48
uint32_t seed
Definition ocean.h:57
float calmRadius
Metres from the Transform where the waves begin to fade.
Definition ocean.h:62
float stillRadius
Where they are gone; at or inside calmRadius they never fade.
Definition ocean.h:63
uint32_t waveCount
Waves summed, up to MAX_WAVES.
Definition ocean.h:56
float minWavelength
Metres; shorter are ripples, per pixel.
Definition ocean.h:54
float waterlineFoam
Definition ocean.h:68
float maxWavelength
Metres.
Definition ocean.h:55
float windSpeed
m/s, ten metres up: the waves' energy grows nearly with its square.
Definition ocean.h:46
std::array< OceanSurge, MAX_SURGES > surges
Definition ocean.h:75
float heightScale
On the heights the spectrum gives.
Definition ocean.h:53
float spread
0 every wave rolls with the wind; 1 they come from all ahead of it.
Definition ocean.h:51
float shortestRipple
Definition ocean.h:60