Cloud Keyframer

class simul::clouds::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(simul::base::MemoryInterface *mem = NULL, bool make2d = false)

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.

inline int GetNumStorms() const

The number of storms on the timeline.

Storm *AddStorm(float t0, float t1, crossplatform::Quaterniond origin, float r_km)

Add a storm between the times specified, at the given centre c, with horizontal radius r (km).

const Storm *GetStorm(float t) const

Get the storm, if any, that is active at time t.

Storm *GetStorm(float t)

Get the storm, if any, that is active at time t.

Storm *GetStormByUniqueId(sky::uid uid)

Return the storm with unique identifier uid.

const Storm *GetStormByUniqueId(sky::uid uid) const

Return the storm with unique identifier uid.

Storm *GetStorm(int i)

Return the storm with index i.

void DeleteStorm(int i)

Remove the storm with index i.

void DeleteStormByUniqueId(sky::uid uid)

Remove the storm with unique id uid.

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) 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 SetVolume(sky::uid id, CloudVolumeType type, const crossplatform::Quaterniond &orig, vec2 lscale, vec2 uscale, vec2 rake, vec2 height_range_km)

Set the properties of a custom cloud volume:

void RemoveVolume(sky::uid id)

Remove a custom cloud volume.

CloudInterface *GetCloudInterface()

Set the cloud interface. As the constructor needs a CloudInterface, it is not usually necessary to call this.

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)

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:

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

Save to a text file.

void LoadFromText(simul::crossplatform::TextInput &input) override

Load from a text file.

void New()

Clear keyframes.

void RecalculateOffsets()

Check for changed offsets and recalculate.

math::Vector3 GetInitialOffset() const

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

math::Vector3 GetGridOrigin() const

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

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).