Smooth triangles! And support for them in the OBJ File parser.

Also add an interesting tea party scene!
This commit is contained in:
Godzil
2020-03-06 15:07:26 +00:00
parent 73012b6dd1
commit e57b5715e8
38 changed files with 705 additions and 75 deletions

View File

@@ -16,7 +16,18 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
double n2 = 1.0;
Tuple hitP = r.position(this->t);
Tuple normalV = this->object->normalAt(hitP);
Tuple normalV;
if (xs != nullptr)
{
Intersection hit = xs->hit();
normalV = this->object->normalAt(hitP, &hit);
}
else
{
normalV = this->object->normalAt(hitP, nullptr);
}
Tuple eyeV = -r.direction;
bool inside = false;
@@ -70,8 +81,9 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
}
Shape *s = this->object;
/* For now don't get root group material */
//while(s->parent != nullptr) { s = s->parent; }
while((!s->materialSet) && (s->parent != nullptr)) { s = s->parent; }
return Computation(this->object,
this->t,