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(GraphicsAPI::CommandBuffer* commandBuffer, 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 private:
71 GraphicsAPI::Buffer* gpuGlobalUniformBufferObject = nullptr;
72
73 Grindstone::GraphicsAPI::DescriptorSetLayout* globalDescriptorSetLayout;
74 Grindstone::GraphicsAPI::Buffer* globalStagingUniformBufferObject;
75 std::array<Grindstone::GraphicsAPI::Buffer*, 3> globalUniformBufferObject;
76 std::array<Grindstone::GraphicsAPI::DescriptorSet*, 3> globalDescriptorSet;
77
78 GizmoRenderer gizmoRenderer;
79 GridRenderer gridRenderer;
80 std::array<GraphicsAPI::Image*, 3> renderTarget;
81 std::array<GraphicsAPI::Image*, 3> depthTarget;
82 GraphicsAPI::Sampler* sampler = nullptr;
83 GraphicsAPI::DescriptorSetLayout* descriptorSetLayout = nullptr;
84 std::array<GraphicsAPI::DescriptorSet*, 3> descriptorSet;
85 std::vector<
86 std::function<
91 )
92 >
93 > gizmoRenderCallbacks;
94
95 GraphicsAPI::DescriptorSetLayout* mousePickDescriptorSetLayout = nullptr;
96 std::array<GraphicsAPI::Image*, 3> mousePickRenderTarget{};
97 std::array<GraphicsAPI::Framebuffer*, 3> mousePickFramebuffer{};
98 std::array<GraphicsAPI::DescriptorSet*, 3> mousePickDescriptorSet{};
99 std::array<GraphicsAPI::Buffer*, 3> mousePickMatrixBuffer{};
100 std::array<GraphicsAPI::Buffer*, 3> mousePickResponseBuffer{};
101
102 BaseRenderer* renderer = nullptr;
103 glm::mat4 projection;
104 glm::mat4 view;
105 glm::vec3 position = glm::vec3();
106 glm::vec3 eulerAngles = glm::vec3();
107 glm::quat rotation = glm::quat();
108 uint32_t width = 800;
109 uint32_t height = 600;
110 float fieldOfView = glm::radians(80.0f);
111 float nearPlaneDistance = 0.1f;
112 float farPlaneDistance = 150.f;
113 };
114 }
115}
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