Commit dc7417ed authored by paps's avatar paps
Browse files

Ajout de la methode de calcul du rayon refracté

la methode de cacul de la couleur par refraction n'est pas implementée a cause des modif sur getintersection
 (choisir la methode si on a le temps, avant j'utilisais un booleen mais sur ce projet il faut voir)
ajout de la methode naive pour la refraction lors du calcul des ombres
ajout d'un parametre pour les optic, l'indice de refraction necessaire au calcul du rayon refracté
Donc on peut faire de la refraction mais avec un seul rayon refracté en entrée d'un objet et pas de refraction en sorti
il faut aussi prendre en compte les reflexion totale pouvant survenir à l'interieur de l'objet 
parent d0762dfd
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -76,11 +76,13 @@ void LrEntityElementary::pack(const LrMatrix &mat){
bool LrEntityElementary::getIntersection(const LrRay &ray, LrHit *hit,
        Real minBound, Real maxBound) const
{
    if (hit!=NULL)
            hit->entity=(LrEntity*)this;
    if (m_geometry->getIntersection(ray,hit,m_transf,m_transfInv,m_transfInvTransp,minBound,maxBound))
    {
        if (hit!=NULL)
        {
            hit->entity=(LrEntity*)this;
            //hit->entity=(LrEntity*)this;
            hit->optic=m_optic;
        }
        return true;
@@ -94,11 +96,13 @@ bool LrEntityElementary::getIntersection(const LrRay &ray, LrHit *hit,
bool LrEntityElementary::getIntersection(const LrRay &ray, LrHit *hit, int fragment,
                                         Real minBound, Real maxBound) const
{
    if (hit!=NULL)
            hit->entity=(LrEntity*)this;
    if (m_geometry->getIntersection(ray,hit,fragment,m_transf,m_transfInv,m_transfInvTransp,minBound,maxBound))
    {
        if (hit!=NULL)
        {
            hit->entity=(LrEntity*)this;
            //hit->entity=(LrEntity*)this;
            hit->optic=m_optic;
        }
        return true;
+3 −3
Original line number Diff line number Diff line
@@ -40,10 +40,10 @@ LrOpticBasic* LrOpticBasic::clone() const
    return new LrOpticBasic(*this);
}

LrOpticBasic::LrOpticBasic(Real specular, Real diffuse, Real transparency,
LrOpticBasic::LrOpticBasic(Real specular, Real diffuse, Real transparency, int refraction,
                      LrPertColor *pertColor,LrPertNormal *pertNormal)
:
    LrOpticElementary(specular,diffuse,transparency,pertColor,pertNormal)
    LrOpticElementary(specular,diffuse,transparency, refraction, pertColor,pertNormal)
{
}

+3 −1
Original line number Diff line number Diff line
@@ -44,10 +44,12 @@ public:
    * @param specular Real object reference.
    * @param diffuse Real object reference.    
    * @param transparency Real object reference. 
    * @param refraction indice de refraction de l'objet (lié a la transparence)
    * @param pertColor LrPertColor object pointer
    * @param pertNormal LrPertNormal object pointer.
    */
    LrOpticBasic(Real specular, Real diffuse, Real transparency, LrPertColor *pertColor,LrPertNormal *pertNormal);
    LrOpticBasic(Real specular, Real diffuse, Real transparency, int refraction,
                      LrPertColor *pertColor,LrPertNormal *pertNormal);

    /**
    * @brief LrOpticBasic clone.
+15 −1
Original line number Diff line number Diff line
@@ -43,18 +43,20 @@ LrOpticElementary::LrOpticElementary(const LrOpticElementary &source)
    m_specular(source.m_specular),
    m_diffuse(source.m_diffuse),
    m_transparency(source.m_transparency),
    m_refraction(source.m_refraction),
    m_pertColor(source.m_pertColor),
    m_pertNormal(source.m_pertNormal)
{
}

LrOpticElementary::LrOpticElementary(Real specular, Real diffuse, Real transparency, 
LrOpticElementary::LrOpticElementary(Real specular, Real diffuse, Real transparency, int refraction, 
                                      LrPertColor *pertColor,LrPertNormal *pertNormal)
:
    LrOptic(),
    m_specular(specular),
    m_diffuse(diffuse),
    m_transparency(transparency),
    m_refraction(refraction),
    m_pertColor(pertColor),
    m_pertNormal(pertNormal)

@@ -79,6 +81,7 @@ LrOpticElementary& LrOpticElementary::operator = (const LrOpticElementary &sourc
    m_specular = source.m_specular;
    m_diffuse = source.m_diffuse;
    m_transparency = source.m_transparency;
    m_refraction = source.m_refraction;
    m_pertColor = source.m_pertColor;
    m_pertNormal = source.m_pertNormal;

@@ -96,6 +99,7 @@ bool operator == (const LrOpticElementary &lhs, const LrOpticElementary &rhs)
           && (lhs.m_specular == rhs.m_specular)
           && (lhs.m_diffuse == rhs.m_diffuse)
           && (lhs.m_transparency == rhs.m_transparency)
           && (lhs.m_refraction == rhs.m_refraction)
           && (lhs.m_pertColor == rhs.m_pertColor)
           && (lhs.m_pertNormal == rhs.m_pertNormal);
}
@@ -139,6 +143,16 @@ void LrOpticElementary::setTransparency(Real transparency)
    m_transparency = transparency;
}

Real LrOpticElementary::getRefract(Real u, Real v) const
{
    return m_refraction;
}

void LrOpticElementary::setRefract(int refraction)
{
    m_refraction = refraction;
}

LrPertColor* LrOpticElementary::getPertColor(Real u, Real v, LrPoint &pointInter) const
{
    return m_pertColor;
+7 −1
Original line number Diff line number Diff line
@@ -45,10 +45,12 @@ public:
    * @param specular Real object reference.
    * @param diffuse Real object reference.    
    * @param transparency Real object reference. 
    * @param refraction indice de refraction de l'objet (lié a la transparence)
    * @param pertColor LrPertColor object pointer
    * @param pertNormal LrPertNormal object pointer.     
    */
    LrOpticElementary(Real specular, Real diffuse, Real transparency, LrPertColor *pertColor,LrPertNormal *pertNormal);
    LrOpticElementary(Real specular, Real diffuse, Real transparency, int refraction,
                      LrPertColor *pertColor,LrPertNormal *pertNormal);


    /**
@@ -81,6 +83,9 @@ public:
    virtual Real getTransparency(Real u, Real v) const;
    virtual void setTransparency(Real transparency);
    
    virtual Real getRefract(Real u, Real v) const;
    virtual void setRefract(int refraction);

    virtual LrPertColor* getPertColor(Real u, Real v, LrPoint &pointInter) const;
    virtual void setPertColor(LrPertColor *color);
    
@@ -93,6 +98,7 @@ protected:
    Real m_specular; ///@brief Facteur de spécularité.
    Real m_diffuse; ///@brief Facteur de diffusion.
    Real m_transparency; ///@brief Facteur de transparence.
    int  m_refraction; ///@brief indice de refraction.

    LrPertColor *m_pertColor; ///@brief La perturbation de couleur de l'optique.  
    LrPertNormal *m_pertNormal; ///@brief La perturbation de normal de l'optique.  
Loading