Commit 77051b8c authored by paps's avatar paps

--no commit message

--no commit message
parent 04082d82
/**
* @brief LrPertNormalPerlinPlan : les perturbations de normal d'une optic.
* @file LrPertNormalPerlinPlan.cpp
* @date Jeudi 14 Fevrier 2008
* @note
* @author Josselin Francois
* @author Michael Nauge
* @author Axel Richard
* @author Hervé Souchaud
* @author Emeric Verschuur
*
*
* Classe représentant une perturbation de normal utilisant un bruit de perlin
*
*/
#if defined HAVE_CONFIG_H
#include "config.h"
#endif
#include "LrPertNormalPerlinPlan.h"
/*---------------------------------------------------------------------------*
* constructors and destructor *
*---------------------------------------------------------------------------*/
LrPertNormalPerlinPlan::LrPertNormalPerlinPlan()
:
LrPertNormal(),
m_perlin(),
m_bump(0.0)
{
}
LrPertNormalPerlinPlan::LrPertNormalPerlinPlan(const LrPertNormalPerlinPlan &source)
:
LrPertNormal(source),
m_perlin(),
m_bump(source.m_bump)
{
}
LrPertNormalPerlinPlan::LrPertNormalPerlinPlan(Real val_bump)
: LrPertNormal(),
m_perlin(),
m_bump(val_bump)
{
}
LrPertNormalPerlinPlan* LrPertNormalPerlinPlan::clone() const
{
return new LrPertNormalPerlinPlan(*this);
}
LrPertNormalPerlinPlan::~LrPertNormalPerlinPlan()
{
}
/*---------------------------------------------------------------------------*
* accessors *
*---------------------------------------------------------------------------*/
LrVector LrPertNormalPerlinPlan::getNormal(Real u, Real v,
const LrVector &tangent,
const LrVector &N, const LrPoint &point) const
{
//retourne une normal perturbe grace a l'appel a f_noise de perlin
Real x,y,z;
Real X,Y,Z;
X= N.x+point.x;
Y=N.y+point.y;
Z=50*N.z+100*point.z;
x = m_perlin.f_noise(X - m_bump,Y, Z) - m_perlin.f_noise(X + m_bump, Y, Z);
y = m_perlin.f_noise(X, Y - m_bump, Z) - m_perlin.f_noise(X, Y + m_bump, Z);
z = m_perlin.f_noise(X, Y, Z - m_bump) - m_perlin.f_noise(X, Y, Z + m_bump);
LrVector n(N.x+x, N.y+y, N.z+z);
n.normalize();
return n;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment