Planet cleanup
This commit is contained in:
@@ -1,37 +1,9 @@
|
||||
package mindustry.maps.planet;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.noise.*;
|
||||
|
||||
public class PlanetGenerator{
|
||||
Pixmap pix = new Pixmap("planets/colors.png");
|
||||
Simplex noise = new Simplex();
|
||||
int waterLevel = 5;
|
||||
float water = waterLevel / (float)(pix.getHeight());
|
||||
float scl = 5f;
|
||||
|
||||
public float getHeight(Vec3 position){
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
|
||||
float height = Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.4f);
|
||||
if(height <= water){
|
||||
return water;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
public Color getColor(Vec3 position, float height){
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
float rad = scl;
|
||||
float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad));
|
||||
float tnoise = (float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y + 999f, position.z);
|
||||
temp = Mathf.lerp(temp, tnoise, 0.5f);
|
||||
height *= 1.2f;
|
||||
height = Mathf.clamp(height);
|
||||
|
||||
return Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1))));
|
||||
}
|
||||
public interface PlanetGenerator{
|
||||
float getHeight(Vec3 position);
|
||||
Color getColor(Vec3 position);
|
||||
}
|
||||
|
||||
40
core/src/mindustry/maps/planet/TestPlanetGenerator.java
Normal file
40
core/src/mindustry/maps/planet/TestPlanetGenerator.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package mindustry.maps.planet;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.noise.*;
|
||||
|
||||
public class TestPlanetGenerator implements PlanetGenerator{
|
||||
Pixmap pix = new Pixmap("planets/colors.png");
|
||||
Simplex noise = new Simplex();
|
||||
int waterLevel = 5;
|
||||
float water = waterLevel / (float)(pix.getHeight());
|
||||
float scl = 5f;
|
||||
|
||||
@Override
|
||||
public float getHeight(Vec3 position){
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
|
||||
float height = Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.4f);
|
||||
if(height <= water){
|
||||
return water;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
float height = getHeight(position);
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
float rad = scl;
|
||||
float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad));
|
||||
float tnoise = (float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y + 999f, position.z);
|
||||
temp = Mathf.lerp(temp, tnoise, 0.5f);
|
||||
height *= 1.2f;
|
||||
height = Mathf.clamp(height);
|
||||
|
||||
return Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1))));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user