mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 11:15:23 +01:00
2953bedafa
--snapshot-at <seconds> <file> writes a snapshot when the simulation has run that long, --load-snapshot <file> puts one over the scenery once it has loaded, before the first frame. This layer keeps the clock and the simulation timer, the weather with the wind, the random engine, the memory cells, the switches, the tracks an event can change and the ones made on the run, the traction power sources, the event queue, the timers of the launchers and the lamps of the signals. While a snapshot is put back the event manager is suspended, so nothing in the scenery reacts to it. Existing classes only get accessors for what was private (the fraction of the second, launcher timers, the speed limit of a track, the wind, the state of a power source, the event queue). Without the switches nothing changes.
109 lines
2.8 KiB
C++
109 lines
2.8 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "environment/sky.h"
|
|
#include "environment/sun.h"
|
|
#include "environment/moon.h"
|
|
#include "environment/stars.h"
|
|
#include "environment/skydome.h"
|
|
#include "rendering/precipitation.h"
|
|
#include "audio/sound.h"
|
|
|
|
#include <array>
|
|
|
|
class opengl_renderer;
|
|
class opengl33_renderer;
|
|
|
|
// wrapper for environment elements -- sky, sun, stars, clouds etc
|
|
class world_environment {
|
|
|
|
friend opengl_renderer;
|
|
friend opengl33_renderer;
|
|
|
|
public:
|
|
// methods
|
|
void init();
|
|
void update();
|
|
void update_precipitation();
|
|
void update_moon();
|
|
void time( int const Hour = -1, int const Minute = -1, int const Second = -1 );
|
|
// switches between static and dynamic daylight calculation
|
|
void on_daylight_change();
|
|
// calculates current season of the year based on set simulation date
|
|
void compute_season( int const Yearday );
|
|
// calculates current weather
|
|
void compute_weather() const;
|
|
// data access
|
|
inline auto const &
|
|
sun() const {
|
|
return m_sun; }
|
|
inline auto const &
|
|
moon() const {
|
|
return m_moon; }
|
|
inline auto const &
|
|
light_intensity() const {
|
|
return m_lightintensity; }
|
|
inline auto const &
|
|
skydome() const {
|
|
return m_skydome; }
|
|
inline auto &
|
|
skydome() {
|
|
return m_skydome; }
|
|
inline auto const &
|
|
precipitation() const {
|
|
return m_precipitation; }
|
|
inline auto const &
|
|
wind() const {
|
|
return m_wind.vector; }
|
|
inline auto const &
|
|
wind_azimuth() const {
|
|
return m_wind.azimuth; }
|
|
// the wind as it blows and as it is about to change, for a snapshot of the simulation, which puts it back:
|
|
// azimuth and its change, velocity and its change, the time to the next change, the vector
|
|
std::array<float, 8>
|
|
wind_state() const;
|
|
void
|
|
wind_state( std::array<float, 8> const &State );
|
|
|
|
private:
|
|
// types
|
|
struct basic_wind {
|
|
// internal state data
|
|
float azimuth;
|
|
float azimuth_change;
|
|
float velocity;
|
|
float velocity_change;
|
|
float change_time;
|
|
// output
|
|
glm::vec3 vector;
|
|
};
|
|
// methods
|
|
void update_wind();
|
|
// members
|
|
CSkyDome m_skydome;
|
|
cStars m_stars;
|
|
cSun m_sun;
|
|
cMoon m_moon;
|
|
float m_lightintensity { 1.f };
|
|
TSky m_clouds;
|
|
basic_precipitation m_precipitation;
|
|
sound_source m_rainsound { sound_placement::external, -1 };
|
|
basic_wind m_wind;
|
|
};
|
|
|
|
namespace simulation {
|
|
|
|
extern world_environment Environment;
|
|
|
|
} // simulation
|
|
|
|
//---------------------------------------------------------------------------
|