Working on refraction & transparency.

Lots of work left to do!
This commit is contained in:
Godzil
2020-02-21 18:59:14 +00:00
parent 89dd74fa7c
commit df52cb36db
9 changed files with 219 additions and 9 deletions

View File

@@ -13,13 +13,14 @@
#include <ray.h>
class Shape;
class Intersect;
struct Computation
{
Computation(Shape *object, double t, Tuple point, Tuple eyev, Tuple normalv, Tuple overHitP,
bool inside, Tuple reflectV = Vector(0, 0, 0)) :
bool inside, Tuple reflectV = Vector(0, 0, 0), double n1 = 1.0, double n2 = 1.0) :
object(object), t(t), hitPoint(point), eyeVector(eyev), normalVector(normalv), inside(inside),
overHitPoint(overHitP), reflectVector(reflectV) { };
overHitPoint(overHitP), reflectVector(reflectV), n1(n1), n2(n2) { };
Shape *object;
double t;
@@ -29,6 +30,9 @@ struct Computation
Tuple normalVector;
Tuple reflectVector;
double n1;
double n2;
bool inside;
};
@@ -42,7 +46,7 @@ public:
Intersection(double t, Shape *object) : t(t), object(object) { };
bool nothing() { return (this->object == nullptr); };
Computation prepareComputation(Ray r);
Computation prepareComputation(Ray r, Intersect *xs = nullptr);
bool operator==(const Intersection &b) const { return ((this->t == b.t) && (this->object == b.object)); };
};