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
9namespace Grindstone {
10 class BaseRenderer;
11 struct TransformComponent;
12 struct CameraComponent;
13
14 namespace GraphicsAPI {
15 class Framebuffer;
16 class Image;
17 class Sampler;
18 class CommandBuffer;
19 class DescriptorSet;
21 class RenderPass;
22 }
23
24 namespace Editor {
25 class EditorCamera {
26 public:
27 static void SetupRenderPasses();
28 EditorCamera();
29 ~EditorCamera();
30 void CaptureMousePick(GraphicsAPI::CommandBuffer* commandBuffer, int x, int y);
31 uint32_t GetMousePickedEntity(GraphicsAPI::CommandBuffer* commandBuffer);
32 uint64_t GetRenderOutput();
33 void Render(GraphicsAPI::CommandBuffer* commandBuffer);
34 void RenderPlayModeCamera(GraphicsAPI::CommandBuffer* commandBuffer);
35 void OffsetRotation(float pitch, float yaw);
36 void OffsetPosition(float x, float y, float z);
37 void ResizeViewport(uint32_t width, uint32_t height);
38 void UpdateProjectionMatrix();
39 void UpdateViewMatrix();
40 glm::mat4& GetProjectionMatrix();
41 glm::mat4& GetViewMatrix();
42 BaseRenderer* GetRenderer() const;
43
44 bool isGridEnabled = true;
45 bool isBoundingSphereGizmoEnabled = false;
46 bool isBoundingBoxGizmoEnabled = false;
47 bool isColliderGizmoEnabled = true;
48 private:
49 glm::vec3 GetForward() const;
50 glm::vec3 GetRight() const;
51 glm::vec3 GetUp() const;
52
53 GizmoRenderer gizmoRenderer;
54 GridRenderer gridRenderer;
55 GraphicsAPI::Image* renderTarget = nullptr;
56 GraphicsAPI::Image* depthTarget = nullptr;
57 GraphicsAPI::Sampler* sampler = nullptr;
58 GraphicsAPI::DescriptorSetLayout* descriptorSetLayout = nullptr;
59 GraphicsAPI::DescriptorSet* descriptorSet = nullptr;
60 GraphicsAPI::Framebuffer* framebuffer = nullptr;
61
62 GraphicsAPI::DescriptorSetLayout* mousePickDescriptorSetLayout = nullptr;
63 std::array<GraphicsAPI::Image*, 3> mousePickRenderTarget{};
64 std::array<GraphicsAPI::Framebuffer*, 3> mousePickFramebuffer{};
65 std::array<GraphicsAPI::DescriptorSet*, 3> mousePickDescriptorSet{};
66 std::array<GraphicsAPI::Buffer*, 3> mousePickMatrixBuffer{};
67 std::array<GraphicsAPI::Buffer*, 3> mousePickResponseBuffer{};
68
69 BaseRenderer* renderer = nullptr;
70 glm::mat4 projection;
71 glm::mat4 view;
72 glm::vec3 position = glm::vec3();
73 glm::vec3 eulerAngles = glm::vec3();
74 glm::quat rotation = glm::quat();
75 uint32_t width = 800;
76 uint32_t height = 600;
77 float fieldOfView = glm::radians(80.0f);
78 float nearPlaneDistance = 0.1f;
79 float farPlaneDistance = 150.f;
80 };
81 }
82}
Definition BaseRenderer.hpp:19
Definition CameraComponent.cs:2
Definition GizmoRenderer.hpp:21
Definition GridRenderer.hpp:20
Definition CommandBuffer.hpp:73
Definition DescriptorSetLayout.hpp:13
Definition DescriptorSet.hpp:15
Definition Framebuffer.hpp:16
Definition Image.hpp:48
Definition RenderPass.hpp:27
Definition Sampler.hpp:31
Definition TransformComponent.cs:7