mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
+ | Portals
This commit is contained in:
@ -106,6 +106,13 @@ void Scene::updateGPUData()
|
||||
gpu_obj.vertex1 = cube->getSize();
|
||||
gpu_obj.type = static_cast<int>(cube->getType());
|
||||
}
|
||||
else if (obj->getType() == Object::Type::PORTAL)
|
||||
{
|
||||
auto portal = static_cast<const Portal *>(obj);
|
||||
gpu_obj.vertex1 = portal->getEdge1();
|
||||
gpu_obj.vertex2 = portal->getEdge2();
|
||||
gpu_obj.radius = portal->getLinkedPortalIndex();
|
||||
}
|
||||
|
||||
_gpu_objects.push_back(gpu_obj);
|
||||
}
|
||||
|
@ -43,6 +43,12 @@ SceneParser::SceneParser(Scene *scene) : _scene(scene)
|
||||
try { return (new Cube(ss)); }
|
||||
catch (const std::exception &e) { throw; }
|
||||
};
|
||||
|
||||
object_parsers["po"] = [](std::stringstream &ss) -> Object *
|
||||
{
|
||||
try { return (new Portal(ss)); }
|
||||
catch (const std::exception &e) { throw; }
|
||||
};
|
||||
}
|
||||
|
||||
void SceneParser::parseMaterial(std::stringstream &line)
|
||||
@ -51,7 +57,7 @@ void SceneParser::parseMaterial(std::stringstream &line)
|
||||
float emission;
|
||||
float roughness;
|
||||
float metallic;
|
||||
int type;
|
||||
std::string type;
|
||||
|
||||
Material *mat;
|
||||
|
||||
@ -59,15 +65,20 @@ void SceneParser::parseMaterial(std::stringstream &line)
|
||||
throw std::runtime_error("Material: Missing material properties");
|
||||
|
||||
if (!(line >> type))
|
||||
type = 0;
|
||||
|
||||
type = "LAM";
|
||||
|
||||
mat = new Material;
|
||||
|
||||
mat->color = glm::vec3(r / 255.0f, g / 255.0f, b / 255.0f);
|
||||
mat->emission = emission;
|
||||
mat->roughness = roughness;
|
||||
mat->metallic = metallic;
|
||||
mat->type = type;
|
||||
|
||||
mat->type = 0;
|
||||
if (type == "LAM")
|
||||
mat->type = 0;
|
||||
else if (type == "DIE")
|
||||
mat->type = 1;
|
||||
|
||||
_scene->addMaterial(mat);
|
||||
}
|
||||
|
Reference in New Issue
Block a user