Antkeeper  0.0.1
nest-view-state.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_NEST_VIEW_STATE_HPP
21 #define ANTKEEPER_NEST_VIEW_STATE_HPP
22 
24 #include <engine/entity/id.hpp>
25 #include <engine/math/vector.hpp>
26 #include <engine/render/model.hpp>
31 #include <engine/math/angles.hpp>
33 #include <engine/geom/bvh/bvh.hpp>
35 #include "game/ant/ant-phenome.hpp"
36 
38 {
39 public:
40  explicit nest_view_state(::game& ctx);
41  virtual ~nest_view_state();
42 
43 private:
44  void create_third_person_camera_rig();
45  void destroy_third_person_camera_rig();
46 
47  void set_third_person_camera_zoom(double zoom);
48  void set_third_person_camera_rotation(double yaw, double pitch);
49 
50  void zoom_third_person_camera(double zoom);
51  void translate_third_person_camera(const math::dvec3& direction, double magnitude);
52  void rotate_third_person_camera(const input::mouse_moved_event& event);
53 
54  void handle_mouse_motion(const input::mouse_moved_event& event);
55 
56  void update_third_person_camera();
57 
58  [[nodiscard]] geom::ray<float, 3> get_mouse_ray(const math::vec2<std::int32_t>& mouse_position) const;
59 
60  void setup_controls();
61 
62  std::vector<std::shared_ptr<::event::subscription>> action_subscriptions;
63  std::shared_ptr<::event::subscription> mouse_motion_subscription;
64 
65  bool mouse_look{false};
66  bool mouse_grip{false};
67  bool mouse_zoom{false};
68  geom::plane<float> mouse_grip_plane{{0.0, 1.0, 0.0}, 0.0};
69  math::fvec3 mouse_grip_point{};
70 
71  bool moving{false};
72 
73  entity::id third_person_camera_rig_eid{entt::null};
74  double third_person_camera_yaw{0.0};
75  double third_person_camera_pitch{math::radians(45.0)};
76  math::dvec3 third_person_camera_focal_point{0.0, 0.0, 0.0};
77  double third_person_camera_zoom{0.25};
78  std::uint32_t third_person_camera_zoom_step_count{6};
79 
80  double third_person_camera_near_focal_plane_height{2.0f};
81  double third_person_camera_far_focal_plane_height{50.0f};
82 
83  double third_person_camera_near_hfov{math::radians(90.0)};
84  double third_person_camera_far_hfov{math::radians(45.0)};
85 
87  double third_person_camera_speed{1.0f};
88 
89  double third_person_camera_hfov{};
90  double third_person_camera_vfov{};
91  double third_person_camera_focal_plane_width{};
92  double third_person_camera_focal_plane_height{};
93  double third_person_camera_focal_distance{};
94  math::dquat third_person_camera_yaw_rotation{math::dquat::identity()};
95  math::dquat third_person_camera_pitch_rotation{math::dquat::identity()};
96  math::dquat third_person_camera_orientation{math::dquat::identity()};
97 
98  std::shared_ptr<render::matvar_fvec3> light_rectangle_emissive;
99  std::shared_ptr<scene::light_probe> light_probe;
100 
101  std::shared_ptr<geom::brep_mesh> navmesh;
102  std::unique_ptr<geom::bvh> navmesh_bvh;
103  entity::id larva_eid;
104  entity::id worker_eid;
105 
106  ant_phenome worker_phenome;
107  geom::brep_face* navmesh_agent_face{};
108  math::fvec3 navmesh_agent_position{};
109  math::fvec3 navmesh_agent_normal{};
110 };
111 
112 #endif // ANTKEEPER_NEST_VIEW_STATE_HPP
Abstract base class for game states.
Definition: game-state.hpp:29
::game & ctx
Definition: game-state.hpp:44
Definition: game.hpp:121
Portion of a shell bounded by loops.
Definition: brep-face.hpp:244
nest_view_state(::game &ctx)
virtual ~nest_view_state()
entt::entity id
Entity ID type.
Definition: id.hpp:28
Publish-subscribe messaging.
Definition: channel.hpp:32
constexpr T radians(T degrees) noexcept
Converts an angle given in degrees to radians.
Definition: angles.hpp:48
Complete set of ant phenes.
Definition: ant-phenome.hpp:52
n-dimensional plane.
Definition: hyperplane.hpp:36
Half of a line proceeding from an initial point.
Definition: ray.hpp:38
Event generated when a mouse has been moved.
Quaternion composed of a real scalar part and imaginary vector part.
Definition: quaternion.hpp:39
static constexpr quaternion identity() noexcept
Returns a rotation identity quaternion.
Definition: quaternion.hpp:200
n-dimensional vector.
Definition: vector.hpp:44