Browse Source

Add logarithmic zoom to nuptial flight cam

master
C. J. Howard 2 years ago
parent
commit
9ac47d2fe0
6 changed files with 37 additions and 21 deletions
  1. +1
    -1
      src/game/ant/swarm.cpp
  2. +3
    -0
      src/game/state/main-menu.cpp
  3. +26
    -19
      src/game/state/nuptial-flight.cpp
  4. +4
    -0
      src/game/state/nuptial-flight.hpp
  5. +1
    -0
      src/game/state/pause-menu.cpp
  6. +2
    -1
      src/game/state/splash.cpp

+ 1
- 1
src/game/ant/swarm.cpp View File

@ -71,7 +71,7 @@ entity::id create_swarm(game::context& ctx)
// Init picking component // Init picking component
game::component::picking picking; game::component::picking picking;
picking.sphere = {float3{0, 0, 0}, 0.5f};
picking.sphere = {float3{0, 0, 0}, 0.5f * 2.0f};
std::uint32_t male_picking_flags = 0b01; std::uint32_t male_picking_flags = 0b01;
std::uint32_t queen_picking_flags = 0b10; std::uint32_t queen_picking_flags = 0b10;

+ 3
- 0
src/game/state/main-menu.cpp View File

@ -290,6 +290,9 @@ main_menu::~main_menu()
game::menu::remove_text_from_ui(ctx); game::menu::remove_text_from_ui(ctx);
game::menu::delete_text(ctx); game::menu::delete_text(ctx);
// Hide menu BG
ctx.menu_bg_billboard->set_active(false);
// Destruct title animation // Destruct title animation
ctx.animator->remove_animation(&title_fade_animation); ctx.animator->remove_animation(&title_fade_animation);

+ 26
- 19
src/game/state/nuptial-flight.cpp View File

@ -118,7 +118,7 @@ nuptial_flight::nuptial_flight(game::context& ctx):
); );
// Queue fade in // Queue fade in
ctx.fade_transition_color->set_value({0, 0, 0});
ctx.fade_transition_color->set_value({1, 1, 1});
ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, config::nuptial_flight_fade_in_duration, true, ease<float>::out_sine, true, nullptr)); ctx.function_queue.push(std::bind(&screen_transition::transition, ctx.fade_transition, config::nuptial_flight_fade_in_duration, true, ease<float>::out_sine, true, nullptr));
// Queue control setup // Queue control setup
@ -259,6 +259,8 @@ void nuptial_flight::create_camera_rig()
ctx.entity_registry->emplace<component::camera>(camera_rig_eid, camera_rig_camera); ctx.entity_registry->emplace<component::camera>(camera_rig_eid, camera_rig_camera);
ctx.entity_registry->emplace<component::transform>(camera_rig_eid, camera_rig_transform); ctx.entity_registry->emplace<component::transform>(camera_rig_eid, camera_rig_transform);
ctx.entity_registry->emplace<component::constraint_stack>(camera_rig_eid, camera_rig_constraint_stack); ctx.entity_registry->emplace<component::constraint_stack>(camera_rig_eid, camera_rig_constraint_stack);
set_camera_rig_zoom(0.5f);
} }
void nuptial_flight::destroy_camera_rig() void nuptial_flight::destroy_camera_rig()
@ -271,7 +273,24 @@ void nuptial_flight::destroy_camera_rig()
ctx.entity_registry->destroy(camera_rig_focus_eid); ctx.entity_registry->destroy(camera_rig_focus_eid);
ctx.entity_registry->destroy(camera_rig_focus_ease_to_eid); ctx.entity_registry->destroy(camera_rig_focus_ease_to_eid);
}
void nuptial_flight::set_camera_rig_zoom(float zoom)
{
const float near_distance = 1.0f;
const float far_distance = 50.0f;
camera_rig_zoom = zoom;
const float distance = math::log_lerp(far_distance, near_distance, camera_rig_zoom);
ctx.entity_registry->patch<component::constraint::spring_translation>
(
camera_rig_spring_translation_eid,
[&](auto& component)
{
component.spring.x1[2] = distance;
}
);
} }
void nuptial_flight::enable_controls() void nuptial_flight::enable_controls()
@ -320,6 +339,8 @@ void nuptial_flight::enable_controls()
const float gamepad_tilt_factor = gamepad_tilt_sensitivity * (gamepad_invert_tilt ? -1.0f : 1.0f); const float gamepad_tilt_factor = gamepad_tilt_sensitivity * (gamepad_invert_tilt ? -1.0f : 1.0f);
const float gamepad_pan_factor = gamepad_pan_sensitivity * (gamepad_invert_pan ? -1.0f : 1.0f); const float gamepad_pan_factor = gamepad_pan_sensitivity * (gamepad_invert_pan ? -1.0f : 1.0f);
const float dolly_zoom_speed = 4.0f;
// Mouse look // Mouse look
ctx.controls["mouse_look"]->set_activated_callback ctx.controls["mouse_look"]->set_activated_callback
( (
@ -484,32 +505,18 @@ void nuptial_flight::enable_controls()
// Dolly in control // Dolly in control
ctx.controls["move_up"]->set_active_callback ctx.controls["move_up"]->set_active_callback
( (
[&](float value)
[&, dolly_zoom_speed](float value)
{ {
ctx.entity_registry->patch<component::constraint::spring_translation>
(
camera_rig_spring_translation_eid,
[&](auto& component)
{
component.spring.x1[2] -= 100.0f * static_cast<float>(ctx.loop.get_update_period());
}
);
set_camera_rig_zoom(std::min(1.0f, camera_rig_zoom + dolly_zoom_speed * static_cast<float>(ctx.loop.get_update_period())));
} }
); );
// Dolly out control // Dolly out control
ctx.controls["move_down"]->set_active_callback ctx.controls["move_down"]->set_active_callback
( (
[&](float value)
[&, dolly_zoom_speed](float value)
{ {
ctx.entity_registry->patch<component::constraint::spring_translation>
(
camera_rig_spring_translation_eid,
[&](auto& component)
{
component.spring.x1[2] += 100.0f * static_cast<float>(ctx.loop.get_update_period());
}
);
set_camera_rig_zoom(std::max(0.0f, camera_rig_zoom - dolly_zoom_speed * static_cast<float>(ctx.loop.get_update_period())));
} }
); );

+ 4
- 0
src/game/state/nuptial-flight.hpp View File

@ -37,6 +37,8 @@ private:
void create_camera_rig(); void create_camera_rig();
void destroy_camera_rig(); void destroy_camera_rig();
void set_camera_rig_zoom(float zoom);
void enable_controls(); void enable_controls();
void disable_controls(); void disable_controls();
@ -52,6 +54,8 @@ private:
entity::id camera_rig_copy_translation_eid; entity::id camera_rig_copy_translation_eid;
entity::id camera_rig_pivot_eid; entity::id camera_rig_pivot_eid;
float camera_rig_zoom;
entity::id swarm_eid; entity::id swarm_eid;
std::uint32_t selected_picking_flag; std::uint32_t selected_picking_flag;

+ 1
- 0
src/game/state/pause-menu.cpp View File

@ -139,6 +139,7 @@ pause_menu::pause_menu(game::context& ctx):
{ {
ctx.menu_bg_billboard->set_active(false); ctx.menu_bg_billboard->set_active(false);
ctx.state_machine.pop(); ctx.state_machine.pop();
ctx.state_machine.pop();
ctx.state_machine.emplace(new game::state::main_menu(ctx, true)); ctx.state_machine.emplace(new game::state::main_menu(ctx, true));
} }
); );

+ 2
- 1
src/game/state/splash.cpp View File

@ -117,7 +117,8 @@ splash::splash(game::context& ctx):
[&ctx]() [&ctx]()
{ {
ctx.state_machine.pop(); ctx.state_machine.pop();
ctx.state_machine.emplace(new game::state::nuptial_flight(ctx));
ctx.state_machine.emplace(new game::state::main_menu(ctx, true));
//ctx.state_machine.emplace(new game::state::nuptial_flight(ctx));
} }
); );
} }

Loading…
Cancel
Save