Smooth triangles! And support for them in the OBJ File parser.
Also add an interesting tea party scene!
This commit is contained in:
28
source/shapes/smoothtriangle.cpp
Normal file
28
source/shapes/smoothtriangle.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* DoRayMe - a quick and dirty Raytracer
|
||||
* Smooth Triangle implementation
|
||||
*
|
||||
* Created by Manoël Trapier
|
||||
* Copyright (c) 2020 986-Studio.
|
||||
*
|
||||
*/
|
||||
#include <ray.h>
|
||||
#include <shape.h>
|
||||
#include <triangle.h>
|
||||
#include <smoothtriangle.h>
|
||||
#include <math_helper.h>
|
||||
#include <renderstat.h>
|
||||
|
||||
SmoothTriangle::SmoothTriangle(Point p1, Point p2, Point p3, Vector n1, Vector n2, Vector n3) : Triangle(p1, p2, p3),
|
||||
n1(n1), n2(n2), n3(n3)
|
||||
{
|
||||
this->type = SHAPE_SMOOTHTRIANGLE;
|
||||
stats.addSmoothTriangle();
|
||||
}
|
||||
|
||||
Tuple SmoothTriangle::localNormalAt(Tuple point, Intersection *hit)
|
||||
{
|
||||
return (this->n2 * hit->u +
|
||||
this->n3 * hit->v +
|
||||
this->n1 * (1 - hit->u - hit->v)).normalise();
|
||||
}
|
||||
Reference in New Issue
Block a user