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 <Common/Rendering/RenderGraphBuilder.hpp>
7#include "GridRenderer.hpp"
8#include "GizmoRenderer.hpp"
9
11 glm::mat4 projectionMatrix;
12 glm::mat4 viewMatrix;
13 glm::mat4 inverseProjectionMatrix;
14 glm::mat4 inverseViewMatrix;
15 glm::vec3 eyePos;
16 float alignmentBufferForPreviousVec3;
17 glm::vec2 framebufferResolution;
18 glm::vec2 renderResolution;
19 glm::vec2 renderScale;
20 float time;
21};
22
23namespace Grindstone {
24 class BaseRenderer;
25 struct TransformComponent;
26 struct CameraComponent;
27
28 namespace GraphicsAPI {
29 class Framebuffer;
30 class Image;
31 class Sampler;
32 class CommandBuffer;
33 class DescriptorSet;
34 class DescriptorSetLayout;
35 class RenderPass;
36 }
37
38 namespace Editor {
39 class EditorCamera {
40 public:
41 static void SetupRenderPasses();
42 EditorCamera();
43 ~EditorCamera();
45 void CaptureMousePick(int x, int y);
46 uint32_t GetMousePickedEntity(GraphicsAPI::CommandBuffer* commandBuffer);
47 uint64_t GetRenderOutput();
48 void Render(GraphicsAPI::CommandBuffer* commandBuffer);
49 void RenderPlayModeCamera(GraphicsAPI::CommandBuffer* commandBuffer);
50 void OffsetRotation(float pitch, float yaw);
51 void OffsetPosition(glm::vec3 offset);
52 void SetPosition(glm::vec3 newPosition);
53 void ResizeViewport(uint32_t width, uint32_t height);
54 void UpdateProjectionMatrix();
55 void UpdateViewMatrix();
56 glm::mat4& GetProjectionMatrix();
57 glm::mat4& GetViewMatrix();
58 BaseRenderer* GetRenderer() const;
59 void ClearRenderer();
60
61 glm::vec3 GetPosition() const;
62 glm::vec3 GetForward() const;
63 glm::vec3 GetRight() const;
64 glm::vec3 GetUp() const;
65
66 bool isGridEnabled = true;
67 bool isBoundingSphereGizmoEnabled = false;
68 bool isBoundingBoxGizmoEnabled = false;
69 bool isColliderGizmoEnabled = true;
70 bool captureThisFrame = false;
71 int captureX = 0;
72 int captureY = 0;
73 private:
74 GraphicsAPI::Buffer* gpuGlobalUniformBufferObject = nullptr;
75
76 Grindstone::GraphicsAPI::DescriptorSetLayout* globalDescriptorSetLayout;
77 Grindstone::GraphicsAPI::Buffer* globalStagingUniformBufferObject;
78 std::array<Grindstone::GraphicsAPI::Buffer*, 3> globalUniformBufferObject;
79 std::array<Grindstone::GraphicsAPI::DescriptorSet*, 3> globalDescriptorSet;
80
81 GizmoRenderer gizmoRenderer;
82 GridRenderer gridRenderer;
83 std::array<GraphicsAPI::Image*, 3> renderTarget;
84 std::array<GraphicsAPI::Image*, 3> depthTarget;
85 GraphicsAPI::Sampler* sampler = nullptr;
86 GraphicsAPI::DescriptorSetLayout* descriptorSetLayout = nullptr;
87 std::array<GraphicsAPI::DescriptorSet*, 3> descriptorSet;
88 std::vector<
89 std::function<
94 )
95 >
96 > gizmoRenderCallbacks;
97
98 GraphicsAPI::DescriptorSetLayout* mousePickDescriptorSetLayout = nullptr;
99 std::array<GraphicsAPI::Image*, 3> mousePickRenderTarget{};
100 std::array<GraphicsAPI::Framebuffer*, 3> mousePickFramebuffer{};
101 std::array<GraphicsAPI::DescriptorSet*, 3> mousePickDescriptorSet{};
102 std::array<GraphicsAPI::Buffer*, 3> mousePickMatrixBuffer{};
103 std::array<GraphicsAPI::Buffer*, 3> mousePickResponseBuffer{};
104
105 BaseRenderer* renderer = nullptr;
106 glm::mat4 projection;
107 glm::mat4 view;
108 glm::vec3 position = glm::vec3();
109 glm::vec3 eulerAngles = glm::vec3();
110 glm::quat rotation = glm::quat();
111 uint32_t width = 800;
112 uint32_t height = 600;
113 float fieldOfView = glm::radians(80.0f);
114 float nearPlaneDistance = 0.1f;
115 float farPlaneDistance = 150.f;
116 };
117 }
118}
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 RenderGraphBuilder.hpp:12
Definition EditorCamera.hpp:10
Definition RenderGraphResourceRef.hpp:51