package net.anzix.fsz.proceduralterrain;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.type.ReadOnlyColorRGBA;
/**
*
* @author elcsiga
*/
public class Layer {
public Layer(String name, ReadOnlyColorRGBA color, double minimumZoneThickness, double maximumZoneThickness, double chanceOfMinimumZoneThickness, double chanceOfMaximumZoneThickness, double rise) {
this.name = name;
this.color = new ColorRGBA();
this.color.set(color);
this.minimumZoneThickness = minimumZoneThickness;
this.maximumZoneThickness = maximumZoneThickness;
this.chanceOfMinimumZoneThickness = chanceOfMinimumZoneThickness;
this.chanceOfMaximumZoneThickness = chanceOfMaximumZoneThickness;
this.rise = rise;
this.lightMapShadowColorScale = (1.0f / (float)(Math.sqrt(rise))) * 50.0f;
double r = Math.random();
this.chanceGenerator = new NominalHeightGenerator(0.001*r, 2, r*100f );
}
private final String name;
private final ColorRGBA color;
public ColorRGBA getColor() {
return color;
}
public float getLightMapShadowColorScale() {
return lightMapShadowColorScale;
}
private final double minimumZoneThickness;
private final double maximumZoneThickness;
private final double chanceOfMinimumZoneThickness;
private final double chanceOfMaximumZoneThickness;
private final double rise;
private final float lightMapShadowColorScale;
private double chance;
private NominalHeightGenerator chanceGenerator;
public double getZoneWeight(double x, double y) {
chance = 0.7; //Math.abs(chanceGenerator.getHeight(x, y));
if (chance >= chanceOfMaximumZoneThickness)
return maximumZoneThickness;
else if (chance <= chanceOfMinimumZoneThickness)
return minimumZoneThickness;
else
return (chance - chanceOfMinimumZoneThickness)* minimumZoneThickness
+ (chanceOfMaximumZoneThickness - chance)* maximumZoneThickness ;
}
public float getRelativeRealHeight(double relativeNominalHeight) {
return (float)(relativeNominalHeight*rise);
}
public double getTotalRealThichness() {
return rise;
}
}