3#include "World/Entity.h"
4#include "Render/FrameInfo.h"
5#include "Core/Input/KeyCodes.h"
6#include "Core/Input/Input.h"
7#include "Core/Input/MouseButtonCodes.h"
13 Entity entity(m_Owner, FrameInfo::Get().m_World.get());
14 m_CameraTranComp = &entity.GetComponent<TransformComponent>();
21 const glm::vec2& mouse { Input::GetMouseX(), Input::GetMouseY() };
22 const glm::vec2 delta = (mouse - m_InitialMousePosition) * 0.003f;
23 m_InitialMousePosition = mouse;
46 m_FocalPoint += -GetRightDirection() * delta.x * xSpeed * m_Distance;
47 m_FocalPoint += GetUpDirection() * delta.y * ySpeed * m_Distance;
52 glm::vec3 rot = std::any_cast<TransformComponent*>(m_CameraTranComp)->GetRotation();
53 const float yawSign = GetUpDirection().y < 0 ? -1.0f : 1.0f;
55 rot.y += glm::degrees(yawSign * delta.x * RotationSpeed());
56 rot.x += glm::degrees(delta.y * RotationSpeed());
58 std::any_cast<TransformComponent*>(m_CameraTranComp)->SetRotation(rot);
66 m_FocalPoint += GetForwardDirection();
74 float xFactor = 0.0366f * (x * x) - 0.1778f * x + 0.3021f;
77 float yFactor = 0.0366f * (y * y) - 0.1778f * y + 0.3021f;
79 return { xFactor, yFactor };
90 distance = std::max(distance, 0.0f);
91 float speed = distance * distance;
92 speed = std::min(speed, 100.0f);
98 const glm::vec3 pos = CalculatePosition();
99 std::any_cast<TransformComponent*>(m_CameraTranComp)->SetPosition(pos);
106 return m_FocalPoint - GetForwardDirection() * m_Distance;
111 return glm::rotate(GetOrientation(), glm::vec3(0.0f, -1.0f, 0.0f));
116 return glm::rotate(GetOrientation(), glm::vec3(1.0f, 0.0f, 0.0f));
121 return glm::rotate(GetOrientation(), glm::vec3(0.0f, 0.0f, 1.0f));
126 const glm::vec3& rot = std::any_cast<TransformComponent*>(m_CameraTranComp)->GetRotation();
127 return glm::quat(glm::vec3(rot.x, rot.y, rot.z));
#define BIND_EVENT_FN(x)
Bind Event.
Entity Class. This class defines the specific behaves of Entity.
EventDispatcher(Event &event)
Constructor Function.
This Class store a Specific Event type first and Dispatch a event handle function to it.
This Class is the basic Event Class. Inherit from it and create specific event class.
This Class is inherited from KeyEvent Class.
void MouseZoom(float delta)
bool OnKeyPressed(KeyPressedEvent &e)
glm::vec3 GetForwardDirection() const
glm::vec3 GetRightDirection() const
virtual void OnEvent(Event &e) override
This interface defines the behaves on specific component event happened.
virtual void OnTick(TimeStep &ts) override
This interface defines the behaves on specific component tick every frame.
float RotationSpeed() const
std::pair< float, float > PanSpeed() const
void MouseRotate(const glm::vec2 &delta) const
glm::vec3 CalculatePosition() const
virtual void OnConstruction() override
This interface defines the behaves on specific component added.
glm::quat GetOrientation() const
void MousePan(const glm::vec2 &delta)
glm::vec3 GetUpDirection() const
This Class handles our engine time step during frames. Global Unique.