CG-Project2
Loading...
Searching...
No Matches
NormalViewState.hpp
1#pragma once
2
3#include "../../include/AppGui.hpp"
4#include "../../include/State/State.hpp"
5
15class NormalViewState : public State {
16public:
17 virtual void onAttach() override;
18 virtual void onDetach() override;
19
20 virtual void onUpdate() override;
21 virtual void onRender() override;
22
23 virtual bool isCurrentStateEnd() override;
24
29 State("Normal View State") {}
30
31 virtual ~NormalViewState() override = default;
32
33private:
37 struct WorldCamera {
39 unsigned int cameraId;
41 Shared<Camera> camera;
43 glm::vec3 cameraSize = glm::vec3(1);
47 int tbBorderTolerance = 20;
49 float tbRadius = 1.f;
50 } world;
51
55 struct Mouse {
57 glm::vec2 pos{};
59 bool first = true;
61 bool trackState = false;
64 bool skipCursorPos = false;
65 } mouse;
66
68 double inputWalltime{};
70 double inputCputime{};
72 double updateWalltime{};
74 double updateCputime{};
76 double renderWalltime{};
78 double renderCputime{};
80 std::array<std::reference_wrapper<double>, 3> walltimes{inputWalltime, updateWalltime, renderWalltime};
82 std::array<std::reference_wrapper<double>, 3> cputimes{inputCputime, updateCputime, renderCputime};
84 std::array<std::string, 3> names{"Input", "Update", "Render"};
85
87 const Event INPUT_NORMAL_VIEW_OPEN = Event("Input in Normal View Start");
89 const Event INPUT_NORMAL_VIEW_CLOSE = Event("Input in Normal View Stop");
91 const Event ENTITY_SELECTED_CHANGED = Event("Entity Selected Changed");
92 const glm::vec3 CAMERA_START_POSITION = glm::vec3{0, 1, 12};
93
95 unsigned int plane;
96
98 int ettSelected = -1;
100 bool renderBB = false;
101
103 Unique<UniformBuffer> ub;
104
106 void enableDefaultCameraMovement();
107
114 glm::vec3 getTrackballPoint(const Pair<float> &viewpSize, const glm::vec2 &pos);
115
123 glm::vec3 getRayFromMouse(const Pair<float> &size, int mouse_x, int mouse_y);
124
136 bool isRayInSphere(const glm::vec3 &ray, const glm::vec3 &sphere_pos, const float &sphere_radius, float *dist);
137
146 enum InputState {
147 MOUSE_PASSIVE,
148 MOUSE_ACTIVE
149 };
150
157 void changeInputState(Window *w, const InputState &state);
158
164 void defaultKeyCallback(Window *w);
165};
This State render an interactive scene with rendered meshes and lights. The user can modify their int...
Definition NormalViewState.hpp:15
virtual void onUpdate() override
This methods contains all the operations executed at every event::loop::LOOP_UPDATE if there are any.
Definition NormalViewState.cpp:530
virtual bool isCurrentStateEnd() override
Retrieves the current binary state of the current State
Definition NormalViewState.cpp:536
virtual void onAttach() override
This method is called after using StateManager::sync() (read StateMnaager::sync() documentation for m...
Definition NormalViewState.cpp:338
virtual void onDetach() override
This method is called while using sync() (read sync() documentation for more info)....
Definition NormalViewState.cpp:518
NormalViewState()
Instances the normal view state.
Definition NormalViewState.hpp:28
virtual void onRender() override
This methods contains all the operations executed at every event::loop::LOOP_RENDER if there are any.
Definition NormalViewState.cpp:533
State(const std::string &name="State")
Instances a state with the given name.
Definition State.hpp:85