Noise: Refresh module using ZNoise
https://github.com/Overdrivr/ZNoise Former-commit-id: 3f7be1c8fd14e074826ca667676412ea4989621c [formerly 882d0bdad12c264766dc00869ac07bbecbee7306] Former-commit-id: b12a4654bb5b9ff3fdd474704d66aa10fd2d756d
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2015 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 NAZARA_ABSTRACT2DNOISE_HPP
|
||||
#define NAZARA_ABSTRACT2DNOISE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Abstract2DNoise : public MappedNoiseBase
|
||||
{
|
||||
public:
|
||||
virtual ~Abstract2DNoise();
|
||||
|
||||
float GetBasicValue(float x, float y);
|
||||
float GetMappedValue(float x, float y);
|
||||
virtual float GetValue(float x, float y, float resolution) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACT2DNOISE_HPP
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2015 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 NAZARA_ABSTRACT3DNOISE_HPP
|
||||
#define NAZARA_ABSTRACT3DNOISE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Abstract3DNoise : public MappedNoiseBase
|
||||
{
|
||||
public:
|
||||
virtual ~Abstract3DNoise();
|
||||
|
||||
float GetBasicValue(float x, float y, float z);
|
||||
float GetMappedValue(float x, float y, float z);
|
||||
virtual float GetValue(float x, float y, float z, float resolution) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACT3DNOISE_HPP
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2015 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 NAZARA_ABSTRACT4DNOISE_HPP
|
||||
#define NAZARA_ABSTRACT4DNOISE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MappedNoiseBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Abstract4DNoise : public MappedNoiseBase
|
||||
{
|
||||
public:
|
||||
virtual ~Abstract4DNoise();
|
||||
|
||||
float GetBasicValue(float x, float y, float z, float w);
|
||||
float GetMappedValue(float x, float y, float z, float w);
|
||||
virtual float GetValue(float x, float y, float z, float w, float resolution) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ABSTRACT4DNOISE_HPP
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef COMPLEXNOISEBASE_HPP
|
||||
#define COMPLEXNOISEBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
ComplexNoiseBase();
|
||||
~ComplexNoiseBase() = default;
|
||||
|
||||
float GetHurstParameter() const;
|
||||
float GetLacunarity() const;
|
||||
float GetOctaveNumber() const;
|
||||
void SetHurstParameter(float h);
|
||||
void SetLacunarity(float lacunarity);
|
||||
void SetOctavesNumber(float octaves);
|
||||
void RecomputeExponentArray();
|
||||
|
||||
protected:
|
||||
float m_lacunarity;
|
||||
float m_hurst;
|
||||
float m_octaves;
|
||||
std::array<float, 30> m_exponent_array;
|
||||
float m_sum;
|
||||
|
||||
private:
|
||||
bool m_parametersModified;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMPLEXNOISEBASE_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Nazara Engine - Noise module
|
||||
|
||||
Copyright (C) 2015 Rémi "Overdrivr" Bèges (remi.beges@laposte.net)
|
||||
Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
||||
18
include/Nazara/Noise/Enums.hpp
Normal file
18
include/Nazara/Noise/Enums.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_ENUMS_NOISE_HPP
|
||||
#define NAZARA_ENUMS_NOISE_HPP
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum WorleyFunction
|
||||
{
|
||||
WorleyFunction_F1 = 0,
|
||||
WorleyFunction_F2 = 1,
|
||||
WorleyFunction_F3 = 2,
|
||||
WorleyFunction_F4 = 3
|
||||
};
|
||||
}
|
||||
#endif // NAZARA_ENUMS_NOISE_HPP
|
||||
30
include/Nazara/Noise/FBM.hpp
Normal file
30
include/Nazara/Noise/FBM.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_FBM_HPP
|
||||
#define NAZARA_FBM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/Enums.hpp>
|
||||
#include <Nazara/Noise/MixerBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API FBM : public MixerBase
|
||||
{
|
||||
public:
|
||||
FBM(const NoiseBase& source);
|
||||
FBM(const FBM&) = delete;
|
||||
~FBM() = default;
|
||||
|
||||
float Get(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
FBM& operator=(const FBM&) = delete;
|
||||
|
||||
private:
|
||||
const NoiseBase& m_source;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_FBM_HPP
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (C) 2015 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 FBM2D_HPP
|
||||
#define FBM2D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API FBM2D : public Abstract2DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
FBM2D(NoiseType source, unsigned int seed);
|
||||
float GetValue(float x, float y, float resolution);
|
||||
~FBM2D();
|
||||
|
||||
private:
|
||||
Abstract2DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FBM2D_HPP
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright (C) 2015 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 FBM3D_HPP
|
||||
#define FBM3D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API FBM3D : public Abstract3DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
FBM3D(NoiseType source, unsigned int seed);
|
||||
float GetValue(float x, float y, float z, float resolution);
|
||||
~FBM3D();
|
||||
|
||||
private:
|
||||
Abstract3DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FBM3D_HPP
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright (C) 2015 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 FBM4D_HPP
|
||||
#define FBM4D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API FBM4D : public Abstract4DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
FBM4D(NoiseType source, unsigned int seed);
|
||||
float GetValue(float x, float y, float z, float w, float resolution);
|
||||
~FBM4D();
|
||||
|
||||
private:
|
||||
Abstract4DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FBM4D_HPP
|
||||
|
||||
34
include/Nazara/Noise/HybridMultiFractal.hpp
Normal file
34
include/Nazara/Noise/HybridMultiFractal.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_HYBRIDMULTIFRACTAL_HPP
|
||||
#define NAZARA_HYBRIDMULTIFRACTAL_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/MixerBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API HybridMultiFractal : public MixerBase
|
||||
{
|
||||
public:
|
||||
HybridMultiFractal(const NoiseBase & source);
|
||||
HybridMultiFractal(const HybridMultiFractal&) = delete;
|
||||
~HybridMultiFractal() = default;
|
||||
|
||||
float Get(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
HybridMultiFractal& operator=(const HybridMultiFractal&) = delete;
|
||||
|
||||
private:
|
||||
const NoiseBase& m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
float m_offset;
|
||||
float m_weight;
|
||||
float m_signal;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_HYBRIDMULTIFRACTAL_HPP
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (C) 2015 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 HYBRIDMULTIFRACTAL2D_HPP
|
||||
#define HYBRIDMULTIFRACTAL2D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API HybridMultiFractal2D : public Abstract2DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
HybridMultiFractal2D(NoiseType source, unsigned int seed);
|
||||
~HybridMultiFractal2D();
|
||||
|
||||
float GetValue(float x, float y, float resolution);
|
||||
|
||||
private:
|
||||
Abstract2DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
float m_offset;
|
||||
float m_weight;
|
||||
float m_signal;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HYBRIDMULTIFRACTAL2D_HPP
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (C) 2015 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 HYBRIDMULTIFRACTAL3D_HPP
|
||||
#define HYBRIDMULTIFRACTAL3D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API HybridMultiFractal3D : public Abstract3DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
HybridMultiFractal3D(NoiseType source, unsigned int seed);
|
||||
~HybridMultiFractal3D();
|
||||
|
||||
float GetValue(float x, float y, float z, float resolution);
|
||||
|
||||
private:
|
||||
Abstract3DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
float m_offset;
|
||||
float m_weight;
|
||||
float m_signal;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HYBRIDMULTIFRACTAL3D_HPP
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (C) 2015 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 HYBRIDMULTIFRACTAL4D_HPP
|
||||
#define HYBRIDMULTIFRACTAL4D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/ComplexNoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API HybridMultiFractal4D : public Abstract4DNoise, public ComplexNoiseBase
|
||||
{
|
||||
public:
|
||||
HybridMultiFractal4D(NoiseType source, unsigned int seed);
|
||||
~HybridMultiFractal4D();
|
||||
|
||||
float GetValue(float x, float y, float z, float w, float resolution);
|
||||
|
||||
private:
|
||||
Abstract4DNoise* m_source;
|
||||
float m_value;
|
||||
float m_remainder;
|
||||
float m_offset;
|
||||
float m_weight;
|
||||
float m_signal;
|
||||
NoiseType m_noiseType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HYBRIDMULTIFRACTAL4D_HPP
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (C) 2015 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 NAZARA_MAPPEDNOISEBASE_HPP
|
||||
#define NAZARA_MAPPEDNOISEBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API MappedNoiseBase : public NoiseBase
|
||||
{
|
||||
public:
|
||||
MappedNoiseBase();
|
||||
~MappedNoiseBase() = default;
|
||||
|
||||
float GetGain() const;
|
||||
float GetOffset() const;
|
||||
float GetResolution() const;
|
||||
void SetGain(float gain);
|
||||
void SetOffset(float offset);
|
||||
void SetResolution(float resolution);
|
||||
|
||||
protected:
|
||||
float m_gain;
|
||||
float m_offset;
|
||||
float m_resolution;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MAPPEDNOISEBASE_HPP
|
||||
38
include/Nazara/Noise/MixerBase.hpp
Normal file
38
include/Nazara/Noise/MixerBase.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_MIXERBASE_HPP
|
||||
#define NAZARA_MIXERBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API MixerBase
|
||||
{
|
||||
public:
|
||||
MixerBase();
|
||||
~MixerBase() = default;
|
||||
|
||||
float GetHurstParameter() const;
|
||||
float GetLacunarity() const;
|
||||
float GetOctaveNumber() const;
|
||||
|
||||
void SetParameters(float hurst, float lacunarity, float octaves);
|
||||
|
||||
protected:
|
||||
float m_hurst;
|
||||
float m_lacunarity;
|
||||
float m_octaves;
|
||||
std::vector<float> m_exponent_array;
|
||||
float m_sum;
|
||||
|
||||
private:
|
||||
void Recompute();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MIXERBASE_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
||||
@@ -1,48 +1,38 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NOISEBASE_HPP
|
||||
#define NOISEBASE_HPP
|
||||
#ifndef NAZARA_NOISEBASE_HPP
|
||||
#define NAZARA_NOISEBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/Config.hpp>
|
||||
#include <random>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
enum NoiseType
|
||||
{
|
||||
PERLIN,
|
||||
SIMPLEX,
|
||||
CELL
|
||||
};
|
||||
|
||||
class NAZARA_NOISE_API NoiseBase
|
||||
{
|
||||
public:
|
||||
NoiseBase(unsigned int seed = 0);
|
||||
~NoiseBase() = default;
|
||||
|
||||
void SetNewSeed(unsigned int seed);
|
||||
virtual float Get(std::initializer_list<float> coordinates, float scale) const = 0;
|
||||
float GetScale();
|
||||
|
||||
void ShufflePermutationTable();
|
||||
void SetScale(float scale);
|
||||
void SetSeed(unsigned int seed);
|
||||
|
||||
unsigned int GetUniformRandomValue();
|
||||
|
||||
int fastfloor(float n);
|
||||
int JenkinsHash(int a, int b, int c);
|
||||
void Shuffle();
|
||||
void Shuffle(unsigned int amount);
|
||||
|
||||
protected:
|
||||
unsigned int perm[512];
|
||||
float m_scale;
|
||||
|
||||
private:
|
||||
unsigned int Ua, Uc, Um;
|
||||
unsigned int UcurrentSeed;
|
||||
unsigned int Uprevious, Ulast;
|
||||
|
||||
std::default_random_engine generator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NOISEBASE_HPP
|
||||
#endif // NAZARA_NOISEBASE_HPP
|
||||
|
||||
14
include/Nazara/Noise/NoiseTools.hpp
Normal file
14
include/Nazara/Noise/NoiseTools.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_NOISETOOLS_HPP
|
||||
#define NAZARA_NOISETOOLS_HPP
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
int fastfloor(float n);
|
||||
int JenkinsHash(int a, int b, int c);
|
||||
}
|
||||
|
||||
#endif // NAZARA_NOISETOOLS_HPP
|
||||
36
include/Nazara/Noise/Perlin.hpp
Normal file
36
include/Nazara/Noise/Perlin.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_PERLIN_HPP
|
||||
#define NAZARA_PERLIN_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/Config.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Perlin : public NoiseBase
|
||||
{
|
||||
public:
|
||||
Perlin();
|
||||
Perlin(unsigned int seed);
|
||||
~Perlin() = default;
|
||||
|
||||
float Get(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
protected:
|
||||
float _2D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _3D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _4D(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
private:
|
||||
const float gradient2[8][2];
|
||||
const float gradient3[16][3];
|
||||
const float gradient4[32][4];
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_PERLIN_HPP
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PERLIN2D_HPP
|
||||
#define PERLIN2D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Perlin2D : public Abstract2DNoise
|
||||
{
|
||||
public:
|
||||
Perlin2D();
|
||||
Perlin2D(unsigned int seed);
|
||||
~Perlin2D() = default;
|
||||
|
||||
float GetValue(float x, float y, float resolution);
|
||||
|
||||
private:
|
||||
int x0, y0;
|
||||
int gi0,gi1,gi2,gi3;
|
||||
int ii, jj;
|
||||
float gradient2[8][2];
|
||||
float s,t,u,v;
|
||||
float Cx,Cy;
|
||||
float Li1, Li2;
|
||||
Vector2<float> temp;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PERLIN2D_HPP
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PERLIN3D_HPP
|
||||
#define PERLIN3D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Perlin3D : public Abstract3DNoise
|
||||
{
|
||||
public:
|
||||
Perlin3D();
|
||||
Perlin3D(unsigned int seed);
|
||||
~Perlin3D() = default;
|
||||
|
||||
float GetValue(float x, float y, float z, float resolution);
|
||||
|
||||
private:
|
||||
int x0,y0,z0;
|
||||
int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7;
|
||||
int ii,jj,kk;
|
||||
float gradient3[16][3];
|
||||
float Li1,Li2,Li3,Li4,Li5,Li6;
|
||||
float s[2],t[2],u[2],v[2];
|
||||
float Cx,Cy,Cz;
|
||||
float nx,ny,nz;
|
||||
float tmp;
|
||||
Vector3<float> temp;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PERLIN3D_HPP
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PERLIN4D_HPP
|
||||
#define PERLIN4D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Perlin4D : public Abstract4DNoise
|
||||
{
|
||||
public:
|
||||
Perlin4D();
|
||||
Perlin4D(unsigned int seed);
|
||||
~Perlin4D() = default;
|
||||
|
||||
float GetValue(float x, float y, float z, float w, float resolution);
|
||||
|
||||
private:
|
||||
int x0,y0,z0,w0;
|
||||
int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15;
|
||||
int ii,jj,kk,ll;
|
||||
float gradient4[32][4];
|
||||
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;
|
||||
float tmp;
|
||||
Vector4<float> temp;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PERLIN4D_HPP
|
||||
43
include/Nazara/Noise/Simplex.hpp
Normal file
43
include/Nazara/Noise/Simplex.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef SIMPLEX_HPP
|
||||
#define SIMPLE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/Config.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Simplex : public NoiseBase
|
||||
{
|
||||
public:
|
||||
Simplex();
|
||||
Simplex(unsigned int seed);
|
||||
~Simplex() = default;
|
||||
|
||||
float Get(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
protected:
|
||||
float _2D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _3D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _4D(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
private:
|
||||
const float gradient2[8][2];
|
||||
const float gradient3[16][3];
|
||||
const float gradient4[32][4];
|
||||
const float UnskewCoeff2D;
|
||||
const float SkewCoeff2D;
|
||||
const float UnskewCoeff3D;
|
||||
const float SkewCoeff3D;
|
||||
const float UnskewCoeff4D;
|
||||
const float SkewCoeff4D;
|
||||
const int lookupTable4D[64][4];
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SIMPLEX_HPP
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SIMPLEX2D_HPP
|
||||
#define SIMPLEX2D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract2DNoise.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Simplex2D : public Abstract2DNoise
|
||||
{
|
||||
public:
|
||||
Simplex2D();
|
||||
Simplex2D(unsigned int seed);
|
||||
virtual ~Simplex2D() = default;
|
||||
|
||||
float GetValue(float x, float y, float resolution);
|
||||
|
||||
private:
|
||||
int ii,jj;
|
||||
int gi0,gi1,gi2;
|
||||
Vector2i skewedCubeOrigin,off1;
|
||||
float n1,n2,n3;
|
||||
float c1,c2,c3;
|
||||
float gradient2[8][2];
|
||||
float UnskewCoeff2D;
|
||||
float SkewCoeff2D;
|
||||
float sum;
|
||||
Vector2<float> unskewedCubeOrigin, unskewedDistToOrigin;
|
||||
Vector2<float> d1,d2,d3;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SIMPLEX2D_HPP
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SIMPLEX3D_HPP
|
||||
#define SIMPLEX3D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract3DNoise.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Simplex3D : public Abstract3DNoise
|
||||
{
|
||||
public:
|
||||
Simplex3D();
|
||||
Simplex3D(unsigned int seed);
|
||||
~Simplex3D() = default;
|
||||
|
||||
float GetValue(float x, float y, float z, float resolution);
|
||||
|
||||
private:
|
||||
int ii,jj,kk;
|
||||
int gi0,gi1,gi2,gi3;
|
||||
Vector3i skewedCubeOrigin,off1,off2;
|
||||
float n1,n2,n3,n4;
|
||||
float c1,c2,c3,c4;
|
||||
float gradient3[12][3];
|
||||
float UnskewCoeff3D;
|
||||
float SkewCoeff3D;
|
||||
float sum;
|
||||
Vector3<float> unskewedCubeOrigin, unskewedDistToOrigin;
|
||||
Vector3<float> d1,d2,d3,d4;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SIMPLEX3D_HPP
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright (C) 2015 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SIMPLEX4D_HPP
|
||||
#define SIMPLEX4D_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <Nazara/Noise/Abstract4DNoise.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Simplex4D : public Abstract4DNoise
|
||||
{
|
||||
public:
|
||||
Simplex4D();
|
||||
Simplex4D(unsigned int seed);
|
||||
~Simplex4D() = default;
|
||||
|
||||
float GetValue(float x, float y, float z, float w, float resolution);
|
||||
|
||||
private:
|
||||
int ii,jj,kk,ll;
|
||||
int gi0,gi1,gi2,gi3,gi4;
|
||||
Vector4i skewedCubeOrigin,off1,off2,off3;
|
||||
int lookupTable4D[64][4];
|
||||
int c;
|
||||
float n1,n2,n3,n4,n5;
|
||||
float c1,c2,c3,c4,c5,c6;
|
||||
float gradient4[32][4];
|
||||
float UnskewCoeff4D;
|
||||
float SkewCoeff4D;
|
||||
float sum;
|
||||
Vector4<float> unskewedCubeOrigin, unskewedDistToOrigin;
|
||||
Vector4<float> d1,d2,d3,d4,d5;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SIMPLEX4D_H
|
||||
|
||||
41
include/Nazara/Noise/Worley.hpp
Normal file
41
include/Nazara/Noise/Worley.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine - Noise module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef NAZARA_WORLEY_HPP
|
||||
#define NAZARA_WORLEY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Noise/Config.hpp>
|
||||
#include <Nazara/Noise/Enums.hpp>
|
||||
#include <Nazara/Noise/NoiseBase.hpp>
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_NOISE_API Worley : public NoiseBase
|
||||
{
|
||||
public:
|
||||
Worley();
|
||||
Worley(unsigned int seed);
|
||||
~Worley() = default;
|
||||
|
||||
void Set(WorleyFunction func);
|
||||
|
||||
float Get(std::initializer_list<float> coordinates, float scale) const;
|
||||
|
||||
protected:
|
||||
float _2D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _3D(std::initializer_list<float> coordinates, float scale) const;
|
||||
float _4D(std::initializer_list<float> coordinates, float scale) const;
|
||||
void _SquareTest(int xi, int yi, float x, float y, std::map<float, Vector2f> & featurePoints) const;
|
||||
|
||||
private:
|
||||
const float scales[4];
|
||||
WorleyFunction function;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_WORLEY_HPP
|
||||
Reference in New Issue
Block a user