Merge branch 'master' into planetdraw
This commit is contained in:
@@ -22,15 +22,16 @@ public class PlanetGrid{
|
||||
{5, 3, 10, 1, 4}, {2, 5, 4, 0, 11}, {3, 7, 6, 1, 8}, {7, 2, 9, 0, 6}
|
||||
};
|
||||
|
||||
public final int size;
|
||||
public final Ptile[] tiles;
|
||||
public final Corner[] corners;
|
||||
public final Edge[] edges;
|
||||
public int size;
|
||||
public Ptile[] tiles;
|
||||
public Corner[] corners;
|
||||
public Edge[] edges;
|
||||
|
||||
PlanetGrid(int size){
|
||||
//this is protected so if you want to make strange grids you should know what you're doing.
|
||||
protected PlanetGrid(int size){
|
||||
this.size = size;
|
||||
|
||||
tiles = new Ptile[Buildingount(size)];
|
||||
tiles = new Ptile[tileCount(size)];
|
||||
for(int i = 0; i < tiles.length; i++){
|
||||
tiles[i] = new Ptile(i, i < 12 ? 5 : 6);
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class PlanetGrid{
|
||||
return result;
|
||||
}
|
||||
|
||||
static PlanetGrid initialGrid(){
|
||||
public static PlanetGrid initialGrid(){
|
||||
PlanetGrid grid = new PlanetGrid(0);
|
||||
|
||||
for(Ptile t : grid.tiles){
|
||||
@@ -111,7 +112,7 @@ public class PlanetGrid{
|
||||
return grid;
|
||||
}
|
||||
|
||||
static PlanetGrid subdividedGrid(PlanetGrid prev){
|
||||
public static PlanetGrid subdividedGrid(PlanetGrid prev){
|
||||
PlanetGrid grid = new PlanetGrid(prev.size + 1);
|
||||
|
||||
int prevTiles = prev.tiles.length;
|
||||
@@ -207,7 +208,7 @@ public class PlanetGrid{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Buildingount(int size){
|
||||
static int tileCount(int size){
|
||||
return 10 * Mathf.pow(3, size) + 2;
|
||||
}
|
||||
|
||||
@@ -220,12 +221,12 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Ptile{
|
||||
public final int id;
|
||||
public final int edgeCount;
|
||||
public int id;
|
||||
public int edgeCount;
|
||||
|
||||
public final Ptile[] tiles;
|
||||
public final Corner[] corners;
|
||||
public final Edge[] edges;
|
||||
public Ptile[] tiles;
|
||||
public Corner[] corners;
|
||||
public Edge[] edges;
|
||||
|
||||
public Vec3 v = new Vec3();
|
||||
|
||||
@@ -240,11 +241,11 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Corner{
|
||||
public final int id;
|
||||
public final Ptile[] tiles = new Ptile[3];
|
||||
public final Corner[] corners = new Corner[3];
|
||||
public final Edge[] edges = new Edge[3];
|
||||
public final Vec3 v = new Vec3();
|
||||
public int id;
|
||||
public Ptile[] tiles = new Ptile[3];
|
||||
public Corner[] corners = new Corner[3];
|
||||
public Edge[] edges = new Edge[3];
|
||||
public Vec3 v = new Vec3();
|
||||
|
||||
public Corner(int id){
|
||||
this.id = id;
|
||||
@@ -252,9 +253,9 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Edge{
|
||||
public final int id;
|
||||
public final Ptile[] tiles = new Ptile[2];
|
||||
public final Corner[] corners = new Corner[2];
|
||||
public int id;
|
||||
public Ptile[] tiles = new Ptile[2];
|
||||
public Corner[] corners = new Corner[2];
|
||||
|
||||
public Edge(int id){
|
||||
this.id = id;
|
||||
|
||||
@@ -10,6 +10,7 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.type.*;
|
||||
@@ -38,19 +39,19 @@ public class PlanetRenderer implements Disposable{
|
||||
public float zoom = 1f;
|
||||
|
||||
private final Mesh[] outlines = new Mesh[10];
|
||||
private final PlaneBatch3D projector = new PlaneBatch3D();
|
||||
private final Mat3D mat = new Mat3D();
|
||||
private final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||
private PlanetInterfaceRenderer irenderer;
|
||||
public final PlaneBatch3D projector = new PlaneBatch3D();
|
||||
public final Mat3D mat = new Mat3D();
|
||||
public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||
public PlanetInterfaceRenderer irenderer;
|
||||
|
||||
private final Bloom bloom = new Bloom(Core.graphics.getWidth()/4, Core.graphics.getHeight()/4, true, false){{
|
||||
public final Bloom bloom = new Bloom(Core.graphics.getWidth()/4, Core.graphics.getHeight()/4, true, false){{
|
||||
setThreshold(0.8f);
|
||||
blurPasses = 6;
|
||||
}};
|
||||
private final Mesh atmosphere = MeshBuilder.buildHex(Color.white, 2, false, 1.5f);
|
||||
public final Mesh atmosphere = MeshBuilder.buildHex(Color.white, 2, false, 1.5f);
|
||||
|
||||
//seed: 8kmfuix03fw
|
||||
private final CubemapMesh skybox = new CubemapMesh(new Cubemap("cubemaps/stars/"));
|
||||
public final CubemapMesh skybox = new CubemapMesh(new Cubemap("cubemaps/stars/"));
|
||||
|
||||
public PlanetRenderer(){
|
||||
camPos.set(0, 0f, camLength);
|
||||
@@ -82,14 +83,20 @@ public class PlanetRenderer implements Disposable{
|
||||
projector.proj(cam.combined);
|
||||
batch.proj(cam.combined);
|
||||
|
||||
Events.fire(Trigger.universeDrawBegin);
|
||||
|
||||
beginBloom();
|
||||
|
||||
skybox.render(cam.combined);
|
||||
|
||||
Events.fire(Trigger.universeDraw);
|
||||
|
||||
renderPlanet(solarSystem);
|
||||
|
||||
endBloom();
|
||||
|
||||
Events.fire(Trigger.universeDrawEnd);
|
||||
|
||||
Gl.enable(Gl.blend);
|
||||
|
||||
irenderer.renderProjections();
|
||||
@@ -100,18 +107,19 @@ public class PlanetRenderer implements Disposable{
|
||||
cam.update();
|
||||
}
|
||||
|
||||
private void beginBloom(){
|
||||
public void beginBloom(){
|
||||
bloom.resize(Core.graphics.getWidth() / 4, Core.graphics.getHeight() / 4);
|
||||
bloom.capture();
|
||||
}
|
||||
|
||||
private void endBloom(){
|
||||
public void endBloom(){
|
||||
bloom.render();
|
||||
}
|
||||
|
||||
private void renderPlanet(Planet planet){
|
||||
if(!planet.visible()) return;
|
||||
|
||||
public void renderPlanet(Planet planet){
|
||||
if(!planet.visible()) return;
|
||||
|
||||
//render planet at offsetted position in the world
|
||||
planet.draw(cam.combined, planet.getTransform(mat));
|
||||
|
||||
@@ -139,7 +147,7 @@ public class PlanetRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
private void renderOrbit(Planet planet){
|
||||
public void renderOrbit(Planet planet){
|
||||
if(planet.parent == null || !planet.visible()) return;
|
||||
|
||||
Vec3 center = planet.parent.position;
|
||||
@@ -149,7 +157,7 @@ public class PlanetRenderer implements Disposable{
|
||||
batch.flush(Gl.lineLoop);
|
||||
}
|
||||
|
||||
private void renderSectors(Planet planet){
|
||||
public void renderSectors(Planet planet){
|
||||
//apply transformed position
|
||||
batch.proj().mul(planet.getTransform(mat));
|
||||
|
||||
@@ -270,7 +278,7 @@ public class PlanetRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
private Mesh outline(int size){
|
||||
public Mesh outline(int size){
|
||||
if(outlines[size] == null){
|
||||
outlines[size] = MeshBuilder.buildHex(new HexMesher(){
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user