22 name =
"unknown triangle";
37 Triangle::Triangle(
unsigned int p1,
unsigned int p2,
unsigned int p3, std::vector<vec3>* _vertices,
74 constexpr
decimal EPSILON = 0.00001;
82 if (denominator >= 0.)
93 temporary.cross(w0,
v);
94 const decimal iu = temporary.dot(directeur) / denominator;
96 temporary.cross(
u, w0);
97 const decimal iv = temporary.dot(directeur) / denominator;
99 if (t >= -EPSILON && iu >= -EPSILON && iu <= 1. + EPSILON && iv >= -EPSILON && iv <= 1. + EPSILON &&
100 iu + iv <= 1. + EPSILON)
122 unsigned int nbSamples = (
unsigned int)(areaTriangle * density) + 1;
124 for (
unsigned int i = 0; i < nbSamples; i++)
128 while (randU + randV > 1.)
133 samples.push_back(
p +
u * randU +
v * randV);
Definition of a bounding box which is aligned along the axis (BBox AABB).
vec3 pMax
Upper point of the BBox.
BBox Union(const BBox &b, const vec3 &p)
Union of a point and a BBox. A new BBox is created.
vec3 pMin
Lower point of the BBox.
std::string name
Each instantiated object may be named.
: Describes a ray by a pair of unsigned int. The first one gives the source number (in the range 0-40...
vec3 getPosition() const
Return starting point ray.
vec3 getDirection() const
Return direction of the ray.
BBox box
Bounding box of the shape.
std::vector< vec3 > * vertices
GlobalVertices of the scene.
Material * material
Pointer to material.
void setIsSol(const bool &isSol)
bool isSol() const
Get/Set the flag _isSol (ground or not)
std::vector< unsigned int > localVertices
Index of the vertices used for this shape.
virtual bool sample(decimal density, std::vector< vec3 > &samples)
Uncommented method cause not used.
vec3 normal
Normalized normal to triangle.
virtual bool getIntersection(Ray &ray, Intersection &inter)
Get the Intersection between a ray and this shape.
virtual void updateBBox()
Update the bounding box:
vec3 planeNormal
Non-normalized normal, equal to u cross v.
vec3 v
Vector to reach the third vertex (vertex3=p+v)
vec3 u
Vector to reach the second vertex (vertex2=p+u)
Triangle()
Default constructor.
vec3 p
First vertex (vertex1=p)
vec3 Vector_r(const vec3 &vp1, const vec3 &vp2)
base_vec3< decimal > vec3