package Hexel.generation.terrainGenerator.typeMaps;
import java.awt.Color;
import Hexel.generation.terrainGenerator.typeMaps.circle.CirclePoint;
import Hexel.generation.terrainGenerator.typeMaps.ellipse.EllipsePoint;
import Hexel.math.Vector2i;
import Hexel.util.Util;
public class TypeHeightMapGenerator {
private TypeMapGenerator tmg;
private int seed;
public TypeHeightMapGenerator(int seed){
this.seed = seed;
tmg = new TypeMapGenerator(seed);
}
public int getWaterHeight(int x, int y, Vector2i tmp){
return 0;
}
public int getHeight(int x, int y, Vector2i tmp){
double h = 0;
int a = 1;
for (int dx = -a; dx <= a; dx++){
for (int dy = -a; dy <= a; dy++){
h += getRawHeight(x+dx, y+dy, tmp);
}
}
int n = (2*a+1)*(2*a+1);
return (int)Math.ceil(h/n);
}
public double getRawHeight(int x, int y, Vector2i tmp) {
if (!tmg.continentGen.isLand(x, y)){
double h = -10;
if (tmg.volcanoGen.isInside(x, y, tmp)){
CirclePoint c = tmg.volcanoGen.getCirclePoint(x, y, tmp);
double height = 20+10*Util.hashToGaussian(Util.hash(seed, c.cx, c.cy));
double p = c.percentToR;
if (p > 1)
p = 1;
h = (h+height*(1-p))/2;
}
return h;
}
else {
double h = 0;
if (tmg.mountainGen.isInside(x, y, tmp)){
EllipsePoint e = tmg.mountainGen.getEllipsePoint(x, y, tmp);
double height = 10+5*Util.hashToGaussian(Util.hash(seed, e.cx, e.cy));
if (height < 2)
height = 2;
double p = (e.percentToR2*.8+e.percentToR1*.2);
if (p > 1)
p = 1;
h += height*(1-p);
}
if (tmg.valleyGen.isInside(x, y, tmp)){
EllipsePoint e = tmg.valleyGen.getEllipsePoint(x, y, tmp);
double height = 10+5*Util.hashToGaussian(Util.hash(seed, e.cx, e.cy));
if (height < 2)
height = 2;
double p = (e.percentToR2*.5+e.percentToR1*.5);
if (p > 1)
p = 1;
int dh = (int)(height*(1-p));
if (dh < 1)
dh = 1;
h -= dh;
}
if (tmg.volcanoGen.isInside(x, y, tmp)){
CirclePoint c = tmg.volcanoGen.getCirclePoint(x, y, tmp);
double height = 20+10*Util.hashToGaussian(Util.hash(seed, c.cx, c.cy));
double p = c.percentToR;
if (p > 1)
p = 1;
h += height*(1-p);
}
return h;
}
}
}