Refactored planet rendering to different classes
This commit is contained in:
31
core/src/mindustry/maps/generators/PlanetGenerator.java
Normal file
31
core/src/mindustry/maps/generators/PlanetGenerator.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package mindustry.maps.generators;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public abstract class PlanetGenerator extends BasicGenerator implements PlanetMesher{
|
||||
protected Sector sector;
|
||||
|
||||
protected void genTile(Vec3 position, TileGen tile){
|
||||
|
||||
}
|
||||
|
||||
public void generate(Tiles tiles, Sector sec){
|
||||
this.tiles = tiles;
|
||||
this.sector = sec;
|
||||
this.rand.setSeed(sec.id);
|
||||
|
||||
TileGen gen = new TileGen();
|
||||
tiles.each((x, y) -> {
|
||||
gen.reset();
|
||||
Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height);
|
||||
|
||||
genTile(position, gen);
|
||||
tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block));
|
||||
});
|
||||
|
||||
generate(tiles);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package mindustry.maps.planet;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public interface PlanetGenerator{
|
||||
float getHeight(Vec3 position);
|
||||
Color getColor(Vec3 position);
|
||||
void generate(Vec3 position, TileGen tile);
|
||||
void decorate(Tiles tiles, Sector sec);
|
||||
}
|
||||
@@ -13,8 +13,7 @@ import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//TODO refactor into generic planet class
|
||||
public class TestPlanetGenerator extends BasicGenerator implements PlanetGenerator{
|
||||
public class TestPlanetGenerator extends PlanetGenerator{
|
||||
Simplex noise = new Simplex();
|
||||
RidgedPerlin rid = new RidgedPerlin(1, 2);
|
||||
float scl = 5f;
|
||||
@@ -68,7 +67,7 @@ public class TestPlanetGenerator extends BasicGenerator implements PlanetGenerat
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Vec3 position, TileGen tile){
|
||||
public void genTile(Vec3 position, TileGen tile){
|
||||
tile.floor = getBlock(position);
|
||||
tile.block = tile.floor.asFloor().wall;
|
||||
|
||||
@@ -81,15 +80,6 @@ public class TestPlanetGenerator extends BasicGenerator implements PlanetGenerat
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(Tiles tiles, Sector sec){
|
||||
this.tiles = tiles;
|
||||
this.sector = sec;
|
||||
rand.setSeed(sec.id);
|
||||
|
||||
generate(tiles);
|
||||
}
|
||||
|
||||
Block getBlock(Vec3 position){
|
||||
float height = rawHeight(position);
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
|
||||
Reference in New Issue
Block a user