#pragma once #include namespace engine { // ----------------------------------------------------------------------- // Camera // // A custom orbital ("arcball") camera. It orbits a focus point at a // controllable yaw/pitch/distance, with all parameters critically-damped // toward their target values every frame so camera moves - including // "focus on selected planet" - feel like smooth, cinematic transitions // rather than instant snaps. // ----------------------------------------------------------------------- class Camera { public: Camera(); // Input handlers - called directly from Engine's GLFW callbacks. void onMouseDrag(float deltaX, float deltaY); void onMousePan(float deltaX, float deltaY); void onScroll(float deltaY); void reset(); // Smoothly re-targets the orbit focus to a world-space point (e.g. a // selected planet's position) and optionally suggests a nice viewing // distance for that object's scale. void focusOn(const glm::vec3& worldPoint, float suggestedDistance); // Advances the smoothing/interpolation. Must be called once per frame // with the frame's delta time in seconds. void update(float deltaTime); glm::mat4 viewMatrix() const; glm::vec3 position() const { return currentPosition_; } glm::vec3 focusPoint() const { return currentFocus_; } float distance() const { return currentDistance_; } private: // Target (goal) state, set instantly by input; current state chases // it every update() call using exponential smoothing. float targetYaw_ = -0.6f; float targetPitch_ = 0.45f; float targetDistance_ = 18.0f; glm::vec3 targetFocus_{0.0f}; float currentYaw_ = -0.6f; float currentPitch_ = 0.45f; float currentDistance_ = 18.0f; glm::vec3 currentFocus_{0.0f}; glm::vec3 currentPosition_{0.0f}; static constexpr float kMinPitch = -1.45f; static constexpr float kMaxPitch = 1.45f; static constexpr float kMinDistance = 2.0f; static constexpr float kMaxDistance = 400.0f; static constexpr float kSmoothingSpeed = 6.0f; }; } // namespace engine