vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::OceanSurface Struct Reference

An ocean's surface at one moment: the waves the spectrum gives, and what they do. More...

#include <ocean_surface.h>

Public Member Functions

float reach (const glm::vec2 &rest) const
 How much of the waves reach rest: 1 inside calmRadius, 0 from stillRadius out.
glm::vec3 displacement (const glm::vec2 &rest) const
 Where the water resting at rest has been carried: X and Z across, Y up.
float heightAt (const glm::vec2 &point) const
 The water's height over the world point point, above the surface's rest.
glm::vec3 normalAt (const glm::vec2 &point) const
 The surface's unit normal over the world point point.
OceanSample sampleAt (const glm::vec2 &point) const
 Both, for the price of finding the water over point once: what floating things ask.
float significantHeight () const
 Spectral significant wave height, 4 sqrt(m0): the mean of the highest third of the waves.
glm::vec2 farthestReach () const
OceanSurface withoutSurges () const
 The same surface without its surges: the wind's sea alone.

Static Public Member Functions

static OceanSurface at (const Ocean &ocean, const glm::vec3 &centre, double time)
 The surface of ocean, centred at centre, time seconds in.

Public Attributes

std::array< OceanSurge, Ocean::MAX_SURGES > surges {}
 The ocean's, as they stand this moment, each direction unit; one with none is left out.
glm::vec2 centre = glm::vec2(0.0f)
 Where the waves are whole.

Static Public Attributes

static constexpr double GRAVITY = 9.81
 Metres a second squared: what pulls every wave back, and sets how fast each rolls.
static constexpr float SURGE_WHOLE = 0.6f
 Of a surge's length, the share in the middle at its full height; past it each end tapers away.
static constexpr uint32_t INVERSE_STEPS = 4

Detailed Description

An ocean's surface at one moment: the waves the spectrum gives, and what they do.

The one statement of the sum. The renderer uploads these waves and the vertex shaders move a waves material's surface by them (shaders/ocean.glsl, the same arithmetic); gameplay asks the same surface where the water is, so what floats rides what is drawn. Heights are above the moved surface's rest, and points are on the XZ plane.

A point of the water that rests at rest is moved by displacement(rest): Gerstner waves carry the water toward their crests as well as up. heightAt() and normalAt() answer for a point fixed in the world instead, finding the water that is over it.

Member Function Documentation

◆ at()

OceanSurface Vkm::Engine::OceanSurface::at ( const Ocean & ocean,
const glm::vec3 & centre,
double time )
static

The surface of ocean, centred at centre, time seconds in.

The waves depend only on the ocean's fields, so every end that builds one at the same time sees the same sea. Cheap enough to build every frame.

Parameters
oceanThe authored sea.
centreIts Transform's world position; only X and Z are read.
timeSeconds, as NetSession::worldTime gives them; held in double so phases stay exact for hours.
Returns
The surface; with no waves (count 0) for a windless or bandless ocean, though its surges still lift the water.

◆ farthestReach()

glm::vec2 Vkm::Engine::OceanSurface::farthestReach ( ) const

The farthest the water can be carried: x across, y up or down, with every wave in step and every surge crossing there.

Member Data Documentation

◆ INVERSE_STEPS

uint32_t Vkm::Engine::OceanSurface::INVERSE_STEPS = 4
staticconstexpr

Fixed-point steps from a world point back to the water resting under it: the sum never folds (its steepness), so each step is a contraction; these few leave millimetres at the steepest.


The documentation for this struct was generated from the following file: