22 name =
"unknown triangle";
36 Triangle::Triangle(
unsigned int p1,
unsigned int p2,
unsigned int p3, std::vector<vec3>* _vertices,
73 directeur.normalize();
74 if (directeur.dot(this->normal) > 0.)
82 double ir = NAN, iu = NAN, iv = NAN;
85 ir = -(n.dot(otr)) / (n.dot(directeur));
87 iu = (temp.dot(directeur)) / (n.dot(directeur));
89 iv = (temp.dot(directeur)) / (n.dot(directeur));
91 if (iu >= -0.00001 && iu <= 1.00001 && iv >= -0.00001 && iv <= 1.00001 && ir >= -0.00001 &&
112 unsigned int nbSamples = (
unsigned int)(areaTriangle * density) + 1;
114 for (
unsigned int i = 0; i < nbSamples; i++)
118 while (randU + randV > 1.)
123 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
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 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