#include "scene/simplescene.h" #include "primitive/primitive.h" #include "shader/shader.h" bool SimpleScene::findIntersection(Ray &ray) const { bool hit = false; for (auto i: this->primitives()) hit |= i->intersect(ray); return hit; } bool SimpleScene::findOcclusion(Ray &ray) const { for (auto i: this->primitives()) if (i->intersect(ray) && !i->shader()->isTransparent()) return true; return false; } Color SimpleScene::getTransparency(Ray &ray, float maxDistance) const { ray.length = maxDistance; ray.primitive = nullptr; Color transparency(1, 1, 1); for (auto i: this->primitives()) { Ray r = ray; if (i->intersect(r) && r.length < maxDistance && i->shader()->isTransparent()) { Color t = i->shader()->transparency(*this, r, maxDistance); transparency.r *= t.r; transparency.g *= t.g; transparency.b *= t.b; } } return transparency; }