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

@@ -30,17 +30,19 @@ enum ShapeType
SHAPE_GROUP,
SHAPE_TRIANGLE,
SHAPE_OBJFILE,
SHAPE_SMOOTHTRIANGLE,
};
/* Base class for all object that can be presented in the world */
class Shape
{
private:
protected:
ShapeType type;
Matrix localTransformMatrix;
protected:
virtual Intersect localIntersect(Ray r) = 0;
virtual Tuple localNormalAt(Tuple point) = 0;
virtual Tuple localNormalAt(Tuple point, Intersection *hit) = 0;
public:
Matrix transformMatrix;
@@ -50,13 +52,14 @@ public:
Material material;
bool dropShadow;
Shape *parent;
bool materialSet;
public:
Shape(ShapeType = SHAPE_NONE);
virtual Intersect intersect(Ray r);
virtual Intersect intersectOOB(Ray r) { return this->intersect(r); };
Tuple normalAt(Tuple point);
Tuple normalAt(Tuple point, Intersection *hit = nullptr);
/* Bounding box points are always world value */
virtual BoundingBox getLocalBounds();