Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
EditorCamera.hpp
1#pragma once
2
3#include <glm/glm.hpp>
4#include <glm/gtc/quaternion.hpp>
5
6#include "GridRenderer.hpp"
7#include "GizmoRenderer.hpp"
8
10 glm::mat4 projectionMatrix;
11 glm::mat4 viewMatrix;
12 glm::mat4 inverseProjectionMatrix;
13 glm::mat4 inverseViewMatrix;
14 glm::vec3 eyePos;
15 float alignmentBufferForPreviousVec3;
16 glm::vec2 framebufferResolution;
17 glm::vec2 renderResolution;
18 glm::vec2 renderScale;
19 float time;
20};
21
22namespace Grindstone {
23 class BaseRenderer;
24 struct TransformComponent;
25 struct CameraComponent;
26
27 namespace GraphicsAPI {
28 class Framebuffer;
29 class Image;
30 class Sampler;
31 class CommandBuffer;
32 class DescriptorSet;
33 class DescriptorSetLayout;
34 class RenderPass;
35 }
36
37 namespace Editor {
38 class EditorCamera {
39 public:
40 static void SetupRenderPasses();
41 EditorCamera();
42 ~EditorCamera();
43 void CaptureMousePick(GraphicsAPI::CommandBuffer* commandBuffer, int x, int y);
44 uint32_t GetMousePickedEntity(GraphicsAPI::CommandBuffer* commandBuffer);
45 uint64_t GetRenderOutput();
46 void Render(GraphicsAPI::CommandBuffer* commandBuffer);
47 void RenderPlayModeCamera(GraphicsAPI::CommandBuffer* commandBuffer);
48 void OffsetRotation(float pitch, float yaw);
49 void OffsetPosition(glm::vec3 offset);
50 void SetPosition(glm::vec3 newPosition);
51 void ResizeViewport(uint32_t width, uint32_t height);
52 void UpdateProjectionMatrix();
53 void UpdateViewMatrix();
54 glm::mat4& GetProjectionMatrix();
55 glm::mat4& GetViewMatrix();
56 BaseRenderer* GetRenderer() const;
57
58 glm::vec3 GetPosition() const;
59 glm::vec3 GetForward() const;
60 glm::vec3 GetRight() const;
61 glm::vec3 GetUp() const;
62
63 bool isGridEnabled = true;
64 bool isBoundingSphereGizmoEnabled = false;
65 bool isBoundingBoxGizmoEnabled = false;
66 bool isColliderGizmoEnabled = true;
67 private:
68 GraphicsAPI::Buffer* gpuGlobalUniformBufferObject = nullptr;
69
70 Grindstone::GraphicsAPI::DescriptorSetLayout* globalDescriptorSetLayout;
71 Grindstone::GraphicsAPI::Buffer* globalStagingUniformBufferObject;
72 std::array<Grindstone::GraphicsAPI::Buffer*, 3> globalUniformBufferObject;
73 std::array<Grindstone::GraphicsAPI::DescriptorSet*, 3> globalDescriptorSet;
74
75 GizmoRenderer gizmoRenderer;
76 GridRenderer gridRenderer;
77 std::array<GraphicsAPI::Image*, 3> renderTarget;
78 std::array<GraphicsAPI::Image*, 3> depthTarget;
79 GraphicsAPI::Sampler* sampler = nullptr;
80 GraphicsAPI::DescriptorSetLayout* descriptorSetLayout = nullptr;
81 std::array<GraphicsAPI::DescriptorSet*, 3> descriptorSet;
82
83 GraphicsAPI::DescriptorSetLayout* mousePickDescriptorSetLayout = nullptr;
84 std::array<GraphicsAPI::Image*, 3> mousePickRenderTarget{};
85 std::array<GraphicsAPI::Framebuffer*, 3> mousePickFramebuffer{};
86 std::array<GraphicsAPI::DescriptorSet*, 3> mousePickDescriptorSet{};
87 std::array<GraphicsAPI::Buffer*, 3> mousePickMatrixBuffer{};
88 std::array<GraphicsAPI::Buffer*, 3> mousePickResponseBuffer{};
89
90 BaseRenderer* renderer = nullptr;
91 glm::mat4 projection;
92 glm::mat4 view;
93 glm::vec3 position = glm::vec3();
94 glm::vec3 eulerAngles = glm::vec3();
95 glm::quat rotation = glm::quat();
96 uint32_t width = 800;
97 uint32_t height = 600;
98 float fieldOfView = glm::radians(80.0f);
99 float nearPlaneDistance = 0.1f;
100 float farPlaneDistance = 150.f;
101 };
102 }
103}
Definition BaseRenderer.hpp:22
Definition GizmoRenderer.hpp:21
Definition GridRenderer.hpp:20
Definition Buffer.hpp:49
Definition CommandBuffer.hpp:109
Definition DescriptorSetLayout.hpp:14
Definition Sampler.hpp:49
Definition EditorCamera.hpp:9