sphere_morph(0.0f),
sphere_frozen(false),
sphere_stopped(false),
+ sun(resources.get<GL::DirectionalLight>("Sun.light")),
+ sun_angle(Geometry::Angle<float>::from_turns(0.1f)),
camera_stopped(false)
{
window.set_title("Desert Pillars");
global_env->set_fixed_position(GL::Vector3(0.0f, 0.0f, 0.0f));
global_env->set_debug_name("Global environment");
- GL::DirectionalLight &sun = resources.get<GL::DirectionalLight>("Sun.light");
sky = make_unique<GL::Sky>(*global_env, sun);
sky->set_debug_name("Sky");
view.set_content(sequence.get());
view.set_camera(&camera);
+ const GL::Vector3 &sun_direction = sun.get_direction();
+ sun_node = normalize(GL::Vector3(sun_direction.y, -sun_direction.x, 0.0f));
+ sun_axis = normalize(cross(sun_direction, sun_node));
+
const GL::Vector3 &cam_pos = camera.get_position();
camera_distance = cam_pos.norm();
camera_angle = Geometry::atan2(cam_pos.y, cam_pos.x);
camera.set_look_direction(-cam_dir);
}
+ sun_angle += Geometry::Angle<float>::from_degrees(4*dt/Time::sec);
+ sun.set_direction(GL::Matrix::rotation(sun_angle, sun_axis)*-sun_node);
+
display.tick();
view.render();
}
bool sphere_frozen;
bool sphere_stopped;
+ Msp::GL::DirectionalLight &sun;
+ Msp::GL::Vector3 sun_node;
+ Msp::GL::Vector3 sun_axis;
+ Msp::Geometry::Angle<float> sun_angle;
+
float camera_distance;
Msp::Geometry::Angle<float> camera_base_height;
Msp::Geometry::Angle<float> camera_angle;