Cloud Keyframer

class CloudKeyframer : public simul::sky::OvercastCallback, public simul::sky::BaseKeyframer

A class to manage interpolation between cloud states over time. Typically, a CloudKeyframer is created and updated by its Environment.

If time and daytime are linked in the SkyKeyframer, time is in days, otherwise the timescale is in arbitrary units.

Public Functions

CloudKeyframer(platform::core::MemoryInterface *mem = NULL)

Constructor.

~CloudKeyframer()

Destructor.

void SetUniformKeyframes(int StepsPerDay, float range = 1.f)

Create a number of evenly spaced keyframes.

void Synchronize()

Restart all the frame-dependent values (mainly wind offsets), for example in order to synchronize rendering across several channels.

int GetExportLightningStrikes(ExportLightningStrike *strikes, int max_s, float game_time, float real_time, const CloudWindow *w) const

Fills the strikes array and returns how many active strikes in the storm NOTE: right now we only consider 1 strike.

const LightningProperties &GetLightningProperties(float game_time, float real_time, const CloudWindow *window) const

Get the properties of the currently active lightning strike.

inline CloudKeyframe &GetInterpolatedKeyframe()

Get the current interpolated keyframe, which holds the values interpolated from the two surrounding keyframes at any given time.

void SetRecalculate()

Force clouds to regenerate.

CloudKeyframe *GetNextModifiableKeyframe()

The next keyframe not partially built or being used. This keyframe’s properties can be modified without any pause or rebuild.

virtual CloudKeyframe *InsertKeyframe(float t, bool insertFromFile = false) override

Insert a new keyframe at time t, sorting in between the existing keyframes if needed, and return a pointer to it.

void DeleteKeyframe(int i)

Remove a keyframe.

void DeleteKeyframeByUID(sky::uid uid)

Remove Keyframe by UID.

virtual int GetNumKeyframes() const override

Number of keyframes.

virtual sky::BaseKeyframe *GetKeyframe(int i) override

Get a pointer to the keyframe with the given ID.

virtual const sky::BaseKeyframe *GetKeyframe(int i) const override

Get a pointer to the i’th keyframe.

virtual void SortKeyframes() override

Make sure the keyframes are in ascending order of time.

virtual sky::OvercastStruct GetOvercastData(double time) const override

For the specified time, get how overcast the sky will be, where the transition starts (e.g. the cloudbase), and what altitude it occurs over (e.g. how tall the clouds are).

virtual bool HasFloat(const char *name) const override

Return true if the keyframe has a float value with the given, case-insensitive, name; return false otherwise.

virtual float GetFloat(const char *name, const base::Variant *params = NULL) const override

Get a float with the given, case-insensitive, name.

virtual float GetDefaultFloat(const char *name) const override

Return the default float value with the given, case-insensitive, name.

virtual void SetFloat(const char *name, float val) override

Set a float with the given, case-insensitive, name.

virtual bool HasInt(const char *name) const override

Return true if the keyframe has an int value with the given, case-insensitive, name; return false otherwise.

virtual int GetInt(const char *name, const base::Variant *params = NULL) const override

Get an int with the given, case-insensitive, name.

virtual int GetDefaultInt(const char *name) const override

Return the default int value with the given, case-insensitive, name.

virtual void SetInt(const char *name, int val) override

Set an int with the given, case-insensitive, name.

void SetCloudRegion(sky::uid id, const CloudRegion &cloudRegion, const CloudRegionState &cloudRegionState)

Set the properties of a custom cloud volume. edge_lower and edge_upper are always set to 1.0f.

void RemoveCloudRegion(sky::uid id)

Remove a custom cloud volume.

void SetSkyInterface(simul::sky::BaseSkyInterface *si)

Set the sky - this is used to light the clouds over time.

void Relocate(const float pos_before[3], const float pos_after[3])

Relocate: to avoid numerical precision problems, relocation can be performed. Specify any position, before and after relocation.

void Update(float new_time, double latitudeRadians, double longitudeRadians, double headingRadians)

Once-per-frame update for the keyframer, call this with an absolute time value (not a time step).

void Reset()

Force recalculation of the per-keyframe tables.

inline float GetInterpolation() const

Get the interpolation - between zero and one. This is based on InterpStepTime and the sky’s Daytime property. When the interpolation reaches one, the textures will be cycled.

void ForceRelight()

For debugging purposes only.

float GetMaximumLocalPrecipitation(const float pos[3]) const

How much precipitation there is at this point. This value is only approximate - it does not account for the actual cloud cover generated on GPU, so it only gives the maximum precipitation that is possible at this point.

void SetLoopWind()

Make the wind offsets loop based on the loop time.

virtual void Save(simul::sky::Output &os) const override

Save to a binary stream:

virtual void Load(simul::sky::Input &is) override

Load from a binary stream:

virtual void SaveToText(platform::crossplatform::TextOutput &output, bool include_keyframes) const override

Save to a text file.

virtual void LoadFromText(platform::crossplatform::TextInput &input) override

Load from a text file.

void New()

Clear keyframes.

void RecalculateOffsets()

Check for changed offsets and recalculate.

platform::math::Vector3 GetInitialOffset() const

Get the offset of the first keyframe, a mutable property determined by Relocate().

platform::math::Vector3 GetGridOrigin() const

Get the origin of the render grid; this is adjusted internally when Relocate() is called.

platform::math::Vector3 GetWindOffsetKm() const

Get the current offset of the cloud window due to wind.

unsigned GetInterpolationChecksum() const

Checksum for the interpolated state.

unsigned GetSubdivisionChecksum() const

This is a checksum that only changes if an in-use subdivision has modified (cycling does not change it).