From c39f5e51e48390c59b89b2cf95e080030292df8d Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Thu, 27 Oct 2022 15:17:13 +0200 Subject: [PATCH] Adjust trackball camera Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- modules/camera/include/vkcv/camera/Camera.hpp | 26 +++--- .../include/vkcv/camera/CameraManager.hpp | 10 +- .../vkcv/camera/PilotCameraController.hpp | 12 +-- .../vkcv/camera/TrackballCameraController.hpp | 20 ++-- .../src/vkcv/camera/PilotCameraController.cpp | 2 +- .../vkcv/camera/TrackballCameraController.cpp | 92 ++++++++++--------- projects/CMakeLists.txt | 4 +- projects/bindless_textures/src/main.cpp | 3 +- projects/fire_works/src/main.cpp | 2 +- projects/first_scene/src/main.cpp | 1 + projects/head_demo/src/main.cpp | 1 + projects/mpm/.gitignore | 2 +- projects/mpm/CMakeLists.txt | 8 +- projects/particle_simulation/src/main.cpp | 7 +- projects/ray_tracer/src/main.cpp | 2 +- projects/rtx_ambient_occlusion/src/main.cpp | 2 + projects/sph/src/main.cpp | 6 +- projects/voxelization/src/main.cpp | 1 + 18 files changed, 102 insertions(+), 99 deletions(-) diff --git a/modules/camera/include/vkcv/camera/Camera.hpp b/modules/camera/include/vkcv/camera/Camera.hpp index 9851cb73..b02e9cfb 100644 --- a/modules/camera/include/vkcv/camera/Camera.hpp +++ b/modules/camera/include/vkcv/camera/Camera.hpp @@ -69,7 +69,7 @@ namespace vkcv::camera { void setPerspective(float fov, float ratio, float near, float far); /** - * @brief Gets the view matrix of the camera + * @brief Returns the view matrix of the camera * @return The view matrix of the camera */ [[nodiscard]] @@ -84,28 +84,28 @@ namespace vkcv::camera { void lookAt(const glm::vec3& position, const glm::vec3& center, const glm::vec3& up); /** - * @brief Gets the current projection of the camera + * @brief Returns the current projection of the camera * @return The current projection matrix */ [[nodiscard]] const glm::mat4& getProjection() const; /** - * @brief Gets the model-view-projection matrix of the camera with y-axis-correction applied + * @brief Returns the model-view-projection matrix of the camera with y-axis-correction applied * @return The model-view-projection matrix */ [[nodiscard]] glm::mat4 getMVP() const; /** - * @brief Gets the near and far bounds of the view frustum of the camera. + * @brief Returns the near and far bounds of the view frustum of the camera. * @param[out] near The near bound of the view frustum * @param[out] far The far bound of the view frustum */ void getNearFar(float &near, float &far) const; /** - * @brief Gets the current field of view of the camera in radians + * @brief Returns the current field of view of the camera in radians * @return[in] The current field of view in radians */ [[nodiscard]] @@ -118,7 +118,7 @@ namespace vkcv::camera { void setFov(float fov); /** - * @brief Gets the current aspect ratio of the camera + * @brief Returns the current aspect ratio of the camera * @return The current aspect ratio of the camera */ [[nodiscard]] @@ -138,7 +138,7 @@ namespace vkcv::camera { void setNearFar(float near, float far); /** - * @brief Gets the current front vector of the camera in world space + * @brief Returns the current front vector of the camera in world space * @return The current front vector of the camera */ [[nodiscard]] @@ -151,7 +151,7 @@ namespace vkcv::camera { void setFront(const glm::vec3& front); /** - * @brief Gets the current position of the camera in world space + * @brief Returns the current position of the camera in world space * @return The current position of the camera in world space */ [[nodiscard]] @@ -164,7 +164,7 @@ namespace vkcv::camera { void setPosition( const glm::vec3& position ); /** - * @brief Gets the center point. + * @brief Returns the center point. * @return The center point. */ [[nodiscard]] @@ -177,7 +177,7 @@ namespace vkcv::camera { void setCenter(const glm::vec3& center); /** - * @brief Gets the angles of the camera. + * @brief Returns the angles of the camera. * @param[out] pitch The pitch value in radians * @param[out] yaw The yaw value in radians */ @@ -191,7 +191,7 @@ namespace vkcv::camera { void setAngles(float pitch, float yaw); /** - * @brief Gets the pitch value of the camera in degrees. + * @brief Returns the pitch value of the camera in degrees. * @return The pitch value in degrees. */ [[nodiscard]] @@ -204,7 +204,7 @@ namespace vkcv::camera { void setPitch(float pitch); /** - * @brief Gets the yaw value of the camera in degrees. + * @brief Returns the yaw value of the camera in degrees. * @return The yaw value in degrees. */ [[nodiscard]] @@ -217,7 +217,7 @@ namespace vkcv::camera { void setYaw(float yaw); /** - * @brief Gets the up vector. + * @brief Returns the up vector. * @return The up vector. */ [[nodiscard]] diff --git a/modules/camera/include/vkcv/camera/CameraManager.hpp b/modules/camera/include/vkcv/camera/CameraManager.hpp index c54ec940..3c6c556d 100644 --- a/modules/camera/include/vkcv/camera/CameraManager.hpp +++ b/modules/camera/include/vkcv/camera/CameraManager.hpp @@ -103,7 +103,7 @@ namespace vkcv::camera { void gamepadCallback(int gamepadIndex); /** - * @brief Gets a camera controller object of specified @p controllerType. + * @brief Returns a camera controller object of specified @p controllerType. * @param[in] controllerType The type of the camera controller. * @return The specified camera controller object. */ @@ -147,7 +147,7 @@ namespace vkcv::camera { CameraHandle addCamera(ControllerType controllerType, const Camera& camera); /** - * @brief Gets the stored camera object located by @p cameraHandle. + * @brief Returns the stored camera object located by @p cameraHandle. * @param[in] cameraHandle The camera handle. * @return The camera object by @p cameraHandle. * @throws std::runtime_error If @p cameraHandle is not a valid camera handle. @@ -155,7 +155,7 @@ namespace vkcv::camera { Camera& getCamera(const CameraHandle& cameraHandle); /** - * @brief Gets the stored camera object set as the active camera. + * @brief Returns the stored camera object set as the active camera. * @return The active camera. */ Camera& getActiveCamera(); @@ -168,7 +168,7 @@ namespace vkcv::camera { void setActiveCamera(const CameraHandle& cameraHandle); /** - * @brief Gets the handle of the stored active camera object. + * @brief Returns the handle of the stored active camera object. * @return The active camera handle. */ CameraHandle getActiveCameraHandle() const; @@ -183,7 +183,7 @@ namespace vkcv::camera { void setControllerType(const CameraHandle& cameraHandle, ControllerType controllerType); /** - * @brief Gets the currently bound camera controller type of the stored camera object located by @p cameraHandle. + * @brief Returns the currently bound camera controller type of the stored camera object located by @p cameraHandle. * @param[in] cameraHandle The camera handle. * @return The type of the camera controller of the specified camera object. * @throws std::runtime_error If @p cameraHandle is not a valid camera handle. diff --git a/modules/camera/include/vkcv/camera/PilotCameraController.hpp b/modules/camera/include/vkcv/camera/PilotCameraController.hpp index c23a2ccc..40ccd56b 100644 --- a/modules/camera/include/vkcv/camera/PilotCameraController.hpp +++ b/modules/camera/include/vkcv/camera/PilotCameraController.hpp @@ -73,7 +73,7 @@ namespace vkcv::camera { * @param[in] deltaTime The time that has passed since last update. * @param[in] camera The camera object. */ - void updateCamera(double deltaTime, Camera &camera); + void updateCamera(double deltaTime, Camera &camera) override; /** * @brief A callback function for key events. Currently, 3D camera movement via W, A, S, D, E, Q are supported. @@ -83,7 +83,7 @@ namespace vkcv::camera { * @param[in] mods The modifier bits. * @param[in] camera The camera object. */ - void keyCallback(int key, int scancode, int action, int mods, Camera &camera); + void keyCallback(int key, int scancode, int action, int mods, Camera &camera) override; /** * @brief A callback function for mouse scrolling events. Currently, this leads to changes in the field of view @@ -92,7 +92,7 @@ namespace vkcv::camera { * @param[in] offsetY The offset in vertical direction. * @param[in] camera The camera object. */ - void scrollCallback(double offsetX, double offsetY, Camera &camera); + void scrollCallback(double offsetX, double offsetY, Camera &camera) override; /** * @brief A callback function for mouse movement events. Currently, this leads to panning the view of the camera, @@ -101,7 +101,7 @@ namespace vkcv::camera { * @param[in] y The vertical mouse position * @param[in] camera The camera object. */ - void mouseMoveCallback(double x, double y, Camera &camera); + void mouseMoveCallback(double x, double y, Camera &camera) override; /** * @brief A callback function for mouse button events. Currently, the right mouse button enables panning the @@ -111,7 +111,7 @@ namespace vkcv::camera { * @param[in] mods The modifier bits * @param[in] camera The camera object. */ - void mouseButtonCallback(int button, int action, int mods, Camera &camera); + void mouseButtonCallback(int button, int action, int mods, Camera &camera) override; /** * @brief A callback function for gamepad input events. @@ -119,7 +119,7 @@ namespace vkcv::camera { * @param camera The camera object. * @param frametime The current frametime. */ - void gamepadCallback(int gamepadIndex, Camera &camera, double frametime); + void gamepadCallback(int gamepadIndex, Camera &camera, double frametime) override; }; /** @} */ diff --git a/modules/camera/include/vkcv/camera/TrackballCameraController.hpp b/modules/camera/include/vkcv/camera/TrackballCameraController.hpp index e4f40383..5df56fd8 100644 --- a/modules/camera/include/vkcv/camera/TrackballCameraController.hpp +++ b/modules/camera/include/vkcv/camera/TrackballCameraController.hpp @@ -21,10 +21,8 @@ namespace vkcv::camera { class TrackballCameraController final : public CameraController { private: bool m_rotationActive; - float m_cameraSpeed; float m_scrollSensitivity; - float m_radius; float m_pitch; float m_yaw; @@ -47,12 +45,6 @@ namespace vkcv::camera { */ ~TrackballCameraController() = default; - /** - * @brief Sets @p radius as the new radius for orbiting around the camera's center point. - * @param[in] radius The new radius. - */ - void setRadius(const float radius); - /** * @brief Pans the view of @p camera according to the pitch and yaw values and additional offsets @p xOffset * and @p yOffset. @@ -67,7 +59,7 @@ namespace vkcv::camera { * @param[in] deltaTime The time that has passed since last update. * @param[in] camera The camera object */ - void updateCamera(double deltaTime, Camera &camera); + void updateCamera(double deltaTime, Camera &camera) override; /** * @brief A callback function for key events. Currently, the trackball camera does not support camera movement. @@ -78,7 +70,7 @@ namespace vkcv::camera { * @param[in] mods The modifier bits. * @param[in] camera The camera object. */ - void keyCallback(int key, int scancode, int action, int mods, Camera &camera); + void keyCallback(int key, int scancode, int action, int mods, Camera &camera) override; /** * @brief A callback function for mouse scrolling events. Currently, this leads to changes in the field of view @@ -87,7 +79,7 @@ namespace vkcv::camera { * @param[in] offsetY The offset in vertical direction. * @param[in] camera The camera object. */ - void scrollCallback(double offsetX, double offsetY, Camera &camera); + void scrollCallback(double offsetX, double offsetY, Camera &camera) override; /** * @brief A callback function for mouse movement events. Currently, this leads to panning the view of the @@ -96,7 +88,7 @@ namespace vkcv::camera { * @param[in] yoffset The vertical mouse position. * @param[in] camera The camera object. */ - void mouseMoveCallback(double xoffset, double yoffset, Camera &camera); + void mouseMoveCallback(double xoffset, double yoffset, Camera &camera) override; /** * @brief A callback function for mouse button events. Currently, the right mouse button enables panning the @@ -106,7 +98,7 @@ namespace vkcv::camera { * @param[in] mods The modifier bits. * @param[in] camera The camera object. */ - void mouseButtonCallback(int button, int action, int mods, Camera &camera); + void mouseButtonCallback(int button, int action, int mods, Camera &camera) override; /** * @brief A callback function for gamepad input events. @@ -114,7 +106,7 @@ namespace vkcv::camera { * @param camera The camera object. * @param frametime The current frametime. */ - void gamepadCallback(int gamepadIndex, Camera &camera, double frametime); + void gamepadCallback(int gamepadIndex, Camera &camera, double frametime) override; }; /** @} */ diff --git a/modules/camera/src/vkcv/camera/PilotCameraController.cpp b/modules/camera/src/vkcv/camera/PilotCameraController.cpp index 1c7bb126..37a79fe1 100644 --- a/modules/camera/src/vkcv/camera/PilotCameraController.cpp +++ b/modules/camera/src/vkcv/camera/PilotCameraController.cpp @@ -112,7 +112,7 @@ namespace vkcv::camera { xoffset *= static_cast<float>(m_rotationActive); yoffset *= static_cast<float>(m_rotationActive); - panView(xoffset , yoffset, camera); + panView(xoffset, yoffset, camera); } void PilotCameraController::mouseButtonCallback(int button, int action, int mods, Camera &camera) { diff --git a/modules/camera/src/vkcv/camera/TrackballCameraController.cpp b/modules/camera/src/vkcv/camera/TrackballCameraController.cpp index 0052de56..5e89ce1a 100644 --- a/modules/camera/src/vkcv/camera/TrackballCameraController.cpp +++ b/modules/camera/src/vkcv/camera/TrackballCameraController.cpp @@ -5,65 +5,71 @@ namespace vkcv::camera { TrackballCameraController::TrackballCameraController() { m_rotationActive = false; - m_radius = 3.0f; m_cameraSpeed = 2.5f; m_scrollSensitivity = 0.2f; - m_pitch = 0.0f; - m_yaw = 0.0f; - } - - void TrackballCameraController::setRadius(const float radius) { - m_radius = 0.1f * (radius < 0.1f) + radius * (1 - (radius < 0.1f)); + m_pitch = 0.0f; + m_yaw = 0.0f; } void TrackballCameraController::panView(double xOffset, double yOffset, Camera &camera) { - // update only if there is (valid) input - if (xOffset == 0.0 && yOffset == 0.0) { - return; - } - - // handle yaw rotation - m_yaw = m_yaw + static_cast<float>(xOffset) * 90.0f * m_cameraSpeed; - - // handle pitch rotation - m_pitch = m_pitch + static_cast<float>(yOffset) * 90.0f * m_cameraSpeed; - } + // update only if there is (valid) input + if (xOffset == 0.0 && yOffset == 0.0) { + return; + } + + m_yaw += static_cast<float>(xOffset) * 90.0f * m_cameraSpeed; + m_pitch += static_cast<float>(yOffset) * 90.0f * m_cameraSpeed; + } void TrackballCameraController::updateRadius(double offset, Camera &camera) { // update only if there is (valid) input if (offset == 0.0) { return; } - - glm::vec3 cameraPosition = camera.getPosition(); - glm::vec3 cameraCenter = camera.getCenter(); - float radius = glm::length(cameraCenter - cameraPosition); // get current camera radius - setRadius(radius - static_cast<float>(offset) * m_scrollSensitivity); + + camera.setPosition( + camera.getPosition() + + camera.getFront() * static_cast<float>(offset) + ); } void TrackballCameraController::updateCamera(double deltaTime, Camera &camera) { - const glm::vec3 yAxis = glm::vec3(0.0f, 1.0f, 0.0f); - const glm::vec3 xAxis = glm::vec3(1.0f, 0.0f, 0.0f); + const auto center = camera.getCenter(); + const auto distance = center - camera.getPosition(); + const float radius = glm::length(distance); + + glm::vec3 front = distance / radius; + glm::vec3 up = camera.getUp(); + glm::vec3 left; - const glm::mat4 rotationY = glm::rotate(glm::mat4(1.0f), glm::radians(m_yaw), yAxis); - const glm::mat4 rotationX = glm::rotate(rotationY, -glm::radians(m_pitch), xAxis); - const glm::vec3 translation = glm::vec3( - rotationX * glm::vec4(0.0f, 0.0f, m_radius, 0.0f) + const auto rotationY = glm::rotate( + glm::identity<glm::mat4>(), + glm::radians(m_yaw), + up ); - - const glm::vec3 center = camera.getCenter(); - const glm::vec3 position = center + translation; - const glm::vec3 up = glm::vec3( - rotationX * glm::vec4(0.0f, 1.0f, 0.0f, 0.0f) + + front = glm::vec3(rotationY * glm::vec4(front, 0.0f)); + left = glm::normalize(glm::cross(up, front)); + + const auto rotationX = glm::rotate( + rotationY, + glm::radians(m_pitch), + left ); + + up = glm::vec3(rotationX * glm::vec4(up, 0.0f)); + front = glm::normalize(glm::cross(up, left)); - camera.lookAt(position, center, up); - } + m_yaw = 0.0f; + m_pitch = 0.0f; + + camera.lookAt(center + front * radius, center, up); + } void TrackballCameraController::keyCallback(int key, int scancode, int action, int mods, Camera &camera) {} void TrackballCameraController::scrollCallback(double offsetX, double offsetY, Camera &camera) { - updateRadius(offsetY, camera); + updateRadius(offsetY * m_scrollSensitivity, camera); } void TrackballCameraController::mouseMoveCallback(double xoffset, double yoffset, Camera &camera) { @@ -90,19 +96,19 @@ namespace vkcv::camera { double threshold = 0.1; // handle rotations - double stickRightX = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X]); - double stickRightY = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y]); + auto stickRightX = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X]); + auto stickRightY = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y]); double rightXVal = glm::clamp((glm::abs(stickRightX)-threshold), 0.0, 1.0) - * std::copysign(1.0, stickRightX) * sensitivity * frametime; + * glm::sign(stickRightX) * sensitivity * frametime; double rightYVal = glm::clamp((glm::abs(stickRightY)-threshold), 0.0, 1.0) - * std::copysign(1.0, stickRightY) * sensitivity * frametime; + * glm::sign(stickRightY) * sensitivity * frametime; panView(rightXVal, rightYVal, camera); // handle translation - double stickLeftY = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y]); + auto stickLeftY = static_cast<double>(gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y]); double leftYVal = glm::clamp((glm::abs(stickLeftY)-threshold), 0.0, 1.0) - * std::copysign(1.0, stickLeftY) * sensitivity * frametime; + * glm::sign(stickLeftY) * sensitivity * frametime; updateRadius(-leftYVal, camera); } } \ No newline at end of file diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 2d2a6b00..3860ec7a 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -11,10 +11,10 @@ add_subdirectory(head_demo) add_subdirectory(indirect_dispatch) add_subdirectory(indirect_draw) add_subdirectory(mesh_shader) +add_subdirectory(mpm) add_subdirectory(particle_simulation) add_subdirectory(path_tracer) add_subdirectory(ray_tracer) add_subdirectory(rtx_ambient_occlusion) add_subdirectory(sph) -add_subdirectory(voxelization) -add_subdirectory(mpm) \ No newline at end of file +add_subdirectory(voxelization) \ No newline at end of file diff --git a/projects/bindless_textures/src/main.cpp b/projects/bindless_textures/src/main.cpp index 37d0c68b..5021de5c 100644 --- a/projects/bindless_textures/src/main.cpp +++ b/projects/bindless_textures/src/main.cpp @@ -212,9 +212,10 @@ int main(int argc, const char** argv) { vkcv::camera::CameraManager cameraManager(window); auto camHandle0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); - cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); + auto camHandle1 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); cameraManager.getCamera(camHandle0).setPosition(glm::vec3(0, 0, -3)); + cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0, 0, -3)); core.run([&](const vkcv::WindowHandle &windowHandle, double t, double dt, uint32_t swapchainWidth, uint32_t swapchainHeight) { diff --git a/projects/fire_works/src/main.cpp b/projects/fire_works/src/main.cpp index 54a6e03c..51e29ed5 100644 --- a/projects/fire_works/src/main.cpp +++ b/projects/fire_works/src/main.cpp @@ -218,7 +218,7 @@ int main(int argc, const char **argv) { cameraManager.getCamera(trackballHandle).setCenter(glm::vec3(0.0f, 0.0f, 0.0f)); // set camera to look at the center of the particle volume cameraManager.getCamera(trackballHandle).setNearFar(0.1f, 50.0f); - cameraManager.getCamera(trackballHandle).setPosition(glm::vec3(0, 0, -25)); + cameraManager.getCamera(trackballHandle).setPosition(glm::vec3(0, 0, 25)); cameraManager.getCamera(pilotHandle).setNearFar(0.1f, 50.0f); cameraManager.getCamera(pilotHandle).setPosition(glm::vec3(0, 0, 25)); diff --git a/projects/first_scene/src/main.cpp b/projects/first_scene/src/main.cpp index 1d0fd0e9..964b048e 100644 --- a/projects/first_scene/src/main.cpp +++ b/projects/first_scene/src/main.cpp @@ -37,6 +37,7 @@ int main(int argc, const char** argv) { cameraManager.getCamera(camHandle0).setPosition(glm::vec3(-8, 1, -0.5)); cameraManager.getCamera(camHandle0).setNearFar(0.1f, 30.0f); + cameraManager.getCamera(camHandle1).setPosition(glm::vec3(-8, 1, -0.5)); cameraManager.getCamera(camHandle1).setNearFar(0.1f, 30.0f); vkcv::scene::Scene scene = vkcv::scene::Scene::load( diff --git a/projects/head_demo/src/main.cpp b/projects/head_demo/src/main.cpp index 771689e9..f1e98828 100644 --- a/projects/head_demo/src/main.cpp +++ b/projects/head_demo/src/main.cpp @@ -43,6 +43,7 @@ int main(int argc, const char** argv) { cameraManager.getCamera(camHandle0).setPosition(glm::vec3(15.5f, 0, 0)); cameraManager.getCamera(camHandle0).setNearFar(0.1f, 30.0f); + cameraManager.getCamera(camHandle1).setPosition(glm::vec3(15.5f, 0, 0)); cameraManager.getCamera(camHandle1).setNearFar(0.1f, 30.0f); vkcv::scene::Scene scene = vkcv::scene::Scene::load( diff --git a/projects/mpm/.gitignore b/projects/mpm/.gitignore index 7ed07ed4..68b4554c 100644 --- a/projects/mpm/.gitignore +++ b/projects/mpm/.gitignore @@ -1 +1 @@ -wobble_bobble +mpm diff --git a/projects/mpm/CMakeLists.txt b/projects/mpm/CMakeLists.txt index 6c90d522..859a0ac1 100644 --- a/projects/mpm/CMakeLists.txt +++ b/projects/mpm/CMakeLists.txt @@ -1,15 +1,15 @@ cmake_minimum_required(VERSION 3.16) -project(wobble_bobble) +project(mpm) # setting c++ standard for the project set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) # adding source files to the project -add_project(wobble_bobble src/main.cpp) +add_project(mpm src/main.cpp) # including headers of dependencies and the VkCV framework -target_include_directories(wobble_bobble SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_camera_include} ${vkcv_gui_include} ${vkcv_shader_compiler_include}) +target_include_directories(mpm SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_camera_include} ${vkcv_gui_include} ${vkcv_shader_compiler_include}) # linking with libraries from all dependencies and the VkCV framework -target_link_libraries(wobble_bobble vkcv vkcv_camera vkcv_gui vkcv_shader_compiler) +target_link_libraries(mpm vkcv vkcv_camera vkcv_gui vkcv_shader_compiler) diff --git a/projects/particle_simulation/src/main.cpp b/projects/particle_simulation/src/main.cpp index 7e48d53e..72249ee3 100644 --- a/projects/particle_simulation/src/main.cpp +++ b/projects/particle_simulation/src/main.cpp @@ -197,14 +197,13 @@ int main(int argc, const char **argv) { auto camHandle0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); auto camHandle1 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); - cameraManager.getCamera(camHandle0).setNearFar(0.1, 30); - cameraManager.getCamera(camHandle0).setNearFar(0.1, 30); + cameraManager.getCamera(camHandle0).setNearFar(0.1f, 30.0f); + cameraManager.getCamera(camHandle1).setNearFar(0.1f, 30.0f); cameraManager.setActiveCamera(camHandle1); - cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0, 0, -2)); + cameraManager.getCamera(camHandle0).setPosition(glm::vec3(0.0f, 0.0f, -2.0f)); cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0.0f, 0.0f, -2.0f)); - cameraManager.getCamera(camHandle1).setCenter(glm::vec3(0.0f, 0.0f, 0.0f)); const auto swapchainExtent = core.getSwapchainExtent(window.getSwapchain()); diff --git a/projects/ray_tracer/src/main.cpp b/projects/ray_tracer/src/main.cpp index fadbadc2..1a906d5d 100644 --- a/projects/ray_tracer/src/main.cpp +++ b/projects/ray_tracer/src/main.cpp @@ -162,7 +162,7 @@ int main(int argc, const char** argv) { cameraManager.getCamera(camHandle0).setPosition(glm::vec3(0, 0, 2)); - cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0.0f, 0.0f, 0.0f)); + cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0, 0, -4)); cameraManager.getCamera(camHandle1).setCenter(glm::vec3(0.0f, 0.0f, -1.0f)); core.run([&](const vkcv::WindowHandle &windowHandle, double t, double dt, diff --git a/projects/rtx_ambient_occlusion/src/main.cpp b/projects/rtx_ambient_occlusion/src/main.cpp index 2e999bae..2a9d5d20 100644 --- a/projects/rtx_ambient_occlusion/src/main.cpp +++ b/projects/rtx_ambient_occlusion/src/main.cpp @@ -36,6 +36,8 @@ int main(int argc, const char** argv) { vkcv::camera::CameraManager cameraManager(core.getWindow(windowHandle)); auto camHandle = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); + + cameraManager.getCamera(camHandle).setPosition(glm::vec3(0, 0, -3)); cameraManager.getCamera(camHandle).setNearFar(0.1f, 30.0f); // get Teapot vertices and indices diff --git a/projects/sph/src/main.cpp b/projects/sph/src/main.cpp index 72cc9995..989201a9 100644 --- a/projects/sph/src/main.cpp +++ b/projects/sph/src/main.cpp @@ -211,12 +211,12 @@ int main(int argc, const char **argv) { auto camHandle0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT); auto camHandle1 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL); - cameraManager.getCamera(camHandle0).setNearFar(0.1, 30); - cameraManager.getCamera(camHandle0).setPosition(glm::vec3(0, 0, -2.5)); + cameraManager.getCamera(camHandle0).setNearFar(0.1f, 30.0f); + cameraManager.getCamera(camHandle0).setPosition(glm::vec3(0.0f, 0.0f, -2.5f)); cameraManager.setActiveCamera(camHandle1); - cameraManager.getCamera(camHandle1).setNearFar(0.1, 30); + cameraManager.getCamera(camHandle1).setNearFar(0.1f, 30.0f); cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0.0f, 0.0f, -2.5f)); cameraManager.getCamera(camHandle1).setCenter(glm::vec3(0.0f, 0.0f, 0.0f)); diff --git a/projects/voxelization/src/main.cpp b/projects/voxelization/src/main.cpp index fe58a620..9b9bf39b 100644 --- a/projects/voxelization/src/main.cpp +++ b/projects/voxelization/src/main.cpp @@ -122,6 +122,7 @@ int main(int argc, const char** argv) { cameraManager.getCamera(camHandle0).setYaw(180.0f); cameraManager.getCamera(camHandle0).setFov(glm::radians(37.8)); // fov of a 35mm lens + cameraManager.getCamera(camHandle1).setPosition(glm::vec3(0.f, 0.f, 3.f)); cameraManager.getCamera(camHandle1).setNearFar(0.1f, 30.0f); vkcv::asset::Scene mesh; -- GitLab