WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
ViewportController.cpp
Go to the documentation of this file.
2
3#include "InputAction.h"
4#include "OrbitCamera.h"
5
6#include <glm/glm.hpp>
7
9{
10 // Orbit — combine yaw and pitch for a single position update
11 if (input.orbitYaw != 0.0f || input.orbitPitch != 0.0f)
12 {
13 camera.setYawAndPitch(camera.yaw() + input.orbitYaw,
14 camera.pitch() + input.orbitPitch);
15 }
16
17 // Zoom — adjust orbital radius
18 if (input.zoom != 0.0f)
19 {
20 camera.setRadius(camera.radius() + input.zoom);
21 }
22
23 // Pan — lateral along camera right vector, vertical along world Z
24 if (input.panX != 0.0f || input.panZ != 0.0f)
25 {
26 const auto look = camera.lookAt();
27 const auto right = camera.right();
28 camera.setLookAt(glm::vec3(look.x + right.x * input.panX,
29 look.y + right.y * input.panX,
30 look.z + input.panZ));
31 }
32}
Orbit camera that revolves around a target point.
Definition OrbitCamera.h:10
float radius() const
Current orbit radius (distance to target).
Definition OrbitCamera.h:60
void setLookAt(const glm::vec3 &target)
Set the point the camera orbits around.
float yaw() const
Current yaw angle in radians.
Definition OrbitCamera.h:45
void setRadius(float radius)
Set the distance from the camera to the target.
float pitch() const
Current pitch angle in radians.
Definition OrbitCamera.h:48
glm::vec3 lookAt() const
Current orbit target position.
Definition OrbitCamera.h:54
glm::vec3 right() const
Camera right vector (perpendicular to view direction and up).
Definition OrbitCamera.h:33
void setYawAndPitch(float yaw, float pitch)
Set both yaw and pitch simultaneously.
void apply(const InputState &input, OrbitCamera &camera)
Apply the resolved input state to the orbit camera.
float orbitPitch
Definition InputAction.h:74
float orbitYaw
Definition InputAction.h:73