fix niveaux
This commit is contained in:
@@ -20,27 +20,27 @@ public class GestionnaireNiveau {
|
|||||||
// Niveau 1
|
// Niveau 1
|
||||||
niveaux.add(new Niveau(1,
|
niveaux.add(new Niveau(1,
|
||||||
new Color(112, 158, 251),
|
new Color(112, 158, 251),
|
||||||
8, 1 / 80.0, 70, 100, 500));
|
8, 1 / 30.0, 60, 0, 600));
|
||||||
|
|
||||||
// Niveau 2
|
// Niveau 2
|
||||||
niveaux.add(new Niveau(2,
|
niveaux.add(new Niveau(2,
|
||||||
new Color(187, 138, 255),
|
new Color(187, 138, 255),
|
||||||
10, 1 / 60.0, 60, 100, 500));
|
10, 1 / 25.0, 55, 0, 600));
|
||||||
|
|
||||||
// Niveau 3
|
// Niveau 3
|
||||||
niveaux.add(new Niveau(3,
|
niveaux.add(new Niveau(3,
|
||||||
new Color(255, 106, 132),
|
new Color(255, 106, 132),
|
||||||
11, 1 / 50.0, 55, 100, 500));
|
11, 1 / 20.0, 50, 0, 600));
|
||||||
|
|
||||||
// Niveau 4
|
// Niveau 4
|
||||||
niveaux.add(new Niveau(4,
|
niveaux.add(new Niveau(4,
|
||||||
new Color(191, 255, 207),
|
new Color(191, 255, 207),
|
||||||
12, 1 / 40.0, 50, 100, 500));
|
12, 1 / 17.0, 47, 0, 600));
|
||||||
|
|
||||||
// Niveau 5
|
// Niveau 5
|
||||||
niveaux.add(new Niveau(5,
|
niveaux.add(new Niveau(5,
|
||||||
new Color(251, 233, 144),
|
new Color(251, 233, 144),
|
||||||
13, 1 / 35.0, 45, 100, 500));
|
13, 1 / 15.0, 45, 100, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mettreAJour() {
|
public void mettreAJour() {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class Ligne extends ObjetGraphique {
|
|||||||
double limiteBas = gestionnaireNiveau.getLimiteBas();
|
double limiteBas = gestionnaireNiveau.getLimiteBas();
|
||||||
double hauteur = limiteBas - limiteHaut;
|
double hauteur = limiteBas - limiteHaut;
|
||||||
|
|
||||||
double bruit = noiseGenerator.noise(noisePos);
|
double bruit = noiseGenerator.noise(noisePos, 1);
|
||||||
double normalise = (bruit + 1) / 2;
|
double normalise = (bruit + 1) / 2;
|
||||||
|
|
||||||
return limiteBas - normalise * hauteur;
|
return limiteBas - normalise * hauteur;
|
||||||
|
|||||||
@@ -109,11 +109,32 @@ public class NoiseGenerator {
|
|||||||
return value / initialSize;
|
return value / initialSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Noise 1D avec nombre d'octaves controle.
|
||||||
|
* 1 octave = lisse, utilise tout le range [-1, 1].
|
||||||
|
* Plus d'octaves = plus de detail/jitter, mais converge vers 0.
|
||||||
|
*/
|
||||||
|
public double noise(double x, int octaves) {
|
||||||
|
double value = 0.0;
|
||||||
|
double size = default_size;
|
||||||
|
double weightSum = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
while (size >= 1 && count < octaves) {
|
||||||
|
value += smoothNoise((x / size), (x / size), (x / size)) * size;
|
||||||
|
weightSum += size;
|
||||||
|
size /= 2.0;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value / weightSum;
|
||||||
|
}
|
||||||
|
|
||||||
public double smoothNoise(double x, double y, double z) {
|
public double smoothNoise(double x, double y, double z) {
|
||||||
// Offset each coordinate by the seed value
|
// Offset each coordinate by the seed value
|
||||||
x += this.seed;
|
x += this.seed;
|
||||||
y += this.seed;
|
y += this.seed;
|
||||||
x += this.seed;
|
z += this.seed;
|
||||||
|
|
||||||
int X = (int) Math.floor(x) & 255; // FIND UNIT CUBE THAT
|
int X = (int) Math.floor(x) & 255; // FIND UNIT CUBE THAT
|
||||||
int Y = (int) Math.floor(y) & 255; // CONTAINS POINT.
|
int Y = (int) Math.floor(y) & 255; // CONTAINS POINT.
|
||||||
|
|||||||
Reference in New Issue
Block a user