Commit 34c1338c authored by paps's avatar paps
Browse files

Modification des noms de classe pour les texture perlin

modification des constructeurs de ces classes pour prendre en compte 2 nouveaux parametre (le type d'interpolation et un coef )
ameloration des fractal perlin et ajout de la classe permettant de creer une texture de perlin basic ( avous de tester)
voir le fichier LrPertCOlorTxtPrc3DPerlin.h
parent 2d4a43a8
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
/**
 * @brief PertColor : les perturbations de couleur d'une optic.
 * @file LrPertColorTextProcDamier.cpp
 * @file LrPertColor3DDamier.cpp
 * @date Jeudi 14 Fevrier 2008
 * @note 
 * @author Josselin Francois
@@ -18,7 +18,7 @@
#include "config.h"
#endif

#include "LrPertColorTextProcDamier.h"
#include "LrPertColor3DDamier.h"
#include <math.h>
#include <stdlib.h>

@@ -26,38 +26,38 @@
 * constructors and destructor                                               *
 *---------------------------------------------------------------------------*/

LrPertColorTextProcDamier::LrPertColorTextProcDamier()
LrPertColor3DDamier::LrPertColor3DDamier()
:   LrPertColorTextProc3D(),
    dim(0.0)
{

}
LrPertColorTextProcDamier::LrPertColorTextProcDamier(const LrPertColorTextProcDamier &source)
LrPertColor3DDamier::LrPertColor3DDamier(const LrPertColor3DDamier &source)
:   LrPertColorTextProc3D(source),
    dim(source.dim)
{

}

LrPertColorTextProcDamier::LrPertColorTextProcDamier(const LrColor &c1, const LrColor &c2, Real dimension)
LrPertColor3DDamier::LrPertColor3DDamier(const LrColor &c1, const LrColor &c2, Real dimension)
:   LrPertColorTextProc3D(c1, c2, c2),
    dim(dimension)
{

}
LrPertColorTextProcDamier * LrPertColorTextProcDamier::clone() const
LrPertColor3DDamier * LrPertColor3DDamier::clone() const
{
    return new LrPertColorTextProcDamier(*this);
    return new LrPertColor3DDamier(*this);
}

LrPertColorTextProcDamier::~LrPertColorTextProcDamier()
LrPertColor3DDamier::~LrPertColor3DDamier()
{
}

/*---------------------------------------------------------------------------*
 * assignement operator(s)                                                   *
 *---------------------------------------------------------------------------*/
LrPertColorTextProcDamier& LrPertColorTextProcDamier::operator = (const LrPertColorTextProcDamier &source)
LrPertColor3DDamier& LrPertColor3DDamier::operator = (const LrPertColor3DDamier &source)
{
    if (this == &source)
        return *this;
@@ -71,18 +71,18 @@ LrPertColorTextProcDamier& LrPertColorTextProcDamier::operator = (const LrPertCo
/*---------------------------------------------------------------------------*
 * comparison operator(s)                                                    *
 *---------------------------------------------------------------------------*/
bool operator == (const LrPertColorTextProcDamier &lhs, const LrPertColorTextProcDamier &rhs)
bool operator == (const LrPertColor3DDamier &lhs, const LrPertColor3DDamier &rhs)
{
    return (LrPertColorTextProc3D&)lhs==(LrPertColorTextProc3D&)rhs && lhs.dim == rhs.dim ;

}

bool operator != (const LrPertColorTextProcDamier &lhs, const LrPertColorTextProcDamier &rhs)
bool operator != (const LrPertColor3DDamier &lhs, const LrPertColor3DDamier &rhs)
{
    return (! (lhs == rhs));
}

LrColor LrPertColorTextProcDamier:: getColor(Real u, Real v, LrPoint &point) const
LrColor LrPertColor3DDamier:: getColor(Real u, Real v, LrPoint &point) const
{
    int x = (int)(point.x / dim);
    int y = (int)(point.y / dim);
+12 −12
Original line number Diff line number Diff line
/**
 * @brief PertColor : les perturbations de couleur d'une optic.
 * @file LrPertColorTexture.h
 * @file LrPertColor3DDamier.h
 * @date Jeudi 14 Fevrier 2008
 * @note 
 * @author Josselin Francois
@@ -14,8 +14,8 @@
 * 
 */ 

#ifndef LRPERTCOLOR_TEXTURE_PROC_DAMIER_H
#define LRPERTCOLOR_TEXTURE_PROC_DAMIER_H
#ifndef LRPERTCOLOR_3D_DAMIER_H
#define LRPERTCOLOR_3D_DAMIER_H

#include "LrPertColorTextProc3D.h"

@@ -24,16 +24,16 @@
 * 
 * Classe représentant une perturbation de couleur par une texture procedurale
 */
class LrPertColorTextProcDamier : public LrPertColorTextProc3D
class LrPertColor3DDamier : public LrPertColorTextProc3D
{
    public:
    
        LrPertColorTextProcDamier();
        LrPertColor3DDamier();
        /**
        * @brief LrPertColorTextProcDmaier copy constructor
        * @param source LrPertColorTextProcDmaier object reference.
        */
        LrPertColorTextProcDamier(const LrPertColorTextProcDamier &source);
        LrPertColor3DDamier(const LrPertColor3DDamier &source);
    
        /**
        * @brief LrPertColorTextProcDmaier personnal constructor 
@@ -42,31 +42,31 @@ class LrPertColorTextProcDamier : public LrPertColorTextProc3D
        * @param c3 couleur 3 de la texture.
        * @param dimension dimension des damiers
        */
        LrPertColorTextProcDamier(const LrColor &c1, const LrColor &c2, Real dimension);
        LrPertColor3DDamier(const LrColor &c1, const LrColor &c2, Real dimension);
    
    
        /**
        * @brief LrPertColorTexture clone.
        * @return LrPertColorTexture pointer object.
        */
        LrPertColorTextProcDamier * clone() const;
        LrPertColor3DDamier * clone() const;
    
        /**
        * @brief LrPertColorTexture destructor
        */
        virtual ~LrPertColorTextProcDamier();
        virtual ~LrPertColor3DDamier();
    
    
        /**
        * @brief assignement operator(s)
        */
        LrPertColorTextProcDamier & operator = (const LrPertColorTextProcDamier &source);
        LrPertColor3DDamier & operator = (const LrPertColor3DDamier &source);
    
        /**
        * @brief comparison operator(s)
        */
        friend bool operator == (const LrPertColorTextProcDamier &lhs, const LrPertColorTextProcDamier &rhs);
        friend bool operator != (const LrPertColorTextProcDamier &lhs, const LrPertColorTextProcDamier &rhs);
        friend bool operator == (const LrPertColor3DDamier &lhs, const LrPertColor3DDamier &rhs);
        friend bool operator != (const LrPertColor3DDamier &lhs, const LrPertColor3DDamier &rhs);

        /**
        * @brief accessors
+95 −0
Original line number Diff line number Diff line
/**
 * @brief PertColor : les perturbations de couleur d'une optic.
 * @file LrPertColorTextProcMarbre.cpp
 * @file LrPertColor3DPBasic.cpp
 * @date Jeudi 14 Fevrier 2008
 * @note 
 * @author Josselin Francois
@@ -18,35 +18,36 @@
#include "config.h"
#endif

#include "LrPertColorTextProcMarbre.h"
#include "LrPertColor3DPBasic.h"
#include "LrVector.h"

/*---------------------------------------------------------------------------*
 * constructors and destructor                                               *
 *---------------------------------------------------------------------------*/

LrPertColorTextProcMarbre::LrPertColorTextProcMarbre()
LrPertColor3DPBasic::LrPertColor3DPBasic()
:   LrPertColorTxtPrc3DPerlin()
{

}
LrPertColorTextProcMarbre::LrPertColorTextProcMarbre(const LrPertColorTextProcMarbre &source)
LrPertColor3DPBasic::LrPertColor3DPBasic(const LrPertColor3DPBasic &source)
:   LrPertColorTxtPrc3DPerlin(source)
{

}

LrPertColorTextProcMarbre::LrPertColorTextProcMarbre(const LrColor &c1, const LrColor &c2, const LrColor &c3, 
                                                     Real intensite, int level)
:   LrPertColorTxtPrc3DPerlin(c1, c2, c3, intensite, level)
LrPertColor3DPBasic::LrPertColor3DPBasic(const LrColor &c1, const LrColor &c2, const LrColor &c3, 
                                                             Real intensite, int level, Real multiplicateur, int typeInterpol)
:   LrPertColorTxtPrc3DPerlin(c1, c2, c3, intensite, level, multiplicateur, typeInterpol)
{

}
LrPertColorTextProcMarbre * LrPertColorTextProcMarbre::clone() const
LrPertColor3DPBasic * LrPertColor3DPBasic::clone() const
{
    return new LrPertColorTextProcMarbre(*this);
    return new LrPertColor3DPBasic(*this);
}

LrPertColorTextProcMarbre::~LrPertColorTextProcMarbre()
LrPertColor3DPBasic::~LrPertColor3DPBasic()
{

}
@@ -54,7 +55,7 @@ LrPertColorTextProcMarbre::~LrPertColorTextProcMarbre()
/*---------------------------------------------------------------------------*
 * assignement operator(s)                                                   *
 *---------------------------------------------------------------------------*/
LrPertColorTextProcMarbre& LrPertColorTextProcMarbre::operator = (const LrPertColorTextProcMarbre &source)
LrPertColor3DPBasic& LrPertColor3DPBasic::operator = (const LrPertColor3DPBasic &source)
{
    if (this == &source)
        return *this;
@@ -67,36 +68,28 @@ LrPertColorTextProcMarbre& LrPertColorTextProcMarbre::operator = (const LrPertCo
/*---------------------------------------------------------------------------*
 * comparison operator(s)                                                    *
 *---------------------------------------------------------------------------*/
bool operator == (const LrPertColorTextProcMarbre &lhs, const LrPertColorTextProcMarbre &rhs)
bool operator == (const LrPertColor3DPBasic &lhs, const LrPertColor3DPBasic &rhs)
{
    return (LrPertColorTxtPrc3DPerlin&)lhs==(LrPertColorTxtPrc3DPerlin&)rhs;

}

bool operator != (const LrPertColorTextProcMarbre &lhs, const LrPertColorTextProcMarbre &rhs)
bool operator != (const LrPertColor3DPBasic &lhs, const LrPertColor3DPBasic &rhs)
{
    return (! (lhs == rhs));
}

LrColor LrPertColorTextProcMarbre::getColor(Real u, Real v, LrPoint &point) const
LrColor LrPertColor3DPBasic::getColor(Real u, Real v, LrPoint &point) const
{
    Real noise = 0.0;
    LrPoint tmp(1 * point.x, 1 * point.y,  1 * point.z);
    for (int i = 1; i <= m_level; i ++)
    LrVector tmp(m_mult*point.x, m_mult*point.y,  m_mult*point.z);
    for (int i = 0; i < m_level; i ++)
    {
                noise += (1.0f / i ) * fabsf(m_perlin.f_noise(i * tmp.x , 
                                        i * tmp.y ,
                                        i * tmp.z));
        noise += fabsf((m_perlin.f_noise(tmp.x, tmp.y, tmp.z)));
     }
 
    //calcul du coefficient de perlin
    //noise = fabsf(sin(tmp.x+tmp.y+tmp.z + noise));
    noise = fabsf(sin(tmp.x + noise));

    noise *= m_intensity;
    //return interpolCos(C1, C2, noise);
    return interpolLinear(C1, C2, noise);
    
    if(m_interpolation == COS) return interpolCos(C1, C2, noise);
    else  return interpolLinear(C1, C2, noise);
}
 
 
+14 −12
Original line number Diff line number Diff line
/**
 * @brief PertColor : les perturbations de couleur d'une optic.
 * @file LrPertColorTextProc.h
 * @file LrPertColor3DPBasic.h
 * @date Jeudi 14 Fevrier 2008
 * @note 
 * @author Josselin Francois
@@ -14,8 +14,8 @@
 * 
 */ 

#ifndef LRPERTCOLOR_TEXTURE_PROC_TURBULENCE_H
#define LRPERTCOLOR_TEXTURE_PROC_TURBULENCE_H
#ifndef LRPERTCOLOR_3DP_BASIC_H
#define LRPERTCOLOR_3DP_BASIC_H

#include "LrPertColorTxtPrc3DPerlin.h"

@@ -25,16 +25,16 @@
 * 
 * Classe représentant une perturbation de couleur par une texture procedurale
 */
class LrPertColorTextProcTurbulence : public LrPertColorTxtPrc3DPerlin
class LrPertColor3DPBasic : public LrPertColorTxtPrc3DPerlin
{
    public:
    
        LrPertColorTextProcTurbulence();
        LrPertColor3DPBasic();
        /**
        * @brief LrPertColorTextProcDmaier copy constructor
        * @param source LrPertColorTextProcDmaier object reference.
        */
        LrPertColorTextProcTurbulence(const LrPertColorTextProcTurbulence &source);
        LrPertColor3DPBasic(const LrPertColor3DPBasic &source);
    
        /**
        * @brief LrPertColorTextProcDmaier personnal constructor 
@@ -43,31 +43,32 @@ class LrPertColorTextProcTurbulence : public LrPertColorTxtPrc3DPerlin
        * @param c3 couleur 3 de la texture.
        * @param dimension dimension des damiers
        */
        LrPertColorTextProcTurbulence(const LrColor &c1, const LrColor &c2, const LrColor &c3, Real intensite, int level);
        LrPertColor3DPBasic(const LrColor &c1, const LrColor &c2, const LrColor &c3, Real intensite, 
                                      int level, Real multiplicateur, int typeInterpol);
    
    
        /**
        * @brief LrPertColorTexture clone.
        * @return LrPertColorTexture pointer object.
        */
        LrPertColorTextProcTurbulence * clone() const;
        LrPertColor3DPBasic * clone() const;
    
        /**
        * @brief LrPertColorTexture destructor
        */
        virtual ~LrPertColorTextProcTurbulence();
        virtual ~LrPertColor3DPBasic();
    
    
        /**
        * @brief assignement operator(s)
        */
        LrPertColorTextProcTurbulence & operator = (const LrPertColorTextProcTurbulence &source);
        LrPertColor3DPBasic & operator = (const LrPertColor3DPBasic &source);
    
        /**
        * @brief comparison operator(s)
        */
        friend bool operator == (const LrPertColorTextProcTurbulence &lhs, const LrPertColorTextProcTurbulence &rhs);
        friend bool operator != (const LrPertColorTextProcTurbulence &lhs, const LrPertColorTextProcTurbulence &rhs);
        friend bool operator == (const LrPertColor3DPBasic &lhs, const LrPertColor3DPBasic &rhs);
        friend bool operator != (const LrPertColor3DPBasic &lhs, const LrPertColor3DPBasic &rhs);

        /**
        * @brief accessors
@@ -77,3 +78,4 @@ class LrPertColorTextProcTurbulence : public LrPertColorTxtPrc3DPerlin
};

#endif 
 
+30 −23
Original line number Diff line number Diff line
/**
 * @brief PertColor : les perturbations de couleur d'une optic.
 * @file LrPertColorTextProcBois.cpp
 * @file LrPertColor3DPBois.cpp
 * @date Jeudi 14 Fevrier 2008
 * @note 
 * @author Josselin Francois
@@ -18,35 +18,36 @@
#include "config.h"
#endif

#include "LrPertColorTextProcBois.h"
#include "LrPertColor3DPBois.h"
#include "LrVector.h"

/*---------------------------------------------------------------------------*
 * constructors and destructor                                               *
 *---------------------------------------------------------------------------*/

LrPertColorTextProcBois::LrPertColorTextProcBois()
LrPertColor3DPBois::LrPertColor3DPBois()
:   LrPertColorTxtPrc3DPerlin()
{

}
LrPertColorTextProcBois::LrPertColorTextProcBois(const LrPertColorTextProcBois &source)
LrPertColor3DPBois::LrPertColor3DPBois(const LrPertColor3DPBois &source)
:   LrPertColorTxtPrc3DPerlin(source)
{

}

LrPertColorTextProcBois::LrPertColorTextProcBois(const LrColor &c1, const LrColor &c2, const LrColor &c3, 
                                                 Real intensite, int level)
:   LrPertColorTxtPrc3DPerlin(c1, c2, c3, intensite, level)
LrPertColor3DPBois::LrPertColor3DPBois(const LrColor &c1, const LrColor &c2, const LrColor &c3, 
                                                 Real intensite, int level, Real multiplicateur, int typeInterpol)
:   LrPertColorTxtPrc3DPerlin(c1, c2, c3, intensite, level, multiplicateur, typeInterpol)
{

}
LrPertColorTextProcBois * LrPertColorTextProcBois::clone() const
LrPertColor3DPBois * LrPertColor3DPBois::clone() const
{
    return new LrPertColorTextProcBois(*this);
    return new LrPertColor3DPBois(*this);
}

LrPertColorTextProcBois::~LrPertColorTextProcBois()
LrPertColor3DPBois::~LrPertColor3DPBois()
{

}
@@ -54,7 +55,7 @@ LrPertColorTextProcBois::~LrPertColorTextProcBois()
/*---------------------------------------------------------------------------*
 * assignement operator(s)                                                   *
 *---------------------------------------------------------------------------*/
LrPertColorTextProcBois& LrPertColorTextProcBois::operator = (const LrPertColorTextProcBois &source)
LrPertColor3DPBois& LrPertColor3DPBois::operator = (const LrPertColor3DPBois &source)
{
    if (this == &source)
        return *this;
@@ -67,35 +68,41 @@ LrPertColorTextProcBois& LrPertColorTextProcBois::operator = (const LrPertColorT
/*---------------------------------------------------------------------------*
 * comparison operator(s)                                                    *
 *---------------------------------------------------------------------------*/
bool operator == (const LrPertColorTextProcBois &lhs, const LrPertColorTextProcBois &rhs)
bool operator == (const LrPertColor3DPBois &lhs, const LrPertColor3DPBois &rhs)
{
    return (LrPertColorTxtPrc3DPerlin&)lhs==(LrPertColorTxtPrc3DPerlin&)rhs;

}

bool operator != (const LrPertColorTextProcBois &lhs, const LrPertColorTextProcBois &rhs)
bool operator != (const LrPertColor3DPBois &lhs, const LrPertColor3DPBois &rhs)
{
    return (! (lhs == rhs));
}

LrColor LrPertColorTextProcBois::getColor(Real u, Real v, LrPoint &point) const
LrColor LrPertColor3DPBois::getColor(Real u, Real v, LrPoint &point) const
{
    Real t, noise;
    t = 0.0;
    //les seuils
    Real v1= 0.25;
    Real v2= 0.5;
    Real v3 =0.75;
    //point.normalize();
    //calcul du coefficient de m_perlin a partir de la partie entiere
    t = 20 * m_perlin.f_noise(point.x, point.y, point.z); 
    noise = t = 0.0;
    LrPoint tmp(m_mult*point.x, m_mult*point.y,  m_mult*point.z);
    for (int i = 0; i < m_level; i ++)
    {
                t += 20 * (m_perlin.f_noise(tmp.x, tmp.y, tmp.z));
    }
    noise = fabsf(t - floor(t));
    noise *= m_intensity;
    if(m_interpolation == COS) return interpolCos(C1, C2, noise);
    else  return interpolLinear(C1, C2, noise);
    
    /*Real v1= 0.25;
    Real v2= 0.5;
    Real v3 =0.75;
    
    //calcul du coefficient de m_perlin a partir de la partie entiere
    //t = 20 * (m_perlin.f_noise(point.x, point.y, point.z)); 
    if(noise < v1) return C1;
    if(v1 < noise && noise < v2) return interpolCos (C1, C2, noise);
    if(v2 < noise && noise < v3) return interpolCos (C2, C3, noise);
    if(noise > v3) return C3;
    return C3;*/
}


Loading