+void Layout3D::tick()
+{
+ Time::TimeDelta t = layout.get_clock().get_current_time();
+ Angle time_of_day = Angle::from_turns(t/Time::day);
+ Angle latitude = Angle::from_degrees(52.5);
+ Angle axial_tilt = Angle::from_degrees(23.45);
+ Transform trans = Transform::rotation(Angle::quarter_turn()-latitude, Vector(-1, 0, 0))*
+ Transform::rotation(Angle::half_turn()-time_of_day, Vector(0, 0, 1))*
+ Transform::rotation(axial_tilt, Vector(-1, 0, 0));
+ Vector sun_dir = trans.transform_linear(Vector(0, -1, 0));
+ Vector diff = Vector(sun.get_position())-sun_dir;
+ if(diff.norm()>0.0025f)
+ sun.set_position(GL::Vector4(sun_dir, 0.0f));
+ // TODO replace these very unscientific guesses with correct formulas
+ lighting.set_ambient(GL::Color(pow(0.2f*(sun_dir.z+1.0f), 2.0f)));
+ sun.set_diffuse(GL::Color(0.7f*max(sun_dir.z, 0.0f)));
+}
+