Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2026-01-10 15:30:45 +02:00
parent 4d9e1f03b0
commit 858f848427
6 changed files with 450 additions and 28 deletions

View File

@@ -1,5 +1,7 @@
#pragma once
#include <cmath>
#include <smath.hpp>
#include <vk_mem_alloc.h>
#include <vulkan/vulkan.hpp>
@@ -55,4 +57,39 @@ struct GPUSceneData {
smath::Vec4 sunlight_color;
};
struct Camera {
smath::Vec3 position {};
smath::Vec3 target { 0, 0, -1 };
smath::Vec3 up { 0, 1, 0 };
float fovy { smath::deg(70.0f) };
};
struct PolarCoordinate {
float r, theta, phi;
static PolarCoordinate from_vec3(smath::Vec3 const &v)
{
PolarCoordinate p;
p.r = std::sqrt(v.x() * v.x() + v.y() * v.y() + v.z() * v.z());
if (p.r == 0.0f) {
p.theta = 0.0f;
p.phi = 0.0f;
return p;
}
p.theta = std::atan2(v.z(), v.x());
p.phi = std::acos(v.y() / p.r);
return p;
}
smath::Vec3 to_vec3() const
{
float sin_phi = std::sin(phi);
return smath::Vec3 { r * sin_phi * std::cos(theta), r * std::cos(phi),
r * sin_phi * std::sin(theta) };
}
};
} // namespace Lunar