Skip to content
Snippets Groups Projects
CamObs.cpp 520 B
Newer Older
Postea's avatar
Postea committed
#include "CamObs.h"
Yoel's avatar
Yoel committed

Postea's avatar
Postea committed
#include <limits>

namespace cam {
Yoel's avatar
Yoel committed
CamObs::CamObs(const util::Mat4& mat, float theta, int width, int height)
Yoel's avatar
Yoel committed
    : mat(mat), theta(theta), width(width), height(height) {
Postea's avatar
Postea committed

Yoel's avatar
Yoel committed
// Create a new ray shooting from the camera
Ray CamObs::create(float x, float y) const {
Yoel's avatar
Yoel committed
	util::Vec3 d(x - width / 2, height / 2 - y,
	             -(width / 2) / (tan(theta / 2)));
Postea's avatar
Postea committed

Yoel's avatar
Yoel committed
	d = mat.transformDir(d);

	return Ray(mat.position(), d, 0, std::numeric_limits<float>::infinity(),
	           true);
Postea's avatar
Postea committed
}
Yoel's avatar
Yoel committed
}  // namespace cam