mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-05 16:55:32 +01:00
feat(world): the sky over the camera on a curved body, the light of the sun in world space
Step 4 of docs/world-format-eu07.md, its second part. On a curved body the sun and the moon are worked out for the latitude and longitude of the camera (sky.cameraplace, on by default, as settled in #516; off keeps 52 N 19 E). The sky and the weather take the sun in the local axes at the camera; after them the direction of the sun light is turned into the axes of the world, which it shades and casts its shadows in. The sun, the moon and the stars are drawn with the view turned to the local axes. On the plane, the only body loaded today, nothing is turned or moved.
This commit is contained in:
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulation/simulationsounds.h"
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/Timer.h"
|
||||
#include "world/worldgeometry.h"
|
||||
|
||||
namespace simulation {
|
||||
|
||||
@@ -123,6 +124,19 @@ void
|
||||
world_environment::update() {
|
||||
// the clouds move with the wind, a change of the weather goes on; the overcast and fog range follow a described weather
|
||||
m_weather.update( Timer::GetDeltaTime(), Global.pCamera.Pos );
|
||||
// the sky of a curved body is the one over the camera (sky.cameraplace)
|
||||
if( auto const &body { world_geometry::current_body() }; body.curved() && Global.sky_camera_place ) {
|
||||
auto const place { world_geometry::to_geodetic( body, Global.pCamera.Pos ) };
|
||||
m_sun.set_observer( glm::degrees( place.longitude ), glm::degrees( place.latitude ) );
|
||||
m_moon.set_observer( glm::degrees( place.longitude ), glm::degrees( place.latitude ) );
|
||||
m_observer_at_camera = true;
|
||||
}
|
||||
else if( m_observer_at_camera ) {
|
||||
// back to the place they're set to at the start
|
||||
m_sun.setLocation( 19.00f, 52.00f );
|
||||
m_moon.setLocation( 19.00f, 52.00f );
|
||||
m_observer_at_camera = false;
|
||||
}
|
||||
// move celestial bodies...
|
||||
m_sun.update();
|
||||
m_moon.update();
|
||||
|
||||
Reference in New Issue
Block a user