12 struct CameraMatrices {
25 MANDRILL_NON_COPYABLE(
Camera)
33 MANDRILL_API
Camera(ptr<Device> pDevice, GLFWwindow* pWindow, ptr<Swapchain> pSwapchain);
52 MANDRILL_API
void update(
float delta, glm::vec2 cursorDelta);
60 return mMouseCaptured;
70 mMouseCaptured = capture;
79 mMouseCaptured = !mMouseCaptured;
80 return mMouseCaptured;
128 mDirection = glm::normalize(target - mPosition);
136 MANDRILL_API
void setUp(glm::vec3 up)
167 CameraMatrices* matrices =
168 static_cast<CameraMatrices*
>(mpUniforms->getHostMap()) + mpSwapchain->getInFlightIndex();
169 return matrices->view;
178 CameraMatrices* matrices =
179 static_cast<CameraMatrices*
>(mpUniforms->getHostMap()) + mpSwapchain->getInFlightIndex();
180 return matrices->proj;
199 VkWriteDescriptorSet write = {
200 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
201 .dstBinding = binding,
202 .dstArrayElement = 0,
203 .descriptorCount = 1,
204 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
205 .pBufferInfo = &mBufferInfo,
212 ptr<Device> mpDevice;
213 GLFWwindow* mpWindow;
214 ptr<Swapchain> mpSwapchain;
216 bool mMouseCaptured =
false;
222 glm::vec3 mDirection;
226 ptr<Buffer> mpUniforms;
227 ptr<Descriptor> mpDescriptor;
228 VkDescriptorSetLayout mLayout;
229 VkDescriptorBufferInfo mBufferInfo;
Camera class for managing camera properties and transformations in a 3D scene.
Definition Camera.h:23
MANDRILL_API glm::vec3 getPosition() const
Get the position of the camera.
Definition Camera.h:87
MANDRILL_API void setUp(glm::vec3 up)
Set the up direction of the camera.
Definition Camera.h:136
MANDRILL_API void setPosition(glm::vec3 pos)
Set the position of the camera.
Definition Camera.h:97
MANDRILL_API void updateAspectRatio()
Update the aspect ratio that is used for the camera matrix. Call this if the window size changes.
Definition Camera.cpp:68
MANDRILL_API bool toggleMouseCapture()
Toggle mouse capture state, without specifying the new state.
Definition Camera.h:77
VkWriteDescriptorSet getWriteDescriptor(uint32_t binding) const
Get the write descriptor of the camera. Use this with when using push descriptors.
Definition Camera.h:197
MANDRILL_API bool isMouseCaptured() const
Check if camera has captured the mouse movements.
Definition Camera.h:58
MANDRILL_API glm::vec3 getDirection() const
Get the direction of the camera.
Definition Camera.h:106
MANDRILL_API glm::mat4 getProjectionMatrix() const
Get the projection matrix of the camera.
Definition Camera.h:176
MANDRILL_API void setMoveSpeed(float speed)
Set the movement speed of the camera.
Definition Camera.h:156
MANDRILL_API glm::mat4 getViewMatrix() const
Get the view matrix of the camera.
Definition Camera.h:165
MANDRILL_API ~Camera()
Destructor of camera.
Definition Camera.cpp:62
MANDRILL_API void setFov(float fov)
Set the field of view of the camera.
Definition Camera.h:146
MANDRILL_API ptr< Descriptor > getDescriptor() const
Get the descriptor of the camera, containing the view and projection matrices, and their invertations...
Definition Camera.h:187
MANDRILL_API void captureMouse(bool capture)
Set the capture state of the mouse.
Definition Camera.h:68
MANDRILL_API void update(float delta, glm::vec2 cursorDelta)
Update function to handle camera movements. Call this each app update.
Definition Camera.cpp:75
MANDRILL_API void setDirection(glm::vec3 dir)
Set the direction of the camera.
Definition Camera.h:116
MANDRILL_API void setTarget(glm::vec3 target)
Set the target the camera should look towards.
Definition Camera.h:126