And CSG! \o/
Still working on a nice scene for it.
This commit is contained in:
52
source/include/csg.h
Normal file
52
source/include/csg.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* DoRayMe - a quick and dirty Raytracer
|
||||
* CSG header
|
||||
*
|
||||
* Created by Manoël Trapier
|
||||
* Copyright (c) 2020 986-Studio.
|
||||
*
|
||||
*/
|
||||
#ifndef DORAYME_CSG_H
|
||||
#define DORAYME_CSG_H
|
||||
|
||||
#include <shape.h>
|
||||
|
||||
class CSG : public Shape
|
||||
{
|
||||
public:
|
||||
enum OperationType
|
||||
{
|
||||
UNION,
|
||||
DIFFERENCE,
|
||||
INTERSECTION
|
||||
};
|
||||
|
||||
protected:
|
||||
Shape *left;
|
||||
Shape *right;
|
||||
OperationType operation;
|
||||
BoundingBox bounds;
|
||||
|
||||
protected:
|
||||
Intersect localIntersect(Ray r);
|
||||
Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
|
||||
BoundingBox getLocalBounds();
|
||||
|
||||
bool intersectionAllowed(bool leftHit, bool inLeft, bool inRight);
|
||||
|
||||
Intersect filterIntersections(Intersect &xs);
|
||||
|
||||
void updateBoundingBox();
|
||||
BoundingBox getBounds();
|
||||
|
||||
public:
|
||||
CSG(OperationType operation, Shape *left, Shape *right);
|
||||
|
||||
bool includes(Shape *b);
|
||||
|
||||
void updateTransform();
|
||||
|
||||
void dumpMe(FILE *fp);
|
||||
};
|
||||
|
||||
#endif /* DORAYME_CSG_H */
|
||||
Reference in New Issue
Block a user