~ | Better camera system + | Quad intersection test

This commit is contained in:
TheRedShip
2025-01-03 16:23:09 +01:00
parent f973d77654
commit d25db020bf
16 changed files with 135 additions and 1876 deletions

View File

@ -10,8 +10,8 @@
/* */
/* ************************************************************************** */
#ifndef RT_Plane__HPP
# define RT_Plane__HPP
#ifndef RT_PLANE__HPP
# define RT_PLANE__HPP
# include "RT.hpp"

View File

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Quad.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2024/12/23 19:47:09 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RT_QUAD__HPP
# define RT_QUAD__HPP
# include "RT.hpp"
class Quad : public Object
{
public:
Quad(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
try {
float x, y, z;
float x1, y1, z1;
float x2, y2, z2;
int mat_index;
if (!(line >> x >> y >> z))
throw std::runtime_error("Missing position");
if (!(line >> x1 >> y1 >> z1))
throw std::runtime_error("Missing quad's first edge ");
if (!(line >> x2 >> y2 >> z2))
throw std::runtime_error("Missing quad's second edge");
if (!(line >> mat_index))
throw std::runtime_error("Missing material properties");
_position = glm::vec3(x, y, z);
_edge1 = glm::vec3(x1, y1, z1);
_edge2 = glm::vec3(x2, y2, z2);
_mat_index = mat_index;
}
catch (const std::exception &e) { throw; }
}
Quad(const glm::vec3 &position, const glm::vec3 &edge1, const glm::vec3 &edge2, const int mat_index)
: Object(position, mat_index), _edge1(edge1), _edge2(edge2) {}
glm::vec3 getEdge1() const { return (_edge1); }
glm::vec3 getEdge2() const { return (_edge2); }
Type getType() const override { return Type::QUAD; }
private:
glm::vec3 _edge1;
glm::vec3 _edge2;
};
#endif