gKitGL
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends
Public Member Functions | Public Attributes
gk::PTNTriangle Struct Reference

representation d'un triangle position + coordonnees de texture + normale. More...

#include <PTNTriangle.h>

Inheritance diagram for gk::PTNTriangle:
gk::PNTriangle gk::Triangle

List of all members.

Public Member Functions

 PTNTriangle ()
 constructeur par defaut.
 PTNTriangle (const Point &_a, const Normal &_na, const Point2 &_ta, const Point &_b, const Normal &_nb, const Point2 &_tb, const Point &_c, const Normal &_nc, const Point2 &_tc)
 construit un triangle connaissant ses 3 sommets, leurs normales et leurs coordonnees de textures.
 PTNTriangle (const Triangle &_abc, const Normal &_na, const Point2 &_ta, const Normal &_nb, const Point2 &_tb, const Normal &_nc, const Point2 &_tc)
 construit un triangle connaissant le triangle de base, les normales et les coordonnees de textures des sommets.
 PTNTriangle (const PNTriangle &_abc, const Point2 &_ta, const Point2 &_tb, const Point2 &_tc)
 construit un triangle connaissant un pn triangle et les coordonnees de textures des sommets.
 ~PTNTriangle ()
 destructeur.
PTNTriangle transform (const Transform &t)
 renvoie un pntriangle transforme par 't'.
Triangle getBaseTriangle ()
 renvoie le triangle geometrique.
PNTriangle getPNTriangle ()
 renvoie le pn triangle.
Point2 getUVTexcoord (const float u, const float v) const
 calcule les coordonnees de texture d'un point a l'interieur du triangle connaissant ses coordonnees barycentriques.
Normal getUVNormal (const float u, const float v) const
 calcule la normale a l'interieur du triangle connaissant ses coordonnees barycentriques.
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

Point2 ta
Point2 tb
Point2 tc
Normal na
Normal nb
Normal nc
Point a
Point b
Point c
float area

Detailed Description

representation d'un triangle position + coordonnees de texture + normale.


Member Function Documentation

Point2 gk::PTNTriangle::getUVTexcoord ( const float  u,
const float  v 
) const [inline]

calcule les coordonnees de texture d'un point a l'interieur du triangle connaissant ses coordonnees barycentriques.

convention t(u, v)= (1 - u - v) * ta + u * tb + v * tc.

Normal gk::PNTriangle::getUVNormal ( const float  u,
const float  v 
) const [inline, inherited]

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.

Parameters:
u1,u2valeurs 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.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends