Add EditorCameraComponent and EditorCameraSystem
This commit is contained in:
39
include/NazaraEditor/Core/Components/CameraComponent.hpp
Normal file
39
include/NazaraEditor/Core/Components/CameraComponent.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <NazaraEditor/Core/Core.hpp>
|
||||
|
||||
#include <Nazara/Platform/WindowEventHandler.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NodeComponent;
|
||||
class WindowEventHandler;
|
||||
|
||||
class NAZARAEDITOR_CORE_API EditorCameraComponent
|
||||
{
|
||||
public:
|
||||
EditorCameraComponent();
|
||||
EditorCameraComponent(const EditorCameraComponent&) = delete;
|
||||
|
||||
EditorCameraComponent(EditorCameraComponent&&);
|
||||
~EditorCameraComponent();
|
||||
|
||||
void Update(Time elapsedTime, NodeComponent& node);
|
||||
|
||||
inline void SetPosition(const Nz::Vector3f& position) { m_targetPosition = position; }
|
||||
inline void SetRotation(const Nz::Quaternionf& rotation) { m_targetAngles = rotation.ToEulerAngles(); }
|
||||
|
||||
inline const Nz::Vector3f& GetPosition() const { return m_targetPosition; }
|
||||
inline const Nz::EulerAnglesf& GetOrientation() const { return m_targetAngles; }
|
||||
|
||||
private:
|
||||
NazaraSlot(Nz::WindowEventHandler, OnMouseMoved, m_onMouseMoved);
|
||||
|
||||
Nz::EulerAnglesf m_targetAngles;
|
||||
Nz::Vector3f m_targetPosition;
|
||||
Nz::Vector3f m_currentVelocity;
|
||||
|
||||
float m_moveSpeed;
|
||||
float m_smoothSpeed;
|
||||
};
|
||||
}
|
||||
37
include/NazaraEditor/Core/Systems/CameraSystem.hpp
Normal file
37
include/NazaraEditor/Core/Systems/CameraSystem.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <NazaraEditor/Core/Core.hpp>
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARAEDITOR_CORE_API EditorCameraSystem
|
||||
{
|
||||
public:
|
||||
static constexpr bool AllowConcurrent = false;
|
||||
static constexpr Int64 ExecutionOrder = 1'001;
|
||||
|
||||
EditorCameraSystem(entt::registry& registry);
|
||||
~EditorCameraSystem();
|
||||
|
||||
EditorCameraSystem(const EditorCameraSystem&) = delete;
|
||||
EditorCameraSystem& operator=(const EditorCameraSystem&) = delete;
|
||||
|
||||
EditorCameraSystem(EditorCameraSystem&&) = delete;
|
||||
EditorCameraSystem& operator=(EditorCameraSystem&&) = delete;
|
||||
|
||||
void Update(Time elapsedTime);
|
||||
|
||||
private:
|
||||
void OnCameraDestroy(entt::registry& registry, entt::entity entity);
|
||||
|
||||
entt::registry& m_registry;
|
||||
|
||||
entt::observer m_cameraConstructObserver;
|
||||
entt::scoped_connection m_cameraDestroyConnection;
|
||||
|
||||
std::unordered_set<entt::entity> m_cameraEntities;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user