-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVoxaNovusCamera.cpp
More file actions
44 lines (39 loc) · 1.06 KB
/
VoxaNovusCamera.cpp
File metadata and controls
44 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "VoxaNovusCamera.h"
#include "imgui/imgui.h"
namespace dx = DirectX;
DirectX::XMMATRIX Camera::GetMatrix() const noexcept
{
const auto pos = dx::XMVector3Transform(
dx::XMVectorSet(0.0f, 0.0f, -r, 0.0f),
dx::XMMatrixRotationRollPitchYaw(phi, -theta, 0.0f)
);
return DirectX::XMMatrixLookAtLH(
pos,
dx::XMVectorZero(),
dx::XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)) *
dx::XMMatrixRotationRollPitchYaw(pitch, -yaw, roll);
}
void Camera::SpawnControlWindow() noexcept {
if (ImGui::Begin("Camera")) {
ImGui::Text("Position");
ImGui::SliderFloat("R", &r, 0.1f, 80.0f, "%.1f");
ImGui::SliderAngle("Theta", &theta, -180.0f, 180.0f);
ImGui::SliderAngle("Phi", &phi, -89.0f, 89.0f);
ImGui::Text("Orientation");
ImGui::SliderAngle("Roll", &roll, -180.0f, 180.0f);
ImGui::SliderAngle("Pitch", &pitch, -180.0f, 180.0f);
ImGui::SliderAngle("Yaw", &yaw, -180.0f, 180.0f);
if (ImGui::Button("Reset")) {
Reset();
}
}
ImGui::End();
}
void Camera::Reset() noexcept {
r = 20.0f;
theta = 0.0f;
phi = 0.0f;
pitch = 0.0f;
yaw = 0.0f;
roll = 0.0f;
}