+ | Fog beam laser now in objects

This commit is contained in:
TheRedShip
2025-03-08 20:36:10 +01:00
committed by tomoron
parent ecc1f68329
commit 075c2a959a
11 changed files with 172 additions and 51 deletions

View File

@ -74,6 +74,7 @@ struct GPUDenoise
# include "objects/Cube.hpp"
# include "objects/Portal.hpp"
# include "objects/Cylinder.hpp"
# include "objects/SpotLight.hpp"
# include "Buffer.hpp"
# include "Arguments.hpp"

View File

@ -47,7 +47,9 @@ class Object
TRIANGLE,
CUBE,
PORTAL,
CYLINDER
CYLINDER,
SPOTLIGHT,
LASERBEAM
};
virtual Type getType() const = 0;

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */
/* Updated: 2025/03/18 13:37:23 by tomoron ### ########.fr */
/* Updated: 2025/03/18 16:47:45 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -117,7 +117,6 @@ class Scene
bool loadTextures();
void updateLightAndObjects(int mat_id);
std::set<int> getGPULights();
void addBvh(std::vector<Triangle> &triangles, glm::vec3 offset, float scale, glm::mat4 transform);
@ -147,6 +146,7 @@ class Scene
void changeScene(std::string &name, std::vector<Buffer *> &buffers);
std::vector<Buffer *> createDataOnGPU(void);
void updateLightAndObjects(int mat_id);
private:
void init(std::string &name);

View File

@ -0,0 +1,68 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* SpotLight.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/08 18:50:04 by TheRed #+# #+# */
/* Updated: 2025/03/08 18:50:04 by TheRed ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RT_SPOTLIGHT__HPP
# define RT_SPOTLIGHT__HPP
# include "RT.hpp"
class SpotLight : public Object
{
public:
SpotLight(std::stringstream &line) : Object(glm::vec3(0.0f), -1)
{
float x, y, z, radius;
float dir_x, dir_y, dir_z;
float angle;
int mat_index;
if (!(line >> x >> y >> z >> radius))
throw std::runtime_error("Missing position or radius values");
if (radius <= 0.0f)
throw std::runtime_error("Radius must be positive");
if (!(line >> dir_x >> dir_y >> dir_z))
throw std::runtime_error("Missing direction values");
if (!(line >> angle))
throw std::runtime_error("Missing angle value");
if (!(line >> mat_index))
throw std::runtime_error("Missing material properties");
_position = glm::vec3(x, y, z);
_radius = radius / 2.0;
_direction = glm::normalize(glm::vec3(dir_x, dir_y, dir_z));
_angle = angle;
_mat_index = mat_index;
}
SpotLight(const glm::vec3& position, float radius, const int mat_index)
: Object(position, mat_index), _radius(radius) {}
float getRadius() const { return (_radius); }
float getAngle() const { return (_angle); }
const glm::vec3 &getDirection() const { return (_direction); }
Type getType() const override { return Type::SPOTLIGHT; }
private:
float _radius;
glm::vec3 _direction;
float _angle;
};
#endif