Loading LrBinderSimple.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,7 @@ bool LrBinderSimple::getIntersection(const LrRay &ray, LrHit *hit, Real minbound oneintersect=true; if(hit != NULL) maxbound = hit->distance; else break; else break; } } return oneintersect; Loading LrGeometryPlan.cpp 0 → 100644 +130 −0 Original line number Diff line number Diff line /** * @brief GÉOMÉTRIE : Gestion d'un plan infini * @file LrGeometryPlan.h * @date Vendredi 7 mars 2008 * @note * @author Josselin Francois * @author Michael Nauge * @author Axel Richard * @author Hervé Souchaud * @author Emeric Verschuur * * Ce fichier contient la classe qui gère une géométrie pour un plan infini. */ #if defined HAVE_CONFIG_H #include "config.h" #endif #include <cstdlib> #include "LrGeometryPlan.h" LrGeometryPlan::LrGeometryPlan() : LrGeometry(), m_normale(LrVector::ZERO) { } LrGeometryPlan::LrGeometryPlan(const LrGeometryPlan& src) : LrGeometry(src), m_normale(src.m_normale) { } LrGeometryPlan::LrGeometryPlan(const LrVector &normale) : LrGeometry(), m_normale(normale) { } LrGeometryPlan::~LrGeometryPlan() { } LrGeometryPlan& LrGeometryPlan::operator = (const LrGeometryPlan& src) { if(this==&src) return *this; LrGeometry::operator = (src); return *this; } bool operator == (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs) { return (const LrGeometry&)rhs == (const LrGeometry&)lhs /* and [...] */; } bool operator != (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs) { return ! (rhs==lhs); } int LrGeometryPlan::getNbFragments() const { return 1; } bool LrGeometryPlan::getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound, Real maxBound) const { Real coefAngle; Real dist; LrPoint originRay = ray.getOrigin(); LrVector tmpO(originRay.x, originRay.y, originRay.z); //calcule de l'angle formé par le vecteur directeur du rayon et la normal du plan coefAngle = m_normale * ray.getDirection(); if (coefAngle == 0.0) return false; //le rayon est parallele au plan dist = -((m_normale * tmpO) / coefAngle); if(dist < minBound || dist > maxBound) return false; //derriere l'origine du rayon if (hit != NULL) { Real u, v; LrVector normal; LrVector tangent; hit->point = ray.getPoint(dist); hit->distance = dist; // ca ressemblerait a un truc comme ca : xyz2uv(hit->point, u, v); hit->u = u; hit->v = v; //uv2xyz(u, v, NULL, &normal, &tangent); if(coefAngle < 0.0) hit->normal = m_normale; else hit->normal = -m_normale; hit->normal = m_normale; hit->tangent = tangent; } return true; } void LrGeometryPlan::getMinMax(LrPoint &min, LrPoint &max, int fragment) const{ min = LrPoint(-1.,-1.,-1.); max = LrPoint(1.,1.,1.); } void LrGeometryPlan::xyz2uv(const LrPoint &point, Real &u, Real &v) const { // [...] LrGeometry::xyz2uv(point, u, v); } void LrGeometryPlan::uv2xyz(Real u, Real v, LrPoint *point, LrVector *normal, LrVector *tangent) const { // [...] } LrGeometryPlan.h 0 → 100644 +126 −0 Original line number Diff line number Diff line /** * @brief GÉOMÉTRIE : Gestion d'un plan infini * @file LrGeometryPlan.h * @date Vendredi 7 mars 2008 * @note * @author Josselin Francois * @author Michael Nauge * @author Axel Richard * @author Hervé Souchaud * @author Emeric Verschuur * * Ce fichier contient la classe qui gère une géométrie pour un plan infini. */ #ifndef LRGEOMETRYPLAN_H #define LRGEOMETRYPLAN_H #include "LrGeometry.h" /** * @brief GÉOMÉTRIE : Gestion d'une géométrie sphérique * * Cette classe gère une géométrie sphérique. */ class LrGeometryPlan : public LrGeometry { public: /** * @brief Constructeur. * @param center Centre de la sphère. * @param r Rayon de la sphère. */ LrGeometryPlan(); /** * @brief Constructeur par copie. * @param src Référence d'un objet LrGeometryPlan. */ LrGeometryPlan(const LrGeometryPlan& src); /** * @brief Constructeur personnel. * @param normale la normale au plan */ LrGeometryPlan(const LrVector &normale); /** * @brief Destructeur. */ virtual ~LrGeometryPlan(); /** * @brief Opérateur d'affectation. * @param src Géométrie source. * @return Une référence sur l'objet affecté. */ LrGeometryPlan& operator = (const LrGeometryPlan& src); /** * @brief Opérateur de test d'égalité. * @return vrai ou faux. */ friend bool operator == (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs); /** * @brief Opérateur de test d'inégalité. * @return vrai ou faux. */ friend bool operator != (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs); /** * @brief Donne le nombre de fragments de la géométrie. * @return Un entier. */ virtual int getNbFragments() const; /** * @brief Donne d'intersection entre un rayon et la géométrie. * @param ray Référence d'un objet LrRay. * @param hit Adresse de l'objet LrHit dans lequel sera stocké le résultat. * @param minBound Distance minimum par rapport à l'origine (défaut : 0). * @param maxBound Distance maximum par rapport à l'origine (défaut : INFINITY). * @return vrai si il y a une intersection, sinon faux. * * Cette méthode calcul l'intersection entre le rayon @a ray et la géométrie * et stocke le résultat dans la sructure LrHit pointée par @a hit si ce * dernier n'est pas égal à NULL. On peut également spécifier la portion du * rayon, à l'aide des paramètres @a minBound @a maxBound , à prendre en * compte pour ce calcul. */ virtual bool getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound=0, Real maxBound=INFINITY) const; /** * @brief Calcul des points min et max de la boîte englobante. * @param min LrPoint minimum de la boîte. * @param max LrPoint maximum de la boîte. * * Calcule le point "en bas, devant, à gauche" et le point "en haut, * derrière, à droite" de la géométrie. */ virtual void getMinMax(LrPoint &min, LrPoint &max, int fragment) const; protected: /** * @brief Conversion de coordonnées absolues en paramétriques. * @param point Point à convertir. * @param u Réel u (paramètre out). * @param v Réel v (paramètre out). */ virtual void xyz2uv(const LrPoint &point, Real &u, Real &v) const; /** * @brief Conversion de coordonnées paramétriques en absolues. * @param u Réel u. * @param v Réel v. * @param point Point résultant (paramètre out). * @param normal Normale à ce point (paramètre out). * @param tangent Tangente à ce point (paramètre out). */ virtual void uv2xyz(Real u, Real v, LrPoint *point, LrVector *normal, LrVector *tangent) const; private: LrVector m_normale; }; #endif LrOptic.h +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ public: * @param u coordonnée paramétriques. * @param v coordonnée paramétriques. */ virtual LrColor compute(const LrVector &rayIn, const LrVector &rayOut, virtual LrColor compute(const LrRay &rayIn, const LrVector &rayOut, const LrVector &normal, const LrVector &tangeante, Real u, Real v) const =0; Loading LrOpticBasic.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -80,11 +80,12 @@ bool operator != (const LrOpticBasic &lhs, const LrOpticBasic &rhs) return (! (lhs == rhs)); } LrColor LrOpticBasic:: compute(const LrVector &rayIn, const LrVector &rayOut, LrColor LrOpticBasic:: compute(const LrRay &rayIn, const LrVector &rayOut, const LrVector &normal,const LrVector &tangeante, Real u, Real v) const { return m_pertColor->getColor(u,v); LrColor colorPhong; LrPoint point = rayIn.getOrigin(); colorPhong = m_pertColor->getColor(u, v, point); } Loading
LrBinderSimple.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,7 @@ bool LrBinderSimple::getIntersection(const LrRay &ray, LrHit *hit, Real minbound oneintersect=true; if(hit != NULL) maxbound = hit->distance; else break; else break; } } return oneintersect; Loading
LrGeometryPlan.cpp 0 → 100644 +130 −0 Original line number Diff line number Diff line /** * @brief GÉOMÉTRIE : Gestion d'un plan infini * @file LrGeometryPlan.h * @date Vendredi 7 mars 2008 * @note * @author Josselin Francois * @author Michael Nauge * @author Axel Richard * @author Hervé Souchaud * @author Emeric Verschuur * * Ce fichier contient la classe qui gère une géométrie pour un plan infini. */ #if defined HAVE_CONFIG_H #include "config.h" #endif #include <cstdlib> #include "LrGeometryPlan.h" LrGeometryPlan::LrGeometryPlan() : LrGeometry(), m_normale(LrVector::ZERO) { } LrGeometryPlan::LrGeometryPlan(const LrGeometryPlan& src) : LrGeometry(src), m_normale(src.m_normale) { } LrGeometryPlan::LrGeometryPlan(const LrVector &normale) : LrGeometry(), m_normale(normale) { } LrGeometryPlan::~LrGeometryPlan() { } LrGeometryPlan& LrGeometryPlan::operator = (const LrGeometryPlan& src) { if(this==&src) return *this; LrGeometry::operator = (src); return *this; } bool operator == (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs) { return (const LrGeometry&)rhs == (const LrGeometry&)lhs /* and [...] */; } bool operator != (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs) { return ! (rhs==lhs); } int LrGeometryPlan::getNbFragments() const { return 1; } bool LrGeometryPlan::getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound, Real maxBound) const { Real coefAngle; Real dist; LrPoint originRay = ray.getOrigin(); LrVector tmpO(originRay.x, originRay.y, originRay.z); //calcule de l'angle formé par le vecteur directeur du rayon et la normal du plan coefAngle = m_normale * ray.getDirection(); if (coefAngle == 0.0) return false; //le rayon est parallele au plan dist = -((m_normale * tmpO) / coefAngle); if(dist < minBound || dist > maxBound) return false; //derriere l'origine du rayon if (hit != NULL) { Real u, v; LrVector normal; LrVector tangent; hit->point = ray.getPoint(dist); hit->distance = dist; // ca ressemblerait a un truc comme ca : xyz2uv(hit->point, u, v); hit->u = u; hit->v = v; //uv2xyz(u, v, NULL, &normal, &tangent); if(coefAngle < 0.0) hit->normal = m_normale; else hit->normal = -m_normale; hit->normal = m_normale; hit->tangent = tangent; } return true; } void LrGeometryPlan::getMinMax(LrPoint &min, LrPoint &max, int fragment) const{ min = LrPoint(-1.,-1.,-1.); max = LrPoint(1.,1.,1.); } void LrGeometryPlan::xyz2uv(const LrPoint &point, Real &u, Real &v) const { // [...] LrGeometry::xyz2uv(point, u, v); } void LrGeometryPlan::uv2xyz(Real u, Real v, LrPoint *point, LrVector *normal, LrVector *tangent) const { // [...] }
LrGeometryPlan.h 0 → 100644 +126 −0 Original line number Diff line number Diff line /** * @brief GÉOMÉTRIE : Gestion d'un plan infini * @file LrGeometryPlan.h * @date Vendredi 7 mars 2008 * @note * @author Josselin Francois * @author Michael Nauge * @author Axel Richard * @author Hervé Souchaud * @author Emeric Verschuur * * Ce fichier contient la classe qui gère une géométrie pour un plan infini. */ #ifndef LRGEOMETRYPLAN_H #define LRGEOMETRYPLAN_H #include "LrGeometry.h" /** * @brief GÉOMÉTRIE : Gestion d'une géométrie sphérique * * Cette classe gère une géométrie sphérique. */ class LrGeometryPlan : public LrGeometry { public: /** * @brief Constructeur. * @param center Centre de la sphère. * @param r Rayon de la sphère. */ LrGeometryPlan(); /** * @brief Constructeur par copie. * @param src Référence d'un objet LrGeometryPlan. */ LrGeometryPlan(const LrGeometryPlan& src); /** * @brief Constructeur personnel. * @param normale la normale au plan */ LrGeometryPlan(const LrVector &normale); /** * @brief Destructeur. */ virtual ~LrGeometryPlan(); /** * @brief Opérateur d'affectation. * @param src Géométrie source. * @return Une référence sur l'objet affecté. */ LrGeometryPlan& operator = (const LrGeometryPlan& src); /** * @brief Opérateur de test d'égalité. * @return vrai ou faux. */ friend bool operator == (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs); /** * @brief Opérateur de test d'inégalité. * @return vrai ou faux. */ friend bool operator != (const LrGeometryPlan& rhs, const LrGeometryPlan& lhs); /** * @brief Donne le nombre de fragments de la géométrie. * @return Un entier. */ virtual int getNbFragments() const; /** * @brief Donne d'intersection entre un rayon et la géométrie. * @param ray Référence d'un objet LrRay. * @param hit Adresse de l'objet LrHit dans lequel sera stocké le résultat. * @param minBound Distance minimum par rapport à l'origine (défaut : 0). * @param maxBound Distance maximum par rapport à l'origine (défaut : INFINITY). * @return vrai si il y a une intersection, sinon faux. * * Cette méthode calcul l'intersection entre le rayon @a ray et la géométrie * et stocke le résultat dans la sructure LrHit pointée par @a hit si ce * dernier n'est pas égal à NULL. On peut également spécifier la portion du * rayon, à l'aide des paramètres @a minBound @a maxBound , à prendre en * compte pour ce calcul. */ virtual bool getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound=0, Real maxBound=INFINITY) const; /** * @brief Calcul des points min et max de la boîte englobante. * @param min LrPoint minimum de la boîte. * @param max LrPoint maximum de la boîte. * * Calcule le point "en bas, devant, à gauche" et le point "en haut, * derrière, à droite" de la géométrie. */ virtual void getMinMax(LrPoint &min, LrPoint &max, int fragment) const; protected: /** * @brief Conversion de coordonnées absolues en paramétriques. * @param point Point à convertir. * @param u Réel u (paramètre out). * @param v Réel v (paramètre out). */ virtual void xyz2uv(const LrPoint &point, Real &u, Real &v) const; /** * @brief Conversion de coordonnées paramétriques en absolues. * @param u Réel u. * @param v Réel v. * @param point Point résultant (paramètre out). * @param normal Normale à ce point (paramètre out). * @param tangent Tangente à ce point (paramètre out). */ virtual void uv2xyz(Real u, Real v, LrPoint *point, LrVector *normal, LrVector *tangent) const; private: LrVector m_normale; }; #endif
LrOptic.h +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ public: * @param u coordonnée paramétriques. * @param v coordonnée paramétriques. */ virtual LrColor compute(const LrVector &rayIn, const LrVector &rayOut, virtual LrColor compute(const LrRay &rayIn, const LrVector &rayOut, const LrVector &normal, const LrVector &tangeante, Real u, Real v) const =0; Loading
LrOpticBasic.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -80,11 +80,12 @@ bool operator != (const LrOpticBasic &lhs, const LrOpticBasic &rhs) return (! (lhs == rhs)); } LrColor LrOpticBasic:: compute(const LrVector &rayIn, const LrVector &rayOut, LrColor LrOpticBasic:: compute(const LrRay &rayIn, const LrVector &rayOut, const LrVector &normal,const LrVector &tangeante, Real u, Real v) const { return m_pertColor->getColor(u,v); LrColor colorPhong; LrPoint point = rayIn.getOrigin(); colorPhong = m_pertColor->getColor(u, v, point); }