Loading LrEntity.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,11 @@ LrMatrix LrEntity::getMat() const return m_mat; } void LrEntity::setMat(const LrMatrix &mat) { m_mat = mat; } bool LrEntity::getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound, Real maxBound) const { Loading LrEntity.h +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public: * @brief Défini la matrice de position. * @param mat Référence d'un objet LrMatrix. */ void setMat(const LrMatrix &mat) const; void setMat(const LrMatrix &mat); /** * @brief Opérateur d'affectation. Loading LrEntityLight.cpp→LrLight.cpp +76 −0 Original line number Diff line number Diff line /** * @brief ENTITÉ : Gestion d'entité lumiere. Classe abstraite. * @file LrEntityLight.cpp * @brief LUMIÈRE : Gestion d'une lumiere. Classe abstraite. * @file LrLight.cpp * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -16,78 +16,61 @@ #include "config.h" #endif #include "LrEntityLight.h" #include "LrLight.h" LrEntityLight::LrEntityLight(const LrMatrix &mat) LrLight::LrLight(const LrMatrix &mat) : LrEntity(mat) m_mat(mat) { } LrEntityLight::LrEntityLight(const LrEntityLight &source) LrLight::LrLight(const LrLight &source) : LrEntity(source) m_mat(source.m_mat) { } LrEntityLight::LrEntityLight(const LrMatrix &mat, const LrColor &col) LrLight::LrLight(const LrMatrix &mat, const LrColor &col) : LrEntity(mat), m_mat(mat), m_color(col) { } LrEntityLight::~LrEntityLight() LrLight::~LrLight() { } void LrEntityLight::pack(const LrMatrix &mat) LrMatrix LrLight::getMat() const { return m_mat; } void LrLight::setMat(const LrMatrix &mat) { m_mat = mat; } LrColor LrEntityLight::getColor()const LrColor LrLight::getColor()const { return m_color; } LrEntityLight& LrEntityLight::operator = (const LrEntityLight& source) LrLight& LrLight::operator = (const LrLight& source) { if (this==&source) return *this; LrEntity::operator = (source); m_color=source.m_color; return *this; } bool LrEntityLight::operator == (const LrEntityLight& source) bool LrLight::operator == (const LrLight& source) { return LrEntity::operator == (source) && m_color==source.m_color; return m_color==source.m_color; } bool LrEntityLight::operator != (const LrEntityLight& source) bool LrLight::operator != (const LrLight& source) { return ! operator == (source); } bool LrEntityLight::getIntersection(const LrRay &ray, LrHit *hit, Real minBound, Real maxBound) const { return false; } void LrEntityLight::getMinMax(LrPoint &min, LrPoint &max, int fragment, LrEntity *&entityLocal, int &fragmentLocal) const { } void LrEntityLight::getMinMax(LrPoint &min, LrPoint &max) const { } int LrEntityLight::getNbFragments() const{ return 1; } LrEntityLight.h→LrLight.h +109 −0 Original line number Diff line number Diff line /** * @brief Classe abstraite pour la génération de lumiere. * @file LrEntityLight.h * @brief LUMIÈRE : Classe abstraite pour la génération de lumiere. * @file LrLight.h * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -20,49 +20,48 @@ /** * @brief ENTITE : Gestion d'objets. * @brief LUMIÈRE : Gestion d'une lumière. * * Cette classe est une classe abstraite permettant la génération de lumiere. */ class LrEntityLight : public LrEntity class LrLight { public: typedef enum Type { LIGHT_POINT, LIGHT_SPOT, LIGHT_PLANE }; /** * @brief Constructeur par defaut. La lumiere est blanche. * @param mat Référence d'un objet LrMatrix. */ LrEntityLight(const LrMatrix &mat); LrLight(const LrMatrix &mat); /** * @brief Constructeur par copie. * @param source Référence d'un objet LrEntityLight. * @param source Référence d'un objet LrLight. */ LrEntityLight(const LrEntityLight &source); LrLight(const LrLight &source); /** * @brief Constructeur par copie. * @param mat Référence d'un objet LrMatrix. * @param col Reference d'une objet LrColor. */ LrEntityLight(const LrMatrix &mat, const LrColor &col); LrLight(const LrMatrix &mat, const LrColor &col); /** * @brief Destructeur. */ virtual ~LrEntityLight(); virtual ~LrLight(); /** * @brief Calcul des matrices de transformation. * @brief Retourne une copie de la matrice de position. * @return Objet LrMatrix. */ virtual void pack(const LrMatrix &mat); LrMatrix getMat() const; /** * @brief Défini la matrice de position. * @param mat Référence d'un objet LrMatrix. */ void setMat(const LrMatrix &mat); /** * @brief Retourne la position de l'entite Loading @@ -86,73 +85,22 @@ public: * @param source Entitée source. * @return Une référence sur l'objet affecté. */ LrEntityLight& operator = (const LrEntityLight& source); LrLight& operator = (const LrLight& source); /** * @brief Opérateur de test d'égalité. * @return vrai ou faux. */ bool operator == (const LrEntityLight& source); bool operator == (const LrLight& source); /** * @brief Opérateur de test d'inégalité. * @return vrai ou faux. */ bool operator != (const LrEntityLight& source); /** * @brief Renvoi le type de lumiere. */ virtual int typeLumiere() const=0; /** * @brief Donne d'intersection entre un rayon et l'entitée. * @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 l'entitée * 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, Real minBound=0, Real maxBound=INFINITY) const; /** * @brief Donne le nombre de fragments de l'entitée. * @return Un entier. */ virtual int getNbFragments() 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. * @param fragment fragment de l'entitée raçine. * @param entityLocal Entitée dans lequel se trouve le fragment. * @param fragmentLocal fragment de l'entitée locale. * * Calcule le point "en bas, devant, à gauche" et le point "en haut, * derrière, à droite" de l'entitée. */ virtual void getMinMax(LrPoint &min, LrPoint &max, int fragment, LrEntity *&entityLocal, int &fragmentLocal) 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 l'entitée. */ virtual void getMinMax(LrPoint &min, LrPoint &max) const; bool operator != (const LrLight& source); private : LrMatrix m_mat; /// @brief Couleur de la lumiere. LrColor m_color; }; Loading LrEntityLightPlane.cpp→LrLightPlane.cpp +87 −0 Original line number Diff line number Diff line /** * @brief ENTITÉ : Gestion d'entité lumiere-surface. * @file LrEntityLightPlane.cpp * @file LrLightPlane.cpp * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -17,60 +17,60 @@ #include "config.h" #endif #include "LrEntityLightPlane.h" #include "LrLightPlane.h" #include <cstdlib> LrEntityLightPlane::LrEntityLightPlane(const LrMatrix &mat) LrLightPlane::LrLightPlane(const LrMatrix &mat) : LrEntityLight(mat), LrLight(mat), m_nbRay(1) { } LrEntityLightPlane::LrEntityLightPlane(const LrEntityLightPlane &source) LrLightPlane::LrLightPlane(const LrLightPlane &source) : LrEntityLight(source) LrLight(source) { m_nbRay=source.m_nbRay; } LrEntityLightPlane::LrEntityLightPlane(const LrMatrix &mat, const LrColor &col, unsigned int nbRay) LrLightPlane::LrLightPlane(const LrMatrix &mat, const LrColor &col, unsigned int nbRay) : LrEntityLight(mat, col), LrLight(mat, col), m_nbRay(nbRay) { } LrEntityLightPlane * LrEntityLightPlane::clone() const LrLightPlane * LrLightPlane::clone() const { return new LrEntityLightPlane(*this); return new LrLightPlane(*this); } LrEntityLightPlane::~LrEntityLightPlane() LrLightPlane::~LrLightPlane() { } LrEntityLightPlane& LrEntityLightPlane::operator = (const LrEntityLightPlane& source) LrLightPlane& LrLightPlane::operator = (const LrLightPlane& source) { if (this==&source) return *this; LrEntityLight::operator = (source); LrLight::operator = (source); return *this; } bool LrEntityLightPlane::operator == (const LrEntityLightPlane& source) bool LrLightPlane::operator == (const LrLightPlane& source) { return LrEntityLight::operator == (source); return LrLight::operator == (source); } bool LrEntityLightPlane::operator != (const LrEntityLightPlane& source) bool LrLightPlane::operator != (const LrLightPlane& source) { return ! operator == (source); } LrPoint LrEntityLightPlane::getPos() const LrPoint LrLightPlane::getPos() const { LrVector v( (Real)(1.0 * rand()/RAND_MAX) * getMat().getCoeff(1,1), Loading @@ -82,11 +82,6 @@ LrPoint LrEntityLightPlane::getPos() const return LrPoint(getMat()*pt); } unsigned int LrEntityLightPlane::getNbRay() const{ unsigned int LrLightPlane::getNbRay() const{ return m_nbRay; } int LrEntityLightPlane::typeLumiere() const { return LrEntityLight::LIGHT_PLANE; } Loading
LrEntity.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,11 @@ LrMatrix LrEntity::getMat() const return m_mat; } void LrEntity::setMat(const LrMatrix &mat) { m_mat = mat; } bool LrEntity::getIntersection(const LrRay &ray, LrHit *hit, int fragment, Real minBound, Real maxBound) const { Loading
LrEntity.h +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public: * @brief Défini la matrice de position. * @param mat Référence d'un objet LrMatrix. */ void setMat(const LrMatrix &mat) const; void setMat(const LrMatrix &mat); /** * @brief Opérateur d'affectation. Loading
LrEntityLight.cpp→LrLight.cpp +76 −0 Original line number Diff line number Diff line /** * @brief ENTITÉ : Gestion d'entité lumiere. Classe abstraite. * @file LrEntityLight.cpp * @brief LUMIÈRE : Gestion d'une lumiere. Classe abstraite. * @file LrLight.cpp * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -16,78 +16,61 @@ #include "config.h" #endif #include "LrEntityLight.h" #include "LrLight.h" LrEntityLight::LrEntityLight(const LrMatrix &mat) LrLight::LrLight(const LrMatrix &mat) : LrEntity(mat) m_mat(mat) { } LrEntityLight::LrEntityLight(const LrEntityLight &source) LrLight::LrLight(const LrLight &source) : LrEntity(source) m_mat(source.m_mat) { } LrEntityLight::LrEntityLight(const LrMatrix &mat, const LrColor &col) LrLight::LrLight(const LrMatrix &mat, const LrColor &col) : LrEntity(mat), m_mat(mat), m_color(col) { } LrEntityLight::~LrEntityLight() LrLight::~LrLight() { } void LrEntityLight::pack(const LrMatrix &mat) LrMatrix LrLight::getMat() const { return m_mat; } void LrLight::setMat(const LrMatrix &mat) { m_mat = mat; } LrColor LrEntityLight::getColor()const LrColor LrLight::getColor()const { return m_color; } LrEntityLight& LrEntityLight::operator = (const LrEntityLight& source) LrLight& LrLight::operator = (const LrLight& source) { if (this==&source) return *this; LrEntity::operator = (source); m_color=source.m_color; return *this; } bool LrEntityLight::operator == (const LrEntityLight& source) bool LrLight::operator == (const LrLight& source) { return LrEntity::operator == (source) && m_color==source.m_color; return m_color==source.m_color; } bool LrEntityLight::operator != (const LrEntityLight& source) bool LrLight::operator != (const LrLight& source) { return ! operator == (source); } bool LrEntityLight::getIntersection(const LrRay &ray, LrHit *hit, Real minBound, Real maxBound) const { return false; } void LrEntityLight::getMinMax(LrPoint &min, LrPoint &max, int fragment, LrEntity *&entityLocal, int &fragmentLocal) const { } void LrEntityLight::getMinMax(LrPoint &min, LrPoint &max) const { } int LrEntityLight::getNbFragments() const{ return 1; }
LrEntityLight.h→LrLight.h +109 −0 Original line number Diff line number Diff line /** * @brief Classe abstraite pour la génération de lumiere. * @file LrEntityLight.h * @brief LUMIÈRE : Classe abstraite pour la génération de lumiere. * @file LrLight.h * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -20,49 +20,48 @@ /** * @brief ENTITE : Gestion d'objets. * @brief LUMIÈRE : Gestion d'une lumière. * * Cette classe est une classe abstraite permettant la génération de lumiere. */ class LrEntityLight : public LrEntity class LrLight { public: typedef enum Type { LIGHT_POINT, LIGHT_SPOT, LIGHT_PLANE }; /** * @brief Constructeur par defaut. La lumiere est blanche. * @param mat Référence d'un objet LrMatrix. */ LrEntityLight(const LrMatrix &mat); LrLight(const LrMatrix &mat); /** * @brief Constructeur par copie. * @param source Référence d'un objet LrEntityLight. * @param source Référence d'un objet LrLight. */ LrEntityLight(const LrEntityLight &source); LrLight(const LrLight &source); /** * @brief Constructeur par copie. * @param mat Référence d'un objet LrMatrix. * @param col Reference d'une objet LrColor. */ LrEntityLight(const LrMatrix &mat, const LrColor &col); LrLight(const LrMatrix &mat, const LrColor &col); /** * @brief Destructeur. */ virtual ~LrEntityLight(); virtual ~LrLight(); /** * @brief Calcul des matrices de transformation. * @brief Retourne une copie de la matrice de position. * @return Objet LrMatrix. */ virtual void pack(const LrMatrix &mat); LrMatrix getMat() const; /** * @brief Défini la matrice de position. * @param mat Référence d'un objet LrMatrix. */ void setMat(const LrMatrix &mat); /** * @brief Retourne la position de l'entite Loading @@ -86,73 +85,22 @@ public: * @param source Entitée source. * @return Une référence sur l'objet affecté. */ LrEntityLight& operator = (const LrEntityLight& source); LrLight& operator = (const LrLight& source); /** * @brief Opérateur de test d'égalité. * @return vrai ou faux. */ bool operator == (const LrEntityLight& source); bool operator == (const LrLight& source); /** * @brief Opérateur de test d'inégalité. * @return vrai ou faux. */ bool operator != (const LrEntityLight& source); /** * @brief Renvoi le type de lumiere. */ virtual int typeLumiere() const=0; /** * @brief Donne d'intersection entre un rayon et l'entitée. * @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 l'entitée * 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, Real minBound=0, Real maxBound=INFINITY) const; /** * @brief Donne le nombre de fragments de l'entitée. * @return Un entier. */ virtual int getNbFragments() 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. * @param fragment fragment de l'entitée raçine. * @param entityLocal Entitée dans lequel se trouve le fragment. * @param fragmentLocal fragment de l'entitée locale. * * Calcule le point "en bas, devant, à gauche" et le point "en haut, * derrière, à droite" de l'entitée. */ virtual void getMinMax(LrPoint &min, LrPoint &max, int fragment, LrEntity *&entityLocal, int &fragmentLocal) 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 l'entitée. */ virtual void getMinMax(LrPoint &min, LrPoint &max) const; bool operator != (const LrLight& source); private : LrMatrix m_mat; /// @brief Couleur de la lumiere. LrColor m_color; }; Loading
LrEntityLightPlane.cpp→LrLightPlane.cpp +87 −0 Original line number Diff line number Diff line /** * @brief ENTITÉ : Gestion d'entité lumiere-surface. * @file LrEntityLightPlane.cpp * @file LrLightPlane.cpp * @date Jeudi 24 Avril 2008 * @note * @author Josselin Francois Loading @@ -17,60 +17,60 @@ #include "config.h" #endif #include "LrEntityLightPlane.h" #include "LrLightPlane.h" #include <cstdlib> LrEntityLightPlane::LrEntityLightPlane(const LrMatrix &mat) LrLightPlane::LrLightPlane(const LrMatrix &mat) : LrEntityLight(mat), LrLight(mat), m_nbRay(1) { } LrEntityLightPlane::LrEntityLightPlane(const LrEntityLightPlane &source) LrLightPlane::LrLightPlane(const LrLightPlane &source) : LrEntityLight(source) LrLight(source) { m_nbRay=source.m_nbRay; } LrEntityLightPlane::LrEntityLightPlane(const LrMatrix &mat, const LrColor &col, unsigned int nbRay) LrLightPlane::LrLightPlane(const LrMatrix &mat, const LrColor &col, unsigned int nbRay) : LrEntityLight(mat, col), LrLight(mat, col), m_nbRay(nbRay) { } LrEntityLightPlane * LrEntityLightPlane::clone() const LrLightPlane * LrLightPlane::clone() const { return new LrEntityLightPlane(*this); return new LrLightPlane(*this); } LrEntityLightPlane::~LrEntityLightPlane() LrLightPlane::~LrLightPlane() { } LrEntityLightPlane& LrEntityLightPlane::operator = (const LrEntityLightPlane& source) LrLightPlane& LrLightPlane::operator = (const LrLightPlane& source) { if (this==&source) return *this; LrEntityLight::operator = (source); LrLight::operator = (source); return *this; } bool LrEntityLightPlane::operator == (const LrEntityLightPlane& source) bool LrLightPlane::operator == (const LrLightPlane& source) { return LrEntityLight::operator == (source); return LrLight::operator == (source); } bool LrEntityLightPlane::operator != (const LrEntityLightPlane& source) bool LrLightPlane::operator != (const LrLightPlane& source) { return ! operator == (source); } LrPoint LrEntityLightPlane::getPos() const LrPoint LrLightPlane::getPos() const { LrVector v( (Real)(1.0 * rand()/RAND_MAX) * getMat().getCoeff(1,1), Loading @@ -82,11 +82,6 @@ LrPoint LrEntityLightPlane::getPos() const return LrPoint(getMat()*pt); } unsigned int LrEntityLightPlane::getNbRay() const{ unsigned int LrLightPlane::getNbRay() const{ return m_nbRay; } int LrEntityLightPlane::typeLumiere() const { return LrEntityLight::LIGHT_PLANE; }