Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy |
4 |
|
|
** File description: |
5 |
|
|
** PerlinNoise |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef PERLINNOISE_HPP_ |
9 |
|
|
#define PERLINNOISE_HPP_ |
10 |
|
|
|
11 |
|
|
#include <vector> |
12 |
|
|
#include <cmath> |
13 |
|
|
#include <algorithm> |
14 |
|
|
#include <numeric> |
15 |
|
|
#include <random> |
16 |
|
|
|
17 |
|
|
class PerlinNoise { |
18 |
|
|
public: |
19 |
|
|
|
20 |
|
✗ |
PerlinNoise(unsigned int seed = std::random_device{}()) { |
21 |
|
✗ |
initPermutationVector(seed); |
22 |
|
✗ |
} |
23 |
|
✗ |
~PerlinNoise() {}; |
24 |
|
|
|
25 |
|
|
float noise(float x, float y); |
26 |
|
|
float fade(float t); |
27 |
|
|
|
28 |
|
|
float lerp(float t, float a, float b); |
29 |
|
|
|
30 |
|
|
float grad(int hash, float x, float y); |
31 |
|
|
protected: |
32 |
|
|
private: |
33 |
|
|
std::vector<int> _p; |
34 |
|
|
void initPermutationVector(unsigned int seed); |
35 |
|
|
}; |
36 |
|
|
|
37 |
|
|
#endif /* !PERLINNOISE_HPP_ */ |
38 |
|
|
|