116 lines
3.7 KiB
C++
116 lines
3.7 KiB
C++
// Copyright (C) 2012 Rémi Bèges
|
|
// This file is part of the "Nazara Engine".
|
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
|
|
#pragma once
|
|
|
|
#ifndef NOISEMACHINE_HPP
|
|
#define NOISEMACHINE_HPP
|
|
|
|
#include <Nazara/Prerequesites.hpp>
|
|
//#include <Nazara/Noise/NoiseBase.hpp>
|
|
#include "NoiseBase.hpp"
|
|
#include <Nazara/Math/Vector2.hpp>
|
|
#include <Nazara/Math/Vector3.hpp>
|
|
#include <Nazara/Math/Vector4.hpp>
|
|
|
|
//TODO : tableau de gradients en float au lieu de int ? Ou condition ternaires ?
|
|
// utiliser fastfloor partout
|
|
// vérifier bon fonctionnement perlin1d
|
|
|
|
class NzNoiseMachine : public NzNoiseBase
|
|
{
|
|
public:
|
|
NzNoiseMachine(int seed = 0);
|
|
~NzNoiseMachine();
|
|
|
|
float Get1DPerlinNoiseValue (float x, float res);
|
|
float Get2DPerlinNoiseValue (float x, float y, float res);
|
|
float Get3DPerlinNoiseValue (float x, float y, float z, float res);
|
|
float Get4DPerlinNoiseValue (float x, float y, float z, float w, float res);
|
|
|
|
float Get2DSimplexNoiseValue(float x, float y, float res);
|
|
float Get3DSimplexNoiseValue(float x, float y, float z, float res);
|
|
float Get4DSimplexNoiseValue(float x, float y, float z, float w, float res);
|
|
|
|
float Get2DCellNoiseValue(float x, float y, float res);
|
|
float Get3DCellNoiseValue(float x, float y, float z, float res);
|
|
float Get4DCellNoiseValue(float x, float y, float z, float w, float res);
|
|
|
|
void SetLacunarity(float lacunarity);
|
|
void SetHurstParameter(float h);
|
|
void SetOctavesNumber(float octaves);
|
|
void RecomputeExponentArray();
|
|
|
|
float Get1DFBMNoiseValue(float x, float res);
|
|
float Get2DFBMNoiseValue(float x, float y, float res);
|
|
float Get3DFBMNoiseValue(float x, float y, float z, float res);
|
|
|
|
float Get2DHybridMultiFractalNoiseValue(float x, float y, float res);
|
|
float Get3DHybridMultiFractalNoiseValue(float x, float y, float z, float res);
|
|
|
|
protected:
|
|
private:
|
|
|
|
//Pour tronquer les nombres
|
|
int fastfloor(float n);
|
|
|
|
int gradient1[2];
|
|
float gradient2[8][2];
|
|
int gradient3[16][3];
|
|
int gradient4[32][4];
|
|
int lookupTable4D[64][4];
|
|
|
|
//----------------------- Simplex variables --------------------------------------
|
|
|
|
float n1, n2, n3, n4, n5;
|
|
NzVector4f A;
|
|
NzVector4i Origin;
|
|
NzVector4f d1,d2,d3,d4,d5;
|
|
NzVector4i off1, off2,off3;
|
|
NzVector4f IsoOriginDist;
|
|
NzVector4f H[5];
|
|
|
|
int ii,jj,kk,ll;
|
|
int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15;
|
|
float lenght;
|
|
float c1,c2,c3,c4,c5,c6;
|
|
int c;
|
|
|
|
float SkewCoeff2D;
|
|
float UnskewCoeff2D;
|
|
|
|
float SkewCoeff3D;
|
|
float UnskewCoeff3D;
|
|
|
|
float SkewCoeff4D;
|
|
float UnskewCoeff4D;
|
|
|
|
//----------------------- Perlin Variables -------------------------------------
|
|
|
|
int x0,y0,z0,w0;
|
|
float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14;
|
|
float s[4],t[4],u[4],v[4];
|
|
float Cx, Cy, Cz, Cw;
|
|
NzVector4f temp;
|
|
float nx,ny,nz,nw;
|
|
float tmp;
|
|
|
|
//---------------------- Complex Noise Variables --------------------------------
|
|
|
|
float m_lacunarity;
|
|
float m_hurst;
|
|
float m_octaves;
|
|
bool m_parametersModified;
|
|
float exponent_array[30];
|
|
bool first;
|
|
float value;
|
|
float remainder;
|
|
float m_sum;
|
|
float smax;
|
|
float smin;
|
|
|
|
};
|
|
|
|
#endif // NOISEMACHINE_H
|