mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Fog beam laser now in objects
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/23 18:29:41 by ycontre #+# #+# */
|
||||
/* Updated: 2025/03/18 13:37:16 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/03/18 16:14:11 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -100,6 +100,9 @@ void Scene::addObject(Object *obj)
|
||||
gpu_obj.vertex2 = quad->getRight();
|
||||
gpu_obj.normal = quad->getNormal();
|
||||
gpu_obj.radius = quad->getSingleSided();
|
||||
|
||||
if (_gpu_materials[gpu_obj.mat_index].emission > 0.)
|
||||
this->_gpu_lights.insert(_gpu_objects.size());
|
||||
}
|
||||
else if (obj->getType() == Object::Type::CUBE)
|
||||
{
|
||||
@ -121,6 +124,16 @@ void Scene::addObject(Object *obj)
|
||||
gpu_obj.vertex2 = triangle->getVertex3();
|
||||
gpu_obj.normal = triangle->getNormal();
|
||||
}
|
||||
else if (obj->getType() == Object::Type::SPOTLIGHT)
|
||||
{
|
||||
auto spotlight = static_cast<SpotLight *>(obj);
|
||||
|
||||
gpu_obj.radius = spotlight->getRadius();
|
||||
gpu_obj.normal = spotlight->getDirection();
|
||||
gpu_obj.vertex1 = glm::vec3(spotlight->getAngle(), 0.0f, 0.0f);
|
||||
|
||||
this->_gpu_lights.insert(_gpu_objects.size());
|
||||
}
|
||||
else if (obj->getType() == Object::Type::PORTAL)
|
||||
{
|
||||
auto portal = static_cast<Portal *>(obj);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/26 21:43:51 by TheRed #+# #+# */
|
||||
/* Updated: 2025/02/04 01:21:11 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/03/18 16:47:59 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,6 +21,7 @@ SceneParser::SceneParser(Scene *scene, std::string filename) : _scene(scene), _f
|
||||
object_parsers["cu"] = [](std::stringstream &ss) -> Object * { return (new Cube(ss)); };
|
||||
object_parsers["po"] = [](std::stringstream &ss) -> Object * { return (new Portal(ss)); };
|
||||
object_parsers["cy"] = [](std::stringstream &ss) -> Object * { return (new Cylinder(ss)); };
|
||||
object_parsers["sl"] = [](std::stringstream &ss) -> Object * { return (new SpotLight(ss)); };
|
||||
}
|
||||
|
||||
void SceneParser::parseMaterial(std::stringstream &line)
|
||||
@ -165,14 +166,12 @@ bool SceneParser::parseLine(const std::string &line)
|
||||
Object *obj = it->second(ss);
|
||||
|
||||
GPUMaterial mat = _scene->getMaterial(obj->getMaterialIndex()); //verify material
|
||||
(void)mat;
|
||||
|
||||
if (obj->getType() == Object::Type::PORTAL)
|
||||
_scene->addObject(static_cast<Portal *>(obj)->createSupportQuad());
|
||||
|
||||
_scene->addObject(obj);
|
||||
|
||||
if (mat.emission > 0.0)
|
||||
_scene->updateLightAndObjects(obj->getMaterialIndex());
|
||||
}
|
||||
|
||||
if (identifier == "MAT")
|
||||
|
@ -239,11 +239,7 @@ void Window::imGuiRender(ShaderProgram &raytracing_program)
|
||||
|
||||
ImGui::Text("Material %d", i);
|
||||
has_changed |= ImGui::ColorEdit3("Color", &mat.color[0]);
|
||||
if (ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f))
|
||||
{
|
||||
has_changed = 1;
|
||||
_scene->updateLightAndObjects(i);
|
||||
}
|
||||
has_changed |= ImGui::SliderFloat("Emission", &mat.emission, 0.0f, 10.0f);
|
||||
|
||||
if (mat.type == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user