QtCraft API C++ classes QML types Handbook

QcAmbience Class

Levels (0..1) of the four ambience loops, chosen from the surroundings with simple rules: wind under the open sky (stronger up high), a cave rumble under a thick rock ceiling, water when water blocks are near, rain while it rains where the listener is (muffled under a roof, faint in a cave). More...

Header: #include <clientcore/sound/QcAmbience.h>

Public Types

struct Levels

Static Public Members

QcAmbience::Levels approach(QcAmbience::Levels current, QcAmbience::Levels target, double seconds)
const float arriveLevel
const double calmHeight
const double calmWind
const int caveCeiling
const int ceilingScan
const double easeSeconds
const double fadePerSecond
const double fullWaterBlocks
const double lavaPopChance
std::optional<QcBlockPos> nearestGlowingLiquid(const QcBlockAccess &world, const QcVec3 &eye)
const double rainInCave
const double rainUnderRoof
const double rainWind
const int shelterRadius
const double stormHeight
QcAmbience::Levels targets(const QcBlockAccess &world, const QcVec3 &eye, double rain = 0.0)
const double waterFadeDistance
const int waterRadius
const double windUnderRoof

Detailed Description

Sky and ceiling are averaged over the columns around the listener, water is one level for all water nearby (nearer blocks count more, capped at 1), so the levels change gently while the listener moves, even fast in a minecart. The loops cross-fade by easing the levels towards their targets. Glowing liquids (lava) are no water: they pop now and then instead.

Member Function Documentation

[static] QcAmbience::Levels QcAmbience::approach(QcAmbience::Levels current, QcAmbience::Levels target, double seconds)

Returns current moved towards target over seconds: a share 1 - exp(-seconds / easeSeconds) of the way, at most fadePerSecond * seconds per loop.

[static] std::optional<QcBlockPos> QcAmbience::nearestGlowingLiquid(const QcBlockAccess &world, const QcVec3 &eye)

Returns the nearest glowing liquid (lava) among the blocks of world sampled for water around eye, if any.

[static] QcAmbience::Levels QcAmbience::targets(const QcBlockAccess &world, const QcVec3 &eye, double rain = 0.0)

Returns the target levels in world for a listener whose eyes are at eye, while rain of strength rain (0..1; 0 where it snows or stays dry) falls there. Unloaded blocks count as air.

Member Variable Documentation

const double QcAmbience::calmWind

Wind under the open sky at calmHeight and below in dry weather: a faint breeze, so that the usual soundscape is no constant rush; heights and rain (storms) raise it, by up to rainWind at full rain, up to 1 together.

const double QcAmbience::lavaPopChance

Chance per ambience sample that lava nearby pops.

const double QcAmbience::rainWind

Most the rain adds to the wind, at full rain.

const int QcAmbience::shelterRadius

Columns sampled for sky and ceiling: every second block up to this far to each side.

const double QcAmbience::windUnderRoof

Share of the wind heard under a roof or a tree.