representation d'un triangle position + normale. More...
#include <PNTriangle.h>
Public Member Functions | |
| PNTriangle () | |
| constructeur par defaut. | |
| PNTriangle (const Point &_a, const Normal &_na, const Point &_b, const Normal &_nb, const Point &_c, const Normal &_nc) | |
| construit un triangle connaissant ses 3 sommets et leur normales. | |
| PNTriangle (const Triangle &abc, const Normal &_na, const Normal &_nb, const Normal &_nc) | |
| construit un triangle connaissant le triangle de base et les normales des sommets. | |
| ~PNTriangle () | |
| destructeur. | |
| Normal | getUVNormal (const float u, const float v) const |
| calcule la normale a l'interieur du triangle connaissant ses coordonnees barycentriques. | |
| PNTriangle | transform (const Transform &t) |
| renvoie un pntriangle transforme par 't'. | |
| Triangle | getBaseTriangle () |
| renvoie le triangle geometrique support du PN triangle. | |
| float | getArea () const |
| calcule l'aire du triangle. | |
| Normal | getNormal () const |
| calcule la normale du triangle. | |
| Vector | local (const Vector &v) const |
| changement de repere du vecteur 'v' global, renvoie le vecteur dans le repere local (bitangent, tangent, normal). | |
| Vector | world (const Vector &v) const |
| changement de repere du vecteur 'v' local, renvoie le vecteur dans le repere global. | |
| BBox | getBBox () const |
| calcule la boite englobante du triangle. | |
| bool | Intersect (const Ray &ray, const float htmax, float &rt, float &ru, float &rv) const |
| intersection avec un rayon. | |
| Point | getUVPoint (const float u, const float v) const |
| renvoie un point a l'interieur du triangle connaissant ses coordonnees barycentriques. | |
| float | sampleUniform (const float u1, const float u2, Point &p) const |
| choisit un point aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisi. | |
| float | sampleUniform (Sampler &sampler, Point &p) const |
| choisit un point aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisi. | |
| float | sampleUniformUV (const float u1, const float u2, float &u, float &v) const |
| choisit une position aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisie. | |
| float | sampleUniformUV (Sampler &sampler, float &u, float &v) const |
| choisit une position aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisie. | |
| float | pdfUniform (const Point &p) const |
| renvoie la probabilite de choisir le point p aleatoirement. | |
Public Attributes | |
| Normal | na |
| Normal | nb |
| Normal | nc |
| Point | a |
| Point | b |
| Point | c |
| float | area |
representation d'un triangle position + normale.
| Normal gk::PNTriangle::getUVNormal | ( | const float | u, |
| const float | v | ||
| ) | const [inline] |
calcule la normale a l'interieur du triangle connaissant ses coordonnees barycentriques.
convention n(u, v)= (1 - u - v) * na + u * nb + v * nc.
References gk::Normalize().
| bool gk::Triangle::Intersect | ( | const Ray & | ray, |
| const float | htmax, | ||
| float & | rt, | ||
| float & | ru, | ||
| float & | rv | ||
| ) | const [inline, inherited] |
intersection avec un rayon.
renvoie faux s'il n'y a pas d'intersection valide, une intersection peut exister mais peut ne pas se trouver dans l'intervalle [0 htmax] du rayon.
renvoie vrai + les coordonnees barycentriques (ru, rv) du point d'intersection + sa position le long du rayon (rt).
convention barycentrique : t(u, v)= (1 - u - v) * a + u * b + v * c
utiliser Mesh::getUVNormal() et Mesh::getUVTexCoord() pour interpoler les attributs du point d'intersection.
ou PNTriangle::getUVNormal().
le parametre htmax permet de trouver tres facilement l'intersection la plus proche de l'origine du rayon.
float t= ray.tmax; // ou t= HUGE_VAL; la plus grande distance le long du rayon. // rechercher le triangle le plus proche de l'origine du rayon for(int i= 0; i < n; i++) { float rt; float ru, rv; if(triangle[i].Intersect(ray, t, rt, ru, rv)) t= rt; }
References gk::Cross(), gk::BasicRay::d, gk::Dot(), and gk::BasicRay::o.
| Point gk::Triangle::getUVPoint | ( | const float | u, |
| const float | v | ||
| ) | const [inline, inherited] |
renvoie un point a l'interieur du triangle connaissant ses coordonnees barycentriques.
convention p(u, v)= (1 - u - v) * a + u * b + v * c
| float gk::Triangle::sampleUniform | ( | const float | u1, |
| const float | u2, | ||
| Point & | p | ||
| ) | const [inline, inherited] |
choisit un point aleatoirement a la surface du triangle et renvoie la probabilite de l'avoir choisi.
| u1,u2 | valeurs aleatoires entre [0 .. 1] utilisées pour le tirage aleatoire. |
Referenced by gk::Triangle::sampleUniform().
| float gk::Triangle::pdfUniform | ( | const Point & | p | ) | const [inline, inherited] |
renvoie la probabilite de choisir le point p aleatoirement.
remarque: le point doit appartenir au triangle.
1.7.6.1