2024-01-21 22:22:03 +00:00
|
|
|
// FROM https://cgvr.cs.uni-bremen.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-02-11 22:06:35 +00:00
|
|
|
#include "../mathter/Matrix.hpp"
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
using Vec3 = mathter::Vector<float, 3, false>;
|
2024-01-21 22:22:03 +00:00
|
|
|
|
|
|
|
class Frustum {
|
|
|
|
public:
|
2024-02-11 22:06:35 +00:00
|
|
|
float ratio, nearDistance, farDistance, width, height, tang, focalLength;
|
2024-01-21 22:22:03 +00:00
|
|
|
|
2024-02-11 22:06:35 +00:00
|
|
|
Frustum(float focalLength, float ratio, float nearDistance, float farDistance) {
|
|
|
|
setCameraInternals(focalLength, ratio, nearDistance, farDistance);
|
2024-01-21 22:22:03 +00:00
|
|
|
}
|
|
|
|
~Frustum() {};
|
|
|
|
|
2024-02-11 22:06:35 +00:00
|
|
|
void setCameraInternals(float focalLength, float ratio, float nearD, float farD);
|
|
|
|
void clipToFrustum(Vec3 &p);
|
|
|
|
float getFocalLength() {
|
|
|
|
return focalLength;
|
2024-02-11 18:56:46 +00:00
|
|
|
}
|
2024-01-21 22:22:03 +00:00
|
|
|
};
|